Click to See Complete Forum and Search --> : [RESOLVED] Graphic bug


Marraco
January 11th, 2010, 11:19 AM
When I use this line to draw lines on a picture:

Dim MyPen as new Pen with {.width=1}
Dim MyGraphics As Graphics = Graphics.FromImage(BMP)
MyGraphics.DrawLines(MyPen, MyDots.ToArray)I get this image:
http://i46.tinypic.com/1eassh.png

but if I use MyPen.Width = 2, then I get the right image:

http://i49.tinypic.com/ei5j0p.png

I don't understand what I are doing wrong.

Craig Gemmill
January 11th, 2010, 12:00 PM
Could you post a sample project that we can use to reproduce the error?

TheGreatCthulhu
January 11th, 2010, 12:50 PM
Intriguing. It’s one of those problems that make no sense.

Now, this is just guesswork, but try playing with the SmoothingMode, InterpolationMode, PixelOffsetMode, CompositingMode & CompositingQuality properties of the Graphics class.
Is your image resized after you draw to it? This might be the cause.

Marraco
January 11th, 2010, 02:23 PM
Could you post a sample project that we can use to reproduce the error?

Ok. Graphic data is too large to enter on this post, so I attach a txt file with the code.

map is drawed by double clicking the picturebox control

each double click switches pen width

Marraco
January 11th, 2010, 02:43 PM
Intriguing. It’s one of those problems that make no sense.

Now, this is just guesswork, but try playing with the SmoothingMode, InterpolationMode, PixelOffsetMode, CompositingMode & CompositingQuality properties of the Graphics class.
Is your image resized after you draw to it? This might be the cause.

Great!

That was.

Adding those lines:

MyGraphics.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
MyGraphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality

solves it.

Thanks TheGreatCthulhu :D

Here is a bit of Latin rock for you!:
http://www.youtube.com/watch?v=K_ZWc5nBWys

TheGreatCthulhu
January 11th, 2010, 04:05 PM
Thanks. Glad I was able to help.