Drawing Pixels

C

Chris Saunders

I am fairly new to .Net and C# but am familiar with the Win32 API.
I wish to set the pixels of the client area of a window one at a time
with a specific color. I have so far discovered that System.Drawing.Bitmap
has a SetPixel() method but I can't seem to find out how to have the bitmap
displayed. I would actually like to have the pixels appear as I set them.

Regards
Chris Saunders
 
C

Chris Saunders

Thanks for the reply Kevin.

That class was the first place I looked but it does not appear
to provide for setting a pixel individually and having it appear
immediatly on the screen. So far all I have managed was to
use a System.Windows.Forms.PictureBox and a
System.Drawing.Bitmap, I use SetPixel for the
bitmap and then set the pictureBox.Image to the
bitmap. Even if I do pictureBox.Image = bitmap in
every iteration of the loop where I set the bitmap
pixels the redrawing does not appear until the loop
is finished.

I hope this explanation was clear enough.
Still hoping for a solution.

Regards
Chris Saunders
 
K

Kevin Spencer

Hi Chris,

Your original question was regarding setting the pixels of the "client area
of a window." This is different than drawing on a bitmap, which is not a
window, nor the client area of a window.

Most drawing is not done using the few methods available in the
System.Drawing.Bitmap class, such as the SetPixel method. In fact, most
drawing done on Bitmaps is done via the Graphics class. I would suggest you
read up on it.

I think you would also benefit from the articles and tutorials at
http://www.bobpowell.net/.

The particular problem you seem to be describing is that you want the Bitmap
to appear immediately after you perform some drawing operation. If you could
be more specific about your business requirement, I could probably be of
more help. In the meantime, if you visit the references I mentioned, you may
not need any help.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top