Problem runing bitmap with Scan0 and System.IntPtr
hi guys, i got a problem hope somebody can help me:
i got b which is the bitmap (entire picture 640*480), but i just need to scan a little part from that bitmap, this dimension is 110*110, but the following code is not doing what i need! help me pls!
note:i dont want to cut the region 110*110 to scan.
BitmapData bmData = b.LockBits(new Rectangle(0, 0, 110, 110), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride; // bytes in a row 3*b.Width
System.IntPtr Scan0 = bmData.Scan0;
byte * p = (byte *)(void *)Scan0;
//int nOffset = stride - b.Width*3;
int nOffset = stride - 110*3;
for(int y=0;y < 110;++y)
{
for(int x=0; x < 110; ++x )
{
do something...
p += 3; --->why+3?
}
p += nOffset; --->what this line does?
}
b.UnlockBits(bmData);