这是绝对最快的我可以将位图复制到C#中的字节[]吗?
如果有一种更快的方式我很想知道!
const int WIDTH = /* width */; const int HEIGHT = /* height */; Bitmap bitmap = new Bitmap(WIDTH,HEIGHT,PixelFormat.Format32bppRgb); Byte[] bytes = new byte[WIDTH * HEIGHT * 4]; BitmapToByteArray(bitmap,bytes); private unsafe void BitmapToByteArray(Bitmap bitmap,Byte[] bytes) { BitmapData bitmapData = bitmap.LockBits(new Rectangle(0,WIDTH,HEIGHT),ImageLockMode.ReadOnly,PixelFormat.Format32bppRgb); fixed(byte* pBytes = &bytes[0]) { MoveMemory(pBytes,bitmapData.Scan0.ToPointer(),WIDTH * HEIGHT * 4); } bitmap.UnlockBits(bitmapData); } [DllImport("Kernel32.dll",EntryPoint = "RtlMoveMemory",SetLastError = false)] private static unsafe extern void MoveMemory(void* dest,void* src,int size);