public static unsafe Image GetImageByByte(byte[,] bytes2 )
{
Bitmap bitmap = new Bitmap(bytes2.GetLength (0), bytes2.GetLength (1));
int w = bitmap.Width;
int h = bitmap.Height;
Rectangle rectangle = new Rectangle(0, 0, w, h);
// 将图片位图区域进行锁定
BitmapData mapdata = bitmap.LockBits(rectangle, ImageLockMode.WriteOnly , PixelFormat.Format24bppRgb);
byte* pixpoint = (byte*)mapdata.Scan0 + 1;
int iStride = mapdata.Stride;
byte* index;
for (int i = 0; i < w; i++)
{
index = pixpoint + i * 3;
for (int j = 0; j < h; j++)
{
*(index + j * iStride) = bytes2[i, j];
}
}
// 将位图内存区域进行解锁
bitmap.UnlockBits(mapdata);
return bitmap;
}