Tag: bitmapdata

PixelFormat.Format32bppArgb似乎有错误的字节顺序

我尝试从Bitmap(System.Drawing.Bitmap)获取所有字节值。 因此我锁定字节并复制它们: public static byte[] GetPixels(Bitmap bitmap){ if(bitmap-PixelFormat.Equals(PixelFormat.Format32.bppArgb)){ var argbData = new byte[bitmap.Width*bitmap.Height*4]; var bd = bitmap.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadOnly, bitmap.PixelFormat); System.Runtime.InteropServices.Marshal.Copy(bd.Scan0, argbData, 0, bitmap.Width * bitmap.Height * 4); bitmap.UnlockBits(bd); } } 我用一个非常简单的2×2 PNG图像测试了这个图像,这个图像是我在Photoshop中创建的像素(红色,绿色,蓝色,白色)。 由于格式,我期望argbData中的以下值: 255 255 0 0 255 0 255 0 255 0 0 255 255 255 255 255 但我得到了: 0 […]