limit the max picture size to 8 megapixels

This commit is contained in:
tibbi 2016-06-16 11:53:18 +02:00
parent 2b2fdf64cc
commit aaf87d49dc
1 changed files with 15 additions and 2 deletions

View File

@ -165,8 +165,8 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
}
final Camera.Size maxPictureSize = parameters.getSupportedPictureSizes().get(0);
parameters.setPictureSize(maxPictureSize.width, maxPictureSize.height);
final Camera.Size maxSize = getPictureSize();
parameters.setPictureSize(maxSize.width, maxSize.height);
MediaPlayer.create(getContext(), R.raw.camera_shutter).start();
camera.setParameters(parameters);
@ -199,6 +199,19 @@ public class Preview extends ViewGroup implements SurfaceHolder.Callback, View.O
}
};
// limit the max picture size at 8 megapixels
private Camera.Size getPictureSize() {
List<Camera.Size> sizes = parameters.getSupportedPictureSizes();
Camera.Size maxSize = sizes.get(0);
for (Camera.Size size : sizes) {
if (size.width * size.height < 9000000) {
maxSize = size;
break;
}
}
return maxSize;
}
private void focusArea() {
if (camera == null)
return;