Advertisement Jump to content
Sign in to follow this  

[.net] Im trying to make an image editor

This topic is 4374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can someone point me to references I must read on, or sample codes maybe? I am, so far, still confused on how to properly use the System::Drawing namespace. I need something to start with, like, drawing a line across an existing bitmap. Hehe, I am such a newb to this stuff.

Share this post

Link to post
Share on other sites
You'd normally use a Graphics object to handle this. You can create one for an existing Bitmap using the Graphics.FromImage method.

To draw a line, you could do this:

Bitmap B = new Bitmap(100, 100);
Graphics G = Graphics.FromImage(B);

G.DrawLine(Pens.Blue, 0, 0, 100, 100);


There are various properties of the Graphics object that control the quality of the drawing. Graphics.SmoothingMode, for example, controls antialiasing (so setting it to HighQuality draws very nice smooth lines).

The only one I can think of that might cause confusion is Graphics.PixelOffsetMode. By default, if you draw something inside pixel (0,0) it is drawn as if (0,0) is in the centre of the top-left pixel, rather than the more intuitive top-left corner. Set it to Half to offset it backwards (-.5,-.5). The most obvious test of this is to use Graphics.DrawImage with integer coordinates - it looks rather blurry with the default settings.

Graphics.Transform can be used to transform what you're drawing, for all sorts of interesting rotation and scaling effects.

[Edited by - benryves on January 26, 2007 9:04:19 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!