Skip to content

Comments

Android: added possibility to select scale type of camera preview (fixes #250)#280

Open
zoka-cz wants to merge 4 commits intoRedth:mainfrom
zoka-cz:main
Open

Android: added possibility to select scale type of camera preview (fixes #250)#280
zoka-cz wants to merge 4 commits intoRedth:mainfrom
zoka-cz:main

Conversation

@zoka-cz
Copy link

@zoka-cz zoka-cz commented Nov 9, 2025

In this PR I have added new parametr PreviewScaleType into the CameraBarcodeReaderView and CameraView which allow user to schange the scaling of the preview. The problem was described in #250 and this should be the solution to this problem.
I have also adapted the example, so you may check the results in app. At the moment I have not possibility to check the behaviour on the iPhone (but I do not expect, that on iPhone it will overflow). On windows user do not experience overflow of preview. It seems to be problem only on Android.
Feel free to adapt the code as needed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new PreviewScaleType property to control camera preview scaling, addressing overflow issues on Android (#250). The implementation allows users to choose between Fill and Fit scaling modes with different alignments (Start/Center/End), with FillCenter as the default behavior.

Key Changes

  • Introduced PreviewScaleType enum with 6 scale type options (FillCenter, FillStart, FillEnd, FitCenter, FitStart, FitEnd)
  • Implemented the property in ICameraView, CameraView, and CameraBarcodeReaderView with appropriate handler mappings
  • Updated example app with a UI control to test different scale types

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ZXing.Net.MAUI/PreviewScaleType.cs New enum defining 6 camera preview scale type options
ZXing.Net.MAUI/Platforms/Android/CameraManager.android.cs Maps enum values to Android PreviewView.ScaleType and applies scaling in UpdateCamera()
ZXing.Net.MAUI/ICameraView.cs Adds PreviewScaleType property to the camera view interface
ZXing.Net.MAUI/CameraManager.cs Adds PreviewScaleType property and UpdatePreviewScaleType method to manage scale type updates
ZXing.Net.MAUI/CameraBarcodeReaderViewHandler.cs Registers property mapper to connect view property changes to camera manager updates
ZXing.Net.MAUI.Controls/Controls/CameraView.cs Implements PreviewScaleType as a bindable property with FillCenter default
ZXing.Net.MAUI.Controls/Controls/CameraBarcodeReaderView.cs Implements PreviewScaleType as a bindable property with FillCenter default
BigIslandBarcode/MainPage.xaml.cs Adds SelectScaleType_Clicked handler to allow runtime scale type selection
BigIslandBarcode/MainPage.xaml Updates layout to show camera in middle row and adds scale type selection button

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jfversluis
Copy link
Collaborator

Yeah I guess what I don't like about this approach is that it adds a property for all platforms but it only actually does something for Android.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants