Bruno Almeida
Bruno Almeida

Reputation: 166

How to get the biggest suported picture size in device?

I want to take a photo using SurfaceView and PictureCallBack with the highest resolution supported.

Here is the configuration that works for my Galaxy Nexus:

    Camera.Parameters params = camera.getParameters();
    List<Camera.Size> sizes = params.getSupportedPictureSizes();
    Toast.makeText(MainActivity.this,"Supported Sizes: " + sizes,Toast.LENGTH_LONG).show();

    params.setPictureSize(2592, 1944);
    params.setJpegQuality(100);

    camera.setParameters(params);

The 2592 x 1944, is the best resolution for my device, but how I get from the var sizes the highest resolution for any devices?

Thank you for the help!

Upvotes: 3

Views: 2358

Answers (1)

the.Doc
the.Doc

Reputation: 886

Loop through your list, and multiply the height and width to get the pixel count and keep a variable of the largest index

int max = 0;
int index = 0;

for (int i = 0; i < List.size(); i++){
     Size s = List.get(i);
     int size = s.height * s.width;
     if (size > max) {
         index = i;
         max = size;
     }
}
params.setPictureSize(List.get(index).width, List.get(index).height);

Upvotes: 4

Related Questions