[iOS, Mac] Fix for image is being flipped after downsizing#30380
[iOS, Mac] Fix for image is being flipped after downsizing#30380SyedAbdulAzeemSF4852 wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes inconsistent scaling and upside-down rendering when downsizing UIImage on iOS and Mac by explicitly setting the renderer’s scale and correcting the Core Graphics coordinate system, and adds UI tests to validate the fix.
- Explicitly set
UIGraphicsImageRendererFormat.Scaletotarget.CurrentScaleto preserve pixel density. - Adjust Core Graphics transforms to align the origin with UIKit’s top-left.
- Added shared and host-app UI tests to verify that a downsized image renders right-side up.
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Graphics/src/Graphics/Platforms/iOS/UIImageExtensions.cs | Added renderer format with explicit scale and CTM adjustments for flipping |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30350.cs | Introduced a shared UI test to verify the downsized image isn’t flipped |
| src/Controls/tests/TestCases.HostApp/Issues/Issue30350.cs | Added host app sample page and label/Image setup for the issue |
Comments suppressed due to low confidence (2)
src/Controls/tests/TestCases.HostApp/Issues/Issue30350.cs:40
- Avoid using async void for InitAsync; consider returning a Task and invoking it in OnAppearing or an async lifecycle method so you can await it and catch exceptions.
private async void InitAsync()
src/Controls/tests/TestCases.HostApp/Issues/Issue30350.cs:29
- You assign downsizedSizeLabel and downsizedSource after setting Content, but neither the Label nor Image will update automatically. Use data binding or update the UI elements on the main thread after loading completes.
new Label
|
Is there any prerelease build available for this PR? I'd like to check on my app how it behaves.. |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| { | ||
| downsizedImage = new Image | ||
| { | ||
| Aspect = Aspect.AspectFit |
There was a problem hiding this comment.
I think this is a bug in iOS: #30465 (comment)
So maybe use Center and then re-enable for all platforms.
There was a problem hiding this comment.
@mattleibow , Based on the suggestion, I replaced AspectFit with AspectCenter. However, the behavior is still inconsistent across platforms. For your reference, I’ve attached the relevant screenshots below.
| Android | Windows | Mac | iOS |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
| @@ -0,0 +1,24 @@ | |||
| #if TEST_FAILS_ON_ANDROID && TEST_FAILS_ON_WINDOWS // Issue Link - https://github.com/dotnet/maui/issues/30465 | |||
There was a problem hiding this comment.
This is a bug in iOS I think: #30465 (comment). We should use center and just try running everywhere again.
There was a problem hiding this comment.
@mattleibow , As suggested, I’ve used Aspect.Center and shared my analysis in this comment.
|
@SyedAbdulAzeemSF4852 COuld you rebase and fix the conflict? |
@jsuarezruiz , Since the revert PR #30421 has been merged and the issue no longer reproduces with that fix, my changes are no longer necessary. Therefore, I’m closing this PR. |




Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Issue Details
Root Cause
Scaling Issue :
Flipping Issue :
Description of Change
Scaling Issue :
Flipping Issue:
Issues Fixed
Fixes #30350
Validated the behaviour in the following platforms
Output