我需要从 Image 获取原始数据,我正在使用 Bitmap LockBits
图像为 24BppRgb 但创建位图后,位图格式为 32BppArgb
知道为什么会这样
System.Drawing.Bitmap bmp = new Bitmap(image);
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, image.PixelFormat);
IntPtr ptr = bmpData.Scan0;
int bytes = Math.Abs(bmpData.Stride) * bmp.Height;
byte[] rgbValues = new byte[bytes];
Marshal.Copy(ptr, rgbValues, 0, bytes);
bmp.UnlockBits(bmpData);
bmp.Dispose();