Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Camera.setParameters(Camera.Parameters) does not work on Sony-Ericsson X10 and Droid?

Tags:

android

camera

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.

like image 429
mobilekid Avatar asked May 01 '10 20:05

mobilekid


1 Answers

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);
like image 113
CaseyB Avatar answered Nov 14 '22 21:11

CaseyB