lockbit 問題
Bitmap source = new Bitmap(pictureBox1.Image); BitmapData sourceData = source.LockBits(new Rectangle(0, 0, source.Width, source.Height), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
IntPtr source_scan = sourceData.Scan0;
unsafe
{
byte* p = (byte*)source_scan.ToPointer();
for (int height = 0; height < sourceData.Height; ++height)
{
for (int width = 0; width < sourceData.Width; ++width)
{
int r, g, b;
r = p[2];
g = p[1];
b = p[0];
p[0] = p[1] = p[2] = (byte)(255);
p += 3;
}
p += sourceData.Stride - (sourceData.Width * 3);
}
}
source.UnlockBits(sourceData);
pictureBox1.Image=source;
}
為什麼我這段code 什麼都沒有做做 好像没有运行一样 是什麼地方錯了嗎? 我是想把圖片換成一張全白圖