public static Bitmap ViewG8(byte[] imgData, int w, int h)
{
if (imgData.Length != (w * h))
throw new ArgumentException("Input array is not correct size");
byte[] buff = new byte[w * h * 3];
for (int i = 0; i < (w * h); i++)
{
for (int j = 0; j < 3; j++)
buff[(3 * i) + j] = imgData[i];
}
var bmp = new Bitmap(w, h, PixelFormat.Format24bppRgb);
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, bmp.PixelFormat);
Marshal.Copy(buff, 0, bmpData.Scan0, buff.Length);
bmp.UnlockBits(bmpData);
return bmp;
}
#endregion