diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java index 5ea130290..714ea0638 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java @@ -329,6 +329,14 @@ protected List getPreviewStreamAvailableSizes() { Size add = new Size(size.getWidth(), size.getHeight()); if (!candidates.contains(add)) candidates.add(add); } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + sizes = streamMap.getHighResolutionOutputSizes(ImageFormat.YUV_420_888); + if (sizes != null) + for (android.util.Size size : sizes) { + Size add = new Size(size.getWidth(), size.getHeight()); + if (!candidates.contains(add)) candidates.add(add); + } + } return candidates; } catch (CameraAccessException e) { throw createCameraException(e); @@ -352,6 +360,14 @@ protected List getFrameProcessingAvailableSizes() { Size add = new Size(size.getWidth(), size.getHeight()); if (!candidates.contains(add)) candidates.add(add); } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + sizes = streamMap.getHighResolutionOutputSizes(mFrameProcessingFormat); + if (sizes != null) + for (android.util.Size size : sizes) { + Size add = new Size(size.getWidth(), size.getHeight()); + if (!candidates.contains(add)) candidates.add(add); + } + } return candidates; } catch (CameraAccessException e) { throw createCameraException(e); diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/options/Camera2Options.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/options/Camera2Options.java index 43c998768..69b2ebf4a 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/options/Camera2Options.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/options/Camera2Options.java @@ -133,6 +133,16 @@ public Camera2Options(@NonNull CameraManager manager, supportedPictureSizes.add(new Size(width, height)); supportedPictureAspectRatio.add(AspectRatio.of(width, height)); } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + psizes = streamMap.getHighResolutionOutputSizes(pictureFormat); + if (psizes != null) + for (android.util.Size size : psizes) { + int width = flipSizes ? size.getHeight() : size.getWidth(); + int height = flipSizes ? size.getWidth() : size.getHeight(); + supportedPictureSizes.add(new Size(width, height)); + supportedPictureAspectRatio.add(AspectRatio.of(width, height)); + } + } // Video Sizes // As a safety measure, remove Sizes bigger than CamcorderProfile.highest