-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[Windows] Fixed Image clipping not working #30684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jfversluis
merged 3 commits into
dotnet:inflight/current
from
SubhikshaSf4851:fix-30440
Aug 25, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+101 KB
...estCases.Android.Tests/snapshots/android/Issue30440ImageShouldClipCorrectly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 142 additions & 0 deletions
142
src/Controls/tests/TestCases.HostApp/Issues/Issue30440.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| using Microsoft.Maui.Controls.Shapes; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 30440, "Image clipping not working", PlatformAffected.UWP)] | ||
|
|
||
| public class Issue30440 : ContentPage | ||
| { | ||
| public Issue30440() | ||
| { | ||
| var mainLayout = new VerticalStackLayout(); | ||
|
|
||
| var headerLabel = new Label | ||
| { | ||
| Text = "Test passes if images are clipped with different geometries", | ||
| AutomationId = "headerLabel", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| FontSize = 16, | ||
| Margin = new Thickness(10) | ||
| }; | ||
|
|
||
| // Grid with 3 columns for different clipping examples | ||
| var grid = new Grid | ||
| { | ||
| ColumnDefinitions = new ColumnDefinitionCollection | ||
| { | ||
| new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, | ||
| new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, | ||
| new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) } | ||
| }, | ||
| RowDefinitions = new RowDefinitionCollection | ||
| { | ||
| new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, | ||
| new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } | ||
| }, | ||
| Margin = new Thickness(10) | ||
| }; | ||
|
|
||
| // Labels for each column | ||
| var circleLabel = new Label | ||
| { | ||
| Text = "Circle Clip", | ||
| AutomationId = "circleLabel", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| FontSize = 14, | ||
| FontAttributes = FontAttributes.Bold | ||
| }; | ||
| Grid.SetColumn(circleLabel, 0); | ||
| Grid.SetRow(circleLabel, 0); | ||
|
|
||
| var rectangleLabel = new Label | ||
| { | ||
| Text = "Rectangle Clip", | ||
| AutomationId = "rectangleLabel", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| FontSize = 14, | ||
| FontAttributes = FontAttributes.Bold | ||
| }; | ||
| Grid.SetColumn(rectangleLabel, 1); | ||
| Grid.SetRow(rectangleLabel, 0); | ||
|
|
||
| var roundedRectLabel = new Label | ||
| { | ||
| Text = "Rounded Rect Clip", | ||
| AutomationId = "roundedRectLabel", | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| FontSize = 14, | ||
| FontAttributes = FontAttributes.Bold | ||
| }; | ||
| Grid.SetColumn(roundedRectLabel, 2); | ||
| Grid.SetRow(roundedRectLabel, 0); | ||
|
|
||
| // Image with circle clipping (EllipseGeometry) | ||
| var circleImage = new Image | ||
| { | ||
| AutomationId = "circleImage", | ||
| Source = "royals.png", | ||
| Aspect = Aspect.AspectFill, | ||
| WidthRequest = 120, | ||
| HeightRequest = 120, | ||
| Clip = new EllipseGeometry | ||
| { | ||
| RadiusX = 60, | ||
| RadiusY = 60, | ||
| Center = new Point(60, 60) | ||
| }, | ||
| Margin = new Thickness(5) | ||
| }; | ||
| Grid.SetColumn(circleImage, 0); | ||
| Grid.SetRow(circleImage, 1); | ||
|
|
||
| // Image with rectangle clipping (RectangleGeometry) | ||
| var rectangleImage = new Image | ||
| { | ||
| AutomationId = "rectangleImage", | ||
| Source = "royals.png", | ||
| Aspect = Aspect.AspectFill, | ||
| WidthRequest = 120, | ||
| HeightRequest = 120, | ||
| Clip = new RectangleGeometry | ||
| { | ||
| Rect = new Rect(10, 10, 100, 100) | ||
| }, | ||
| Margin = new Thickness(5) | ||
| }; | ||
| Grid.SetColumn(rectangleImage, 1); | ||
| Grid.SetRow(rectangleImage, 1); | ||
|
|
||
| // Image with rounded rectangle clipping (RoundRectangleGeometry) | ||
| var roundedRectImage = new Image | ||
| { | ||
| AutomationId = "roundedRectImage", | ||
| Source = "royals.png", | ||
| Aspect = Aspect.AspectFill, | ||
| WidthRequest = 120, | ||
| HeightRequest = 120, | ||
| Clip = new RoundRectangleGeometry | ||
| { | ||
| Rect = new Rect(0, 0, 120, 120), | ||
| CornerRadius = new CornerRadius(20) | ||
| }, | ||
| Margin = new Thickness(5) | ||
| }; | ||
| Grid.SetColumn(roundedRectImage, 2); | ||
| Grid.SetRow(roundedRectImage, 1); | ||
|
|
||
| // Add all elements to grid | ||
| grid.Children.Add(circleLabel); | ||
| grid.Children.Add(rectangleLabel); | ||
| grid.Children.Add(roundedRectLabel); | ||
| grid.Children.Add(circleImage); | ||
| grid.Children.Add(rectangleImage); | ||
| grid.Children.Add(roundedRectImage); | ||
|
|
||
| // Add elements to main layout | ||
| mainLayout.Children.Add(headerLabel); | ||
| mainLayout.Children.Add(grid); | ||
|
|
||
| Content = mainLayout; | ||
| } | ||
| } |
Binary file added
BIN
+43.7 KB
.../tests/TestCases.Mac.Tests/snapshots/mac/Issue30440ImageShouldClipCorrectly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions
22
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue30440.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
| public class Issue30440 : _IssuesUITest | ||
| { | ||
| public Issue30440(TestDevice device) | ||
| : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "Image clipping not working"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Image)] | ||
| public void Issue30440ImageShouldClipCorrectly() | ||
| { | ||
| App.WaitForElement("circleLabel"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } |
Binary file added
BIN
+24.6 KB
.../TestCases.WinUI.Tests/snapshots/windows/Issue30440ImageShouldClipCorrectly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+117 KB
.../tests/TestCases.iOS.Tests/snapshots/ios/Issue30440ImageShouldClipCorrectly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.