ソースを参照

Fixed transparency issues with already transparent images.

Kenric Nugteren 1 年間 前
コミット
2cea526c81
1 ファイル変更7 行追加1 行削除
  1. 7 1
      inabox.wpf/ImageUtils.cs

+ 7 - 1
inabox.wpf/ImageUtils.cs

@@ -269,7 +269,13 @@ namespace InABox.WPF
         public static BitmapImage AsBitmapImage(this Bitmap src, bool transparent = true)
         public static BitmapImage AsBitmapImage(this Bitmap src, bool transparent = true)
         {
         {
             if (transparent)
             if (transparent)
-                src.MakeTransparent(src.GetPixel(0, 0));
+            {
+                var pixel = src.GetPixel(0, 0);
+                if(pixel.A == byte.MaxValue)
+                {
+                    src.MakeTransparent(pixel);
+                }
+            }
 
 
             var bitmapImage = new BitmapImage();
             var bitmapImage = new BitmapImage();
             using (var memory = new MemoryStream())
             using (var memory = new MemoryStream())