kereedy
unread,Apr 18, 2011, 8:26:41 PM4/18/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Purdue Android Programming
I'm trying to get a high quality image using an camera on an Android
phone. At the moment I am using the code below. The problem I am
having is that this method gives me a thumbnail-sized Bitmap image,
while I want the high quality image for my program. At the moment I am
merely scaling up the image to increase its size, but the quality is
terrible. I was wondering if anyone knew how to get the better quality
image from the camera.
Thanks for any help!
Code:
// I have this in earlier my activity, it's how I call the camera
Intent cameraIntent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
....
// This is what I'm using to get the bitmap at the moment
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
if (requestCode == CAMERA_PIC_REQUEST)
{
if(resultCode != RESULT_CANCELED)
{
// I believe this is the source of my problem
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
Bitmap scaledImage = Bitmap.createScaledBitmap(thumbnail, 312,
540, false);
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
scaledImage.compress(CompressFormat.JPEG, 100, bos);
bis = new ByteArrayInputStream(bos.toByteArray());
} catch (Exception e) {
Log.e("outstream_tag", "Problem with
ByteArrayOutputStream " + e.getMessage());
}
showDialog(0);
ivPhoto.setVisibility(ImageView.VISIBLE);
ivPhoto.setImageBitmap(scaledImage);
btnTakePhoto.setVisibility(ImageView.VISIBLE);
}
else
{
btnTakePhoto.setVisibility(ImageView.VISIBLE);
}
}
}