BExplorer.Shell.Interop.ShellThumbnail.IsAlphaBitmap C# (CSharp) Method

IsAlphaBitmap() public static method

public static IsAlphaBitmap ( Bitmap bmp, BitmapData &bmpData ) : bool
bmp System.Drawing.Bitmap
bmpData System.Drawing.Imaging.BitmapData
return bool
        public static bool IsAlphaBitmap(Bitmap bmp, out BitmapData bmpData)
        {
            var bmBounds = new Rectangle(0, 0, bmp.Width, bmp.Height);
            bmpData = bmp.LockBits(bmBounds, ImageLockMode.ReadOnly, bmp.PixelFormat);

            try
            {
                byte[] bytes = new byte[bmpData.Height * bmpData.Stride];
                Marshal.Copy(bmpData.Scan0, bytes, 0, bytes.Length);
                for (var p = 3; p < bytes.Length; p += 4) {
                    if (bytes[p] != 255) return true;
                }
            }
            finally
            {
                bmp.UnlockBits(bmpData);
            }

            return false;
        }