From 1b9790147545629a3d460cf76853371abda8c0f1 Mon Sep 17 00:00:00 2001 From: Isaac Weisberg Date: Sat, 23 May 2026 20:19:53 +0200 Subject: [PATCH 1/2] Always load images asynchronously --- FirstFloor.ModernUI/Windows/Controls/BetterImage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FirstFloor.ModernUI/Windows/Controls/BetterImage.cs b/FirstFloor.ModernUI/Windows/Controls/BetterImage.cs index 58b8b9862..b80491926 100644 --- a/FirstFloor.ModernUI/Windows/Controls/BetterImage.cs +++ b/FirstFloor.ModernUI/Windows/Controls/BetterImage.cs @@ -77,7 +77,7 @@ public partial class BetterImage : Control { /// If image’s size is smaller than this, it will be decoded in the UI thread. /// Doesn’t do anything if OptionDecodeImageSync is true. /// - public static int OptionDecodeImageSyncThreshold = 50 * 1000; // 50 KB + public static int OptionDecodeImageSyncThreshold = 0; // 0 KB // public static int OptionDecodeImageSyncThreshold = 50; // 50 KB From cabe039d90c8184e157d183bd1bcb95bc949bfaa Mon Sep 17 00:00:00 2001 From: Isaac Weisberg Date: Sat, 23 May 2026 21:00:37 +0200 Subject: [PATCH 2/2] Disable color profile conversion in BetterImage --- FirstFloor.ModernUI/Windows/Controls/BetterImage.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FirstFloor.ModernUI/Windows/Controls/BetterImage.cs b/FirstFloor.ModernUI/Windows/Controls/BetterImage.cs index b80491926..7d845c499 100644 --- a/FirstFloor.ModernUI/Windows/Controls/BetterImage.cs +++ b/FirstFloor.ModernUI/Windows/Controls/BetterImage.cs @@ -77,7 +77,7 @@ public partial class BetterImage : Control { /// If image’s size is smaller than this, it will be decoded in the UI thread. /// Doesn’t do anything if OptionDecodeImageSync is true. /// - public static int OptionDecodeImageSyncThreshold = 0; // 0 KB + public static int OptionDecodeImageSyncThreshold = 50 * 1000; // 50 KB // public static int OptionDecodeImageSyncThreshold = 50; // 50 KB @@ -768,7 +768,7 @@ public static Image LoadBitmapSourceFromMemoryStream([NotNull] MemoryStream data downsized = true; } - bi.CreateOptions = BitmapCreateOptions.None; + bi.CreateOptions = BitmapCreateOptions.IgnoreColorProfile; bi.CacheOption = BitmapCacheOption.OnLoad; bi.StreamSource = stream; bi.EndInit(); @@ -1336,13 +1336,13 @@ private static unsafe bool FindTransparentCropArea(string tag, BitmapSource b, o } int w = b.PixelWidth, h = b.PixelHeight, s = (w * b.Format.BitsPerPixel + 7) / 8; - if (w > 800 || h > 450) { + var data = _transparentCropData.Value; + if ((long)s * h > data.Length) { Logging.Warning($"Image is too large to crop: {w}×{h}, tag: {tag}"); left = top = right = bottom = 0; return true; } - var data = _transparentCropData.Value; b.CopyPixels(data, s, 0); var k = b.Format.Masks.ElementAtOrDefault(0).Mask;