Simple questions: Placing Pixels on a form

May 4 2007 9:40 AM

Hello,
I'm trying to fill a windows form with red pixels.

My code is included bellow. I tried to place it in mouse down event handlers, paint event handlers but the result is mostly the same : the application slows down ( almost crashes) and does not display the pixels.


{

Bitmap bmp = new Bitmap(this.Width, this.Height);

for (int i = 0; i < this.Width; i++)

{

for (int j = 0; j < this.Height; j++)

{

bmp.SetPixel(i, j, Color.Blue);

}

}

Graphics g = this.CreateGraphics();

g.DrawImage(bmp, new Point(0, 0));

bmp.Dispose();

}


Any help would be greatly appreciated.


Answers (2)