Reputation: 5063
I am capturing the image from the native camera of device and showing it in another activity using imageview.Problem is that in OnActivityResult method i am getting the bitmap which is blurred.I want to get Bitmap of original size image.can anyone help me??Thanks in advance.This is my code in which i am getting the bitmap in onActivityResult method and save it to the sd card.The image is getting blurred from sd card.
camera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent mIntent=new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(mIntent, CAMERA_PIC_REQUEST);
WookAtMeStaticVariables.retakePic=false;
} catch (Exception e) {
clickmessage="OnClickevent Exception"+e.getMessage();
showAlertDialogForCameraClickException(TakePic.this);
}
}
});
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
if (requestCode == CAMERA_PIC_REQUEST && resultCode==RESULT_OK)
{
imageBitmap=(Bitmap)data.getExtras().get("data");
imageBitmap = Bitmap.createScaledBitmap (imageBitmap,750,750, false);
File file = new File(Environment.getExternalStorageDirectory(),"WookAtMepic"+System.currentTimeMillis()+".jpg");
WookAtMeStaticVariables.mImageFilePath=file.getAbsolutePath();
OutputStream outStream = null;
try {
outStream = new FileOutputStream(file);
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
outStream.flush();
outStream.close();
}
catch(Exception e)
{
e.printStackTrace();
}
Intent afterTakePicIntent= new Intent(TakePic.this,AfterTakePic.class);
startActivity(afterTakePicIntent);
}
} catch (Exception e) {
resultMessage="OnResultevent Exception"+e.getMessage();
showAlertDialogForCameraResultException(TakePic.this);
}
}
Upvotes: 1
Views: 2054
Reputation: 14274
It's easily overlooked, but the image you receive from ACTION_IMAGE_CAPTURE is going to be a small bitmap, UNLESS you specify EXTRA_OUTPUT. See notes here. The reason for that is that a full-scale image is likely going to be pretty large, in the order of several MB, and passing that amount of data around with as in intent-extra is problematic.
So you'll need to pass it the storage URI for a temporary file (or you can publish your own content-provider), and then resize it.
Upvotes: 1