Hi All,
I am trying to implement a Photoshop style color filtering feature in my application. I have a Bitmap, and 4 check-boxes (R,G,B,A). I wanted to know what is the fastest way of doing it
Currently I am doing it as follows
Byte[] rgbValues = new Byte[data.Stride * data.Height];
for (int row = 0; row < data.Height; row++)
{
// Loop through each pixel on this scan line
int bufPos = (m_height - row - 1) * m_width;
int index = row * data.Stride;
for (int col = 0; col < data.Width; col++, bufPos++, index += 4)
{
bool drawCheckerBoard = true; // for alpha
UInt32 rgba = m_image[bufPos];
UInt32 r = EnableRedChannel ? ((rgba >> 0) & 0xFF) : 0x00;
UInt32 g = EnableGreenChannel ? ((rgba >> 8) & 0xFF) : 0x00;
UInt32 b = EnableBlueChannel ? ((rgba >> 16) & 0xFF) : 0x00;
UInt32 a = (rgba >> 24) & 0xFF;
...
...
}
}
and then the usual Marshal.Copy and unlock bits etc...
As you can see it is not really an optimized way, I wanted some suggestions for a faster method.
Thanks