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);
}
On android go to photos, select your photo and click the ... in the top right. Scroll to bottom of page to find image size.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With