diff --git a/src/Controls/tests/TestCases.Android.Tests/snapshots/android/DownSizeImageAppearProperly.png b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/DownSizeImageAppearProperly.png new file mode 100644 index 000000000000..137c2c8266de Binary files /dev/null and b/src/Controls/tests/TestCases.Android.Tests/snapshots/android/DownSizeImageAppearProperly.png differ diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue30350.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue30350.xaml new file mode 100644 index 000000000000..364ed042ca83 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue30350.xaml @@ -0,0 +1,62 @@ + + + + + + + \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue30350.xaml.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue30350.xaml.cs new file mode 100644 index 000000000000..0b0f68add01a --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue30350.xaml.cs @@ -0,0 +1,142 @@ +using System; +using System.ComponentModel; +using System.IO; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Microsoft.Maui.Graphics; +using Microsoft.Maui.Graphics.Platform; +using IImage = Microsoft.Maui.Graphics.IImage; + +namespace Maui.Controls.Sample.Issues +{ + [Issue(IssueTracker.Github, 30350, "IImage downsize broken starting from 9.0.80 and not fixed in 9.0.81", PlatformAffected.iOS)] + public partial class Issue30350 : TestContentPage + { + private ImageSource _originalSource; + private string _originalSize; + private ImageSource _downsizedSource; + private string _downsizedImageSize; + + public Issue30350() + { + InitializeComponent(); + BindingContext = this; + } + + protected override void Init() + { + // Delay loading to ensure all controls are initialized + Dispatcher.Dispatch(async () => await LoadImagesAsync()); + } + + public ImageSource OriginalSource + { + get => _originalSource; + set + { + if (Equals(value, _originalSource)) + return; + _originalSource = value; + OnPropertyChanged(); + } + } + + public ImageSource DownsizedSource + { + get => _downsizedSource; + set + { + if (Equals(value, _downsizedSource)) + return; + _downsizedSource = value; + OnPropertyChanged(); + } + } + + public string OriginalSize + { + get => _originalSize; + set + { + if (value == _originalSize) + return; + _originalSize = value; + OnPropertyChanged(); + } + } + + public string DownsizedImageSize + { + get => _downsizedImageSize; + set + { + if (value == _downsizedImageSize) + return; + _downsizedImageSize = value; + OnPropertyChanged(); + } + } + + private async Task LoadImagesAsync() + { + try + { + // Check if StatusLabel is available + if (StatusLabel != null) + StatusLabel.Text = "Loading images..."; + + // Load original image from embedded resource + OriginalSource = ImageSource.FromResource("Controls.TestCases.HostApp.Resources.Images.royals.png"); + + // Load IImage for processing + var assembly = GetType().GetTypeInfo().Assembly; + using var stream = assembly.GetManifestResourceStream("Controls.TestCases.HostApp.Resources.Images.royals.png"); + + if (stream == null) + { + if (StatusLabel != null) + StatusLabel.Text = "Error: Could not load royals.png resource"; + return; + } + + var originalImage = PlatformImage.FromStream(stream); + if (originalImage == null) + { + if (StatusLabel != null) + StatusLabel.Text = "Error: Could not create IImage from stream"; + return; + } + + OriginalSize = $"{originalImage.Width}x{originalImage.Height}"; + + // Perform downsize operation - this is where the issue occurs in MAUI 9.0.80+ + // The downsized image should be flipped/rotated incorrectly on iOS 9.0.80+ + var downsizedImage = originalImage.Downsize(100); + if (downsizedImage == null) + { + if (StatusLabel != null) + StatusLabel.Text = "Error: Downsize operation failed"; + return; + } + + DownsizedImageSize = $"{downsizedImage.Width}x{downsizedImage.Height}"; + + // Convert downsized IImage to ImageSource + using var downsizedStream = new MemoryStream(); + await downsizedImage.SaveAsync(downsizedStream, ImageFormat.Png); + downsizedStream.Position = 0; + + DownsizedSource = ImageSource.FromStream(() => new MemoryStream(downsizedStream.ToArray())); + + if (StatusLabel != null) + StatusLabel.Text = "Images loaded. Compare for flipping/rotation issues in MAUI 9.0.80+"; + } + catch (Exception ex) + { + if (StatusLabel != null) + StatusLabel.Text = $"Error loading images: {ex.Message}"; + } + } + } +} \ No newline at end of file diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue30426.xaml b/src/Controls/tests/TestCases.HostApp/Issues/Issue30426.xaml new file mode 100644 index 000000000000..c796c306d141 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue30426.xaml @@ -0,0 +1,80 @@ + + + + +