根据Bob Powell的LockBits教程,我在C# 2010 Visual Studio Express中放入了以下代码:
System.Drawing.Imaging.BitmapData bmp =
BitmapImage
.LockBits(new Rectangle(0, 0, 800, 600),
System.Drawing.Imaging.ImageLockMode.ReadWrite,
MainGrid.PixelFormat)
unsafe
{
for (int y = 0; y < bmp.Height; y++)
{
byte* row = (byte*)bmp.Scan0 + (y * bmp.Stride);
for (int x = 0; x < bmp.Width; x++)
{
row[x * 4] = 255;
}
}
}
在将位图数据推送到PictureBox中(PictureBox.Image = BitmapImage;),显示的只有一个带红色边框的白色背景和红色“X”符号。我做错了什么?