Avoid checking pixels if it is not 32 bpp already

This commit is contained in:
Jaex 2017-06-19 19:50:28 +03:00
parent 94233bbe33
commit 2caec59a52

View file

@ -676,10 +676,15 @@ public static bool IsImagesEqual(Bitmap bmp1, Bitmap bmp2)
public static bool IsImageTransparent(Bitmap bmp)
{
using (UnsafeBitmap unsafeBitmap = new UnsafeBitmap(bmp, true, ImageLockMode.ReadOnly))
if (bmp != null && bmp.PixelFormat == PixelFormat.Format32bppArgb)
{
return unsafeBitmap.IsTransparent();
using (UnsafeBitmap unsafeBitmap = new UnsafeBitmap(bmp, true, ImageLockMode.ReadOnly))
{
return unsafeBitmap.IsTransparent();
}
}
return false;
}
public static bool AddMetadata(Image img, int id, string text)