// 性能最高,其数组和像素一一对应
public static byte[] GetImgByte(this Bitmap bmp)
{
BitmapData bitmapData = bmp.LockBits(new System.Drawing.Rectangle(new Point(0, 0), bmp.Size),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
byte[] res = new byte[bitmapData.Stride * bitmapData.Height];
IntPtr Ptr = bitmapData.Scan0;
System.Runtime.InteropServices.Marshal.Copy(Ptr, res, 0, res.Length);
bmp.UnlockBits(bitmapData);
return res;
}