In the app I’m working on, a button opens the camera. When you take a picture, that picture is loaded into the app as a Bitmap. The pictures are very pixelated. How can I increase the quality of the bitmap after it has been loaded into my app?
Code so far:
private static final int CAMERA_PIC_REQUEST = 2500;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button capture = (Button) findViewById(R.id.captureButton);
Button flip = (Button) findViewById(R.id.flipButton);
final TextView text = (TextView) findViewById(R.id.text);
capture.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
text.setVisibility(View.GONE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
});
flip.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data){
if(requestCode == CAMERA_PIC_REQUEST){
Bitmap image = (Bitmap) data.getExtras().get("data");
ImageView imageView = (ImageView) findViewById(R.id.ImageView01);
imageView.setImageBitmap(image);
}
}
}
Do not get that image from data, it is always a low quality image. Try using a file path and get the image from file path.
Open Camera
And when you return to onActivityResult the image will be stored to your defined path. You can get the high resolution image from there. Or you can also use a function to get last captured image …
This function will return you the last captured image path.