diff --git a/docs/docs/guides/PREVIEW.mdx b/docs/docs/guides/PREVIEW.mdx index eafad79bad..1ce2a5415f 100644 --- a/docs/docs/guides/PREVIEW.mdx +++ b/docs/docs/guides/PREVIEW.mdx @@ -62,7 +62,16 @@ const lowResolutionFormat = useCameraFormat(device, [ ]) ``` -On Android, the Preview will always be in full HD, or the Preview View's size, whichever is smaller. +On Android, the Preview will always be in full HD or the Preview View's size, whichever is smaller. +If a format is specified, the preview will try to match the `video`'s resolution and aspect ratio if `video` is enabled, and `photo`'s resolution and aspect ratio if `photo` is enabled. + +```tsx + +``` ### Overlays and Masks @@ -77,4 +86,4 @@ On Android, the Preview View supports two implementation modes which are control
-#### 🚀 Next section: [Taking Photos](./taking-photos) +#### 🚀 Next section: [Taking Photos](./taking-photos) \ No newline at end of file diff --git a/package/android/src/main/java/com/mrousavy/camera/core/CameraSession+Configuration.kt b/package/android/src/main/java/com/mrousavy/camera/core/CameraSession+Configuration.kt index 7c5cf05ae2..1e9c0def64 100644 --- a/package/android/src/main/java/com/mrousavy/camera/core/CameraSession+Configuration.kt +++ b/package/android/src/main/java/com/mrousavy/camera/core/CameraSession+Configuration.kt @@ -75,9 +75,11 @@ internal fun CameraSession.configureOutputs(configuration: CameraConfiguration) } if (format != null) { - // Similar to iOS, Preview will follow video size as it's size (and aspect ratio) + // Preview will follow video size as it's size & aspect ratio, or photo- if video is disabled. + val targetSize = if (videoConfig != null) format.videoSize else format.photoSize + val previewResolutionSelector = ResolutionSelector.Builder() - .forSize(format.videoSize) + .forSize(targetSize) .setAllowedResolutionMode(ResolutionSelector.PREFER_CAPTURE_RATE_OVER_HIGHER_RESOLUTION) .build() preview.setResolutionSelector(previewResolutionSelector)