diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintShouldBeDrawn.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintShouldBeDrawn.png index 970578dca041..ad8a168f7dd2 100644 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintShouldBeDrawn.png and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintShouldBeDrawn.png differ diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeBleed.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeBleed.png index 82ebdf50ca1e..1c4a2be8a62f 100644 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeBleed.png and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeBleed.png differ diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeFit.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeFit.png index c1a476da5ca1..256b8be6b7d3 100644 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeFit.png and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeFit.png differ diff --git a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeStretch.png b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeStretch.png index a6526342a1b7..d5365922f304 100644 Binary files a/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeStretch.png and b/src/Controls/tests/TestCases.Mac.Tests/snapshots/mac/ImagePaintWithResizeModeStretch.png differ diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue16767_Resize.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue16767_Resize.cs index 7f359ef6a2fa..c51d6a91aa0a 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue16767_Resize.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue16767_Resize.cs @@ -13,7 +13,6 @@ public Issue16767_Resize(TestDevice testDevice) : base(testDevice) public override string Issue => "Resize function in W2DImage class"; protected override bool ResetAfterEachTest => true; -#if TEST_FAILS_ON_IOS //Issue Link - https://github.com/dotnet/maui/issues/34755 [Test] [Category(UITestCategories.GraphicsView)] public void ImagePaintWithResizeModeFit() @@ -21,7 +20,6 @@ public void ImagePaintWithResizeModeFit() App.WaitForElement("ResizeModeFit"); VerifyScreenshot(); } -#endif [Test] [Category(UITestCategories.GraphicsView)] diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeBleed.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeBleed.png index 473a6937b856..d976f32b932d 100644 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeBleed.png and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeBleed.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeFit.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeFit.png new file mode 100644 index 000000000000..73ed5b912ab1 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeFit.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeStretch.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeStretch.png index 93ae570b4697..b31ec180349d 100644 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeStretch.png and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios-26/ImagePaintWithResizeModeStretch.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeBleed.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeBleed.png index eae95ed92d21..dabc4518e34c 100644 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeBleed.png and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeBleed.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeFit.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeFit.png new file mode 100644 index 000000000000..43dc1e7c7b01 Binary files /dev/null and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeFit.png differ diff --git a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeStretch.png b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeStretch.png index 4597de9ca0ad..14caa25d5571 100644 Binary files a/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeStretch.png and b/src/Controls/tests/TestCases.iOS.Tests/snapshots/ios/ImagePaintWithResizeModeStretch.png differ diff --git a/src/Graphics/src/Graphics/Platforms/MaciOS/PlatformCanvas.cs b/src/Graphics/src/Graphics/Platforms/MaciOS/PlatformCanvas.cs index 4905360b2171..d343df8fb20d 100644 --- a/src/Graphics/src/Graphics/Platforms/MaciOS/PlatformCanvas.cs +++ b/src/Graphics/src/Graphics/Platforms/MaciOS/PlatformCanvas.cs @@ -708,6 +708,10 @@ public override void FillRectangle(float x, float y, float width, float height) private void FillWithPattern(nfloat x, nfloat y, Action drawingAction) { _context.SaveState(); + + // Reset the pattern phase so the pattern starts at the correct origin. + _context.SetPatternPhase(CGSize.Empty); + var colorspace = CGColorSpace.CreatePattern(null); _context.SetFillColorSpace(colorspace); @@ -741,6 +745,12 @@ private void FillWithPattern(nfloat x, nfloat y, Action drawingAction) private void FillWithImage(nfloat x, nfloat y, Action drawingAction) { _context.SaveState(); + + // The view's PatternPhase is pre-set by PlatformGraphicsView, + // which shifts the image tile and causes it to split across the fill rect. + // Reset it here to the fill rect origin so the image starts at the right place. + _context.SetPatternPhase(CGSize.Empty); + var baseColorspace = _getColorspace?.Invoke(); var colorspace = CGColorSpace.CreatePattern(baseColorspace); _context.SetFillColorSpace(colorspace);