Setting a Pixel

  • Thread starter Thread starter Bob Palank
  • Start date Start date
B

Bob Palank

I think the ability to set a pixel on a graphics surface ought to be
straightforward and I tried to illict Dr. Guis opinion but he was too busy
to respond. So I think he must agree with me but fears authority ;-}
What do others think ? ? ? My original email and Dr. Gui's assistants reply
is shown below.


I'm worried about Dr. GUI and honestly believe he is hoarding the T-Shirts !

In fun
Bob Palank







Dear Dr. Gui

Years ago C and VB allowed us to place a single point on the graphics
surface. I liked _SetPixel(). Now it would seem to me that if you build a
new fancy shmansy language called C#, you ought to be able to place one
colored dot on the screen. Oh I know you can using FillRectangle, but this
seems like hammering a tack with a 10 pound mallet!

Would you ask the powerful people to consider fixing this, or have I missed
something ?

Yours faithfully,

Bob Palank

St. Louis

Thank you for sending a question to Dr. GUI at the Microsoft Developer
Network. Your questions are the

heart of the "Ask Dr. GUI" column. Dr. GUI regrets that due to his many
other duties

he CANNOT provide an individual answer to your question. One of Dr. GUI's
most important and time-consuming

duties is performing lobotomies on marketing and management trainees. (Just
joking, boss!) Dr. GUI doesn't

do house calls, either--even though he has been known to do Windows(R).
Instead of providing individual answers, Dr. GUI selects the

most interesting and/or important questions to run in the"Ask Dr. GUI"
column. You can read the column in the MSDN News

printed newspaper, on the MSDN Library CD-ROM, or on the Web at:

http://msdn.microsoft.com.

If your question is selected for a column, Dr. GUI will thank you by sending
you a neato-keen-way-cool MSDN T-shirt.
 
Bob

Sorry Dr. GUI couldn't respond to your question. Why don't you just pinvoke SetPixel

Jackson Davi
-
This posting is provided "AS IS" with no warranties, and confers no right
 
I think the ability to set a pixel on a graphics surface ought to be
straightforward and I tried to illict Dr. Guis opinion but he was too busy
to respond. So I think he must agree with me but fears authority ;-}

The problem is GDI+ which is either internally based on floating-point
coordinates, or at least pretends that it was. You see, GDI+ doesn't
know about "pixels". GDI+ has never heard of pixels. It provides a
drawing surface with real-world coordinates, hence a single point
would be a mathematical point and therefore invisible.

If you want to draw screen pixels, you have three options:
1. Use P/Invoke and the GDI SetPixel function, as Jackson said.
2. Create a Bitmap and use the Bitmap.SetPixel method.
3. Create a Bitmap, lock it, and set the pixel using bit manipulation.
 

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

Back
Top