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