I have an RGB color held in a Int32 variable.
I using an unsafe code to loop through Bitmap data, and by using the
BitmapData.Scan 0 pointer I need to copy the Int32 color value into the Bitmap
data.
But using the:
/////////////////////////////////////////////////////////////////////////////////////////
Bitmap img = new Bitmap(100, 200,
System.Drawing. Imaging.PixelFo rmat.Format32bp pRgb);
System.Drawing. Imaging.BitmapD ata refData = img.LockBits(ne w Rectangle(0, 0,
img.Width, img.Height), System.Drawing. Imaging.ImageLo ckMode.WriteOnl y,
img.PixelFormat );
int myColot = GetColor(); // The RGB color value in a Int32 variable.
unsafe
{
refBuf = (byte*)refData. Scan0.ToPointer ();
*refBuf = myColot; // This is the problematic code line !!!
}
/////////////////////////////////////////////////////////////////////////////////////////
How do I need to change the problematic code line above, to make it work?
--
Thanks
Sharon
I using an unsafe code to loop through Bitmap data, and by using the
BitmapData.Scan 0 pointer I need to copy the Int32 color value into the Bitmap
data.
But using the:
/////////////////////////////////////////////////////////////////////////////////////////
Bitmap img = new Bitmap(100, 200,
System.Drawing. Imaging.PixelFo rmat.Format32bp pRgb);
System.Drawing. Imaging.BitmapD ata refData = img.LockBits(ne w Rectangle(0, 0,
img.Width, img.Height), System.Drawing. Imaging.ImageLo ckMode.WriteOnl y,
img.PixelFormat );
int myColot = GetColor(); // The RGB color value in a Int32 variable.
unsafe
{
refBuf = (byte*)refData. Scan0.ToPointer ();
*refBuf = myColot; // This is the problematic code line !!!
}
/////////////////////////////////////////////////////////////////////////////////////////
How do I need to change the problematic code line above, to make it work?
--
Thanks
Sharon
Comment