[.net] GDI+ pixel

Started by
7 comments, last by Scet 16 years, 2 months ago
I'm trying to draw a pixel in GDI+ but theres no function for it. Theres one for drawing rectangles, circles, arcs, but no drawpoint. Does anyone know how I can accomplish this? Thanks
Advertisement
Come on man, how many of your threads are going to be about drawing pixels? Me and many others have already told you how to, in many different APIs as well. Also what's with all the API changes? First it was MDX, then OpenGL, then MDX again and now it's GDI+?

Seriously just pick your favorite API and got on with it.

To answer your question though, the fastest method would be to create a Bitmap and then write to it. However since writing and locking is expensive, you should "draw" to an array and then just write the whole array to the Bitmap. This should sound familiar since it's the same technique as in DirectX and openGL, just with a Bitmap in place of a texture.
Try Graphics.FillRectangle(Brushes.Red, x, y, 1, 1); but it is sloow.
System.Drawing.Bitmap has a SetPixel method, but it is slow.

You should tell us what you're trying to do, because raw pixel access is rarely, rarely ever needed. That's why most ways of doing it are slow, because it's just not an important enough task to provide an easy means of doing it quickly.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Quote:Original post by Scet
Come on man, how many of your threads are going to be about drawing pixels? Me and many others have already told you how to, in many different APIs as well. Also what's with all the API changes? First it was MDX, then OpenGL, then MDX again and now it's GDI+?

Seriously just pick your favorite API and got on with it.


I wasn't told how to draw to a texture using Managed Directx, only to use rendertosurface class. I tried OpenGL, but VB isn't good for that. Now I'm trying GDI+ but it's too slow to draw a point.
Quote:Original post by ed209
I wasn't told how to draw to a texture using Managed Directx, only to use rendertosurface class.


Really? Because I seem to remember sending you a PM detailing how to write to both SDL surfaces and DirectX textures. Actually drawing the texture or surface is trivial and could be found with a simple Google search.

Quote:Original post by capn_midnight
You should tell us what you're trying to do, because raw pixel access is rarely, rarely ever needed.


If you look through his posts you'll see he's trying to make an emulator. For which system now I'm not sure. Initially it was for the NES, but that would be far too difficult for him so we suggested the CHIP-8. However at this stage it looks like looking up a simple tutorial is difficult.

I know my posts here sound kind of harsh, but I've responded to many of this guys posts and even shared source code with him through PMs and at this point it's like talking to a brick wall. His threads all die out because he rarely responds to them and then a week later we get the same question with a different API. We're here to help you ed209, but you're not giving us a lot to work with.
Ah, I see.

In that case, "the Lord helps those whom help themselves".

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Quote:Original post by Scet
Come on man, how many of your threads are going to be about drawing pixels? Me and many others have already told you how to, in many different APIs as well. Also what's with all the API changes? First it was MDX, then OpenGL, then MDX again and now it's GDI+?



Originally, I asked how to draw to a texture in managed directx and was told to search for rendertosurface. I found a tutorial that shows you how to render to a texture in managed directx but I didn't know how to write an array to the texture.

It was suggested in one of my threads that I just use GDI+ because directx would be overkill unless I wanted to be able to resize the window. So I figured out how to draw shapes to a bitmap in GDI+, but still didn't know how to draw points to the bitmap. Isn't that what you mean by writing an array to a texture or bitmap - drawing an array of pixels?

I'm trying here, man.
Drawing.Bitmap.LockBits

[google]

This topic is closed to new replies.

Advertisement