Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Camera setJpegQuality ignored

Tags:

It seems that the setJpegQuality method of Camera.Parameters is ignored, at least on the devices I've tried it with (Nexus S, Galaxy S2).

Does it work for anyone else, or is this a known issue, or am I doing something wrong, or... ?

Code for setting parameters below. jpeg quality 1 is very distinctive, so it's very easy to determine visually whether it's working... and it isn't! Other parameters set here (e.g. sepia) work.

    camera = Camera.open();
    final Camera.Parameters parameters = camera.getParameters();
    parameters.setJpegQuality(1);
    parameters.setPictureFormat(ImageFormat.JPEG);
    // Let's set a SEPIA effect, just to verify these parameters are working at all!
    parameters.setColorEffect(Camera.Parameters.EFFECT_SEPIA);
    // I've seen this syntax too on the internet, presumably it's legacy.
    parameters.set("jpeg-quality", 1);
    camera.setParameters(parameters);
like image 600
Darin Tay Avatar asked Jul 13 '12 23:07

Darin Tay


1 Answers

Set all attributes of the picture:

parameters.setPreviewSize(854, 480);  // (h, w)
   parameters.setPictureFormat(ImageFormat.JPEG);
   parameters.set("jpeg-quality", 100);
   parameters.set("orientation", "landscape");
   parameters.set("rotation", 90);
   mCamera.setParameters(parameters);
   mCamera.startPreview();
like image 94
Varun kumar Avatar answered Oct 22 '22 10:10

Varun kumar