Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android camera supported picture sizes

I am trying to retrieve the available camera image sizes, so I able to adjust the camera to my preferred image resolution.

To retrieve the Android camera size I've used the following code:

camera=Camera.open();
Parameters params = camera.getParameters();
List sizes = params.getSupportedPictureSizes();
for (int i=0;i<sizes.size();i++){
    Log.i("PictureSize", "Supported Size: " +sizes.get(i));         
}

This gives me the following output, which I am not sure how to translate into a size.

"Supported size: android.hardware.Camera$Size@65d4c50"
"Supported size: android.hardware.Camera$Size@65d4a70"
"Supported size: android.hardware.Camera$Size@3fe4e00"
"Supported size: android.hardware.Camera$Size@3fe4cd0"
"Supported size: android.hardware.Camera$Size@18f5600"
"Supported size: android.hardware.Camera$Size@13f7860"

If anyone could help me understand the output it would help me a lot, thanks!

Edit: I ended up solving my problem by doing the following:

camera=Camera.open();
Parameters params = camera.getParameters();
List sizes = params.getSupportedPictureSizes();
Camera.Size result = null;
    for (int i=0;i<sizes.size();i++){
        result = (Size) sizes.get(i);
        Log.i("PictureSize", "Supported Size. Width: " + result.width + "height : " + result.height); 
    }
like image 963
Lasse Samson Avatar asked Nov 03 '11 10:11

Lasse Samson


People also ask

How do I check image size on android?

On android go to photos, select your photo and click the ... in the top right. Scroll to bottom of page to find image size.


1 Answers

getSupportedPictureSizes() returns a List of Camera.Size objects. Camera.Size has height and width data members that tell you the height and width of the supported picture size.

Here is a sample project that uses the related getSupportedPreviewSizes() to find the preview size with the largest area that is smaller than the SurfaceView's size.

like image 107
CommonsWare Avatar answered Sep 17 '22 17:09

CommonsWare