private static Bitmap UncompressV8U8(byte[] imgData, int w, int h)
{
MemoryStream bitmapStream = new MemoryStream(w * h * 2);
BinaryWriter bitmapBW = new BinaryWriter(bitmapStream);
int ptr = 0;
for (int y = 0; y < h; y++)
{
for (int x = 0; x < w; x++)
{
sbyte red = (sbyte)Buffer.GetByte(imgData, ptr++);
sbyte green = (sbyte)Buffer.GetByte(imgData, ptr++);
byte blue = 0xFF;
int fCol = blue | (0x7F + green) << 8 | (0x7F + red) << 16 | 0xFF << 24;
bitmapBW.Write(fCol);
}
}
byte[] imageData = bitmapStream.ToArray();
var bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
{
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0,
bmp.Width,
bmp.Height),
ImageLockMode.WriteOnly,
bmp.PixelFormat);
Marshal.Copy(imageData, 0, bmpData.Scan0, imageData.Length);
bmp.UnlockBits(bmpData);
}
return bmp;
}
#endregion