Android: added possibility to select scale type of camera preview (fixes #250)#280
Open
zoka-cz wants to merge 4 commits intoRedth:mainfrom
Open
Android: added possibility to select scale type of camera preview (fixes #250)#280zoka-cz wants to merge 4 commits intoRedth:mainfrom
zoka-cz wants to merge 4 commits intoRedth:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
PreviewScaleTypeenum with 6 scale type options (FillCenter, FillStart, FillEnd, FitCenter, FitStart, FitEnd) - Implemented the property in
ICameraView,CameraView, andCameraBarcodeReaderViewwith 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>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this PR I have added new parametr
PreviewScaleTypeinto theCameraBarcodeReaderViewandCameraViewwhich 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.