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);
}
getSupportedPictureSizes()returns aListofCamera.Sizeobjects.Camera.Sizehasheightandwidthdata 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 theSurfaceView‘s size.