I want to create a bitmap from given 16 bit greyscale values. So far I have this code:
var value = CamData.ToArray();
var b = new Bitmap(160, 112, PixelFormat.Format24bppRgb);
var bdata = b.LockBits(new Rectangle(0, 0, 160, 112), ImageLockMode.WriteOnly, b.PixelFormat);
unsafe
{
fixed (ushort* pData = &value[0])
{
Marshal.Copy((IntPtr)pData, new IntPtr[]{ bdata.Scan0}, 0, value.Length);
}
}
b.UnlockBits(bdata);
but I get an error in the Marshal.Copy Methode: "The requested range is beyond the end of the array". Where is the error?
thanks