
|
GDI+ is supposed to be completely resolution independent. This means that when you draw a line, you should draw one of a certain width and the line should look the same whether you're drawing on a 72 DPI screen or a 1600 DPI screen or printer. For this reason, pens accept a float value for the width setting and your current graphics measurement setting determines the actual width. A pen with a width of 1 may be 1 nominal pixel, 1 millimeter or 1 inch in width. I use the term "nominal pixel" also because two lines drawn with a pen width of 1 and a graphics unit of Pixel are not always guaranteed to be of 1 pixel width or even of the same apparent width due to adjustments made during the rendering of the line. In reality, this approach is not always practical or desirable and you just want a line of exactly one pixel. Microsoft themselves have built in a little cheat for you. Simply set your pen width to -1 and the line will be 1 pixel whether your GraphicsUnit setting is Pixel, Inch or whatever. Copyright Robert W. Powell 2003, All rights reserved |