<分区>
这会产生条纹而不是点。为什么 ?我正在尝试绘制单个像素。还尝试了另一种方法(使用 fillrectangle),它也没有给出预期的结果,得到的是条而不是点。
protected override void OnPaint(PaintEventArgs pea )
{
Graphics g = pea.Graphics ;
for ( int y = 1 ; y <= Width ; y++ )
{
for ( int x = 1 ; x <= Height ; x++ )
{
System.Random rand = new System.Random() ;
Color c = (Color.FromArgb(rand.Next(256),
rand.Next(256),
rand.Next(256)));
// SolidBrush myBrush = new SolidBrush(c);
// g.FillRectangle(myBrush, x, y, 1, 1);
Bitmap pt = new Bitmap(1, 1);
pt.SetPixel(0, 0, c);
g.DrawImageUnscaled(pt, x, y);
}
}
这里发生了什么?