I have built a custom Camera App and I am trying to change the resoloution of the image that is took. I have read around that this could depend on the phone or version of Android?
I know they are set using the setParameters
but just dont know how to set the actuall resoloution to work on all phones. I am wanting it to be kind of small as my app force closes otherwise. When I use a test picture at 640x348 this works so around that size/resoloution would be perfect.
It may be easier to use setPictureSize
?
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
camera = Camera.open();
try {
Camera.Parameters parameters = camera.getParameters();
if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
parameters.set("orientation", "portrait");
camera.setDisplayOrientation(90);
// Uncomment for Android 2.0 and above
parameters.setRotation(90);
} else {
parameters.set("orientation", "landscape");
camera.setDisplayOrientation(0);
// Uncomment for Android 2.0 and above
parameters.setRotation(0);
}
camera.setParameters(parameters);
camera.setPreviewDisplay(holder);
} catch (IOException exception) {
camera.release();
}
camera.startPreview();
}
Step one: When you find your image, don't open it. Instead, right click on the photo and select “Properties.” Step two: Once you're in “Properties,” click on the “Details” tab. Step three: Scroll until you see the resolution or dpi of your picture.
There is no setResolution()
, only setPictureSize()
. Use getSupportedPictureSizes()
on Camera.Parameters
to find the size you want, or use that information to populate a ListView
or Spinner
or something for the user to choose the desired size. Here is a sample project recently updated to use getSupportedPictureSizes()
to find the smallest supported resolution and use that.
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