Hello, I found this code in
Image Processing for Dummies with C# and GDI+ Part 1 - Per Pixel Filters[
^]
I found I can't understand code, here this code:
public static bool Invert(Bitmap b)
{
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
System.IntPtr Scan0 = bmData.Scan0;
unsafe
{
byte * p = (byte *)(void *)Scan0;
int nOffset = stride - b.Width*3;
int nWidth = b.Width * 3;
for(int y=0;y < b.Height;++y)
{
for(int x=0; x < nWidth; ++x )
{
p[0] = (byte)(255-p[0]);
++p;
}
p += nOffset;
}
}
b.UnlockBits(bmData);
return true;
}
Here I want to get by pixel(x,y) position simultaneously for exp:
result= pixel(0,0)+pixel(1,0)+pixel(2,0)+pixel(0,1)+pixel(1,1)+ pixel(2,1)+pixel(0,2)+pixel(1,2)+ pixel(2,2)result=result/9;
How to do it?
and than I don't understand with "p += nOffset;", I try disable it and still running. please explain to me?
thanks :D