protected override unsafe void ProcessFilter( UnmanagedImage image, Rectangle rect )
{
int pixelSize = ( image.PixelFormat == PixelFormat.Format8bppIndexed ) ? 1 : 3;
// processing start and stop X,Y positions
int startX = rect.Left * pixelSize;
int startY = rect.Top;
int stopX = startX + rect.Width * pixelSize;
int stopY = startY + rect.Height;
int offset = image.Stride - rect.Width * pixelSize;
// do the job
byte* ptr = (byte*) image.ImageData.ToPointer( );
// allign pointer to the first pixel to process
ptr += ( startY * image.Stride + startX );
// gamma correction
for ( int y = startY; y < stopY; y++ )
{
for ( int x = startX; x < stopX; x++, ptr++ )
{
// process each pixel
*ptr = table[*ptr];
}
ptr += offset;
}
}
}