[quoted text, click to view] "keperry" <keith.b.perry@gmail.com> wrote in message
news:1161911563.744193.219890@f16g2000cwb.googlegroups.com...
>
> Dang...that's what I thought. I keep getting an error towards the end
> saying that I tried to write or read protected memory. So I thought
> maybe I was going out of bounds or something.
I usually do this slightly differently
BitmapData bmd=bm.LockBits(new Rectangle(0, 0, 10, 10),
System.Drawing.Imaging.ImageLockMode.ReadOnly, bm.PixelFormat);
int PixelSize=4;
byte* ptr = (byte*)bmd.Scan0;
int offset = bmd.stride - PixelSize * bmd.Width;
for(int y=0; y<bmd.Height; y++, ptr += offset)
{
for(int x=0; x<bmd.Width; x++, ptr += PixelSize)
{
ptr[RGB.A] = whatever;
ptr[RGB.R] = whatever;
ptr[RGB.G] = whatever;
ptr[RGB.B] = whatever;
}
}
where RGB.A, R, G and B are constants in a class called RGB.
public const int A = 3;
public const int R = 2;
public const int G = 1;
public const int B = 0;
[quoted text, click to view] >