Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get better line quality in Picture Box?

Status
Not open for further replies.

sname

Programmer
Nov 4, 2003
5
0
0
US
When we use .Line or .Circle to draw a line or circle in a picture box, the line is not smooth. If you look at the details of the line, you can see stairs that looks like poor resolution. I tried different DrawMode, DrawStyle and ScaleMode, but could't get better. Does any one know how to draw a smooth line (not vertical nor horizontal)in picture box? Thanks in advance.
 
The jagged effect that you are seeing is commonly known as aliasing, and is basically unavoidable when drawing anything other than a horizontal or vertical line on a typical raster device.

You might argue that you don't see these jaggies on the output of laserprinter - well, trust me, they are still there, but the resolution of a laserprinter is sufficiently high that the human eye cannot see the steps.

Ah, you say, but I look at lines and curves on-screen in some other applicatins and they don't appear jagged. True, and to achive this they use a technique called antialiasing (actually, a number of techniques) or oversampling. This reduces the prominence of jaggies by surrounding the stairsteps with intermediate shades of gray (for gray-scaling devices) or colour (for colour devices).

Sadly, the VB picturebox does not directly upport antialiasing, and nor does the basic underlying GDI API.

You have to start looking at things like GDI+ (which has a SetSmoothingMode method)* or DirectX (although using DirectX just to get antialiasing in a PictureBox is a slight touch of using a hammer to crack a nut). Or, of course, you could try writing your own oversampling routine; a discussion of just such an approach was started here: thread222-873524

* a keyword search in this forum should locate several examples from me on using GDI+ from VB (although not an antialiasing example, as far as I can recall)
 
Thank you strongm! Although there is no direct solution, I will try to follow your guide.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top