public static Framebuffer FromPixelFormat(byte[] b, int width, int height)
{
if (b.Length != 16)
throw new ArgumentException("Length of b must be 16 bytes.");
Framebuffer buffer = new Framebuffer(width, height);
buffer.BitsPerPixel = (int) b[0];
buffer.Depth = (int) b[1];
buffer.BigEndian = (b[2] != 0);
buffer.TrueColour = (b[3] != 0);
buffer.RedMax = (int) (b[5] | b[4] << 8);
buffer.GreenMax = (int) (b[7] | b[6] << 8);
buffer.BlueMax = (int) (b[9] | b[8] << 8);
buffer.RedShift = (int) b[10];
buffer.GreenShift = (int) b[11];
buffer.BlueShift = (int) b[12];
// Last 3 bytes are padding, ignore
return buffer;
}
}