public void Clear24(byte r, byte g, byte b)
{
unsafe
{
byte* sourcePtr = (byte*)(bitmapData.Scan0);
for (int i = 0; i < bitmapData.Height; i++)
{
for (int j = 0; j < bitmapData.Width; j++)
{
*(sourcePtr) = b;
*(sourcePtr + 1) = g;
*(sourcePtr + 2) = r;
sourcePtr += 3;
}
sourcePtr += bitmapData.Stride - bitmapData.Width * 3; //move to the end of the line (past unused space)
}
}
}