tags:

views:

488

answers:

1

Has anyone come across a strange behaviour with the Camera API when used on Sony-Ericsson X10 or Droid?

For example the following code doesn't work on those devices. As a result I'm getting a lot of negative feedback on the Market translating into many cancelled orders...

mParameters.set("rotation", orientation);
mParameters.set("jpeg-quality", img_quality);
mParameters.set("picture-size", "1024x768");
mCamera.setParameters(mParameters);

Could you suggest an alternative way of achieving the same? Thanks.

+2  A: 

You can't just set random values in the camera parameters because you don't know if the hardware is going to support that, so you need to ask first!

mCamera = Camera.open();
Camera.Parameters params = mCamera.getParameters();
List<Size> sizes = params.getSupportedPictureSizes();
// See which sizes the camera supports and choose one of those
mSize = sizes.get(0);
params.setPictureSize(mSize.width, mSize.height);
mCamera.setParameters(params);
CaseyB
Ok, this explains why "picture-size" didn't work, though the rejected size I've used was fairly standard "1024x768"... Do you have any ideas about "rotation"?! This is even more important to me as if that doesn't work the image is randomly rotated 90 or -90 degrees. Thanks!
mobilekid
Your solution works only on Android 2.0 and later framework revisions. Any ideas how to get the supported picture sizes on 1.5 and 1.6?
mobilekid
It looks like the orientation problem is a known issue on G1's. This thread has a work around.http://groups.google.com/group/android-developers/browse_thread/thread/fec92fc79b38c698/b61f3669ec2a4fcf?show_docid=b61f3669ec2a4fcfAs for getting the supported picture sizes on 1.6 and below it's not supported so the best advice it just to leave it alone.
CaseyB