public static void FromBitmap(this PixelData pixelData, Bitmap bm) { // Retrieve data BitmapData data = bm.LockBits( new Rectangle(0, 0, bm.Width, bm.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); int pixels = data.Width * data.Height; int[] argbValues = new int[pixels]; Marshal.Copy(data.Scan0, argbValues, 0, pixels); bm.UnlockBits(data); pixelData.SetPixelDataArgb(argbValues, bm.Width, bm.Height); pixelData.ColorTransparentPixels(); }