buchholt
asked on
Drawing lines in millimeters in vb.net
Hi there,
How do I draw a line of X millimeters in a picturebox.
When putting a ruler onto the screen(monitor physically), the drawn line and ruler should be equal in size.
I need it for VB.Net
- Thanks ...
How do I draw a line of X millimeters in a picturebox.
When putting a ruler onto the screen(monitor physically), the drawn line and ruler should be equal in size.
I need it for VB.Net
- Thanks ...
How are you drawing the line? If you are using a graphics object, you can set the PageUnit to be GraphicsUnit.Millimeter.
ASKER
I'm drawing like this:
Dim g As Graphics = e.Graphics
Dim p As New Pen(Color.Black, 1)
g.PageUnit = GraphicsUnit.Millimeter
Dim a As New PointF(0, 50)
Dim b As New PointF(100, 50)
g.DrawLine(p, a, b)
... this does not give my a line on 100 millimeters as I would expect - but a 116 millimeter long line!!!
Dim g As Graphics = e.Graphics
Dim p As New Pen(Color.Black, 1)
g.PageUnit = GraphicsUnit.Millimeter
Dim a As New PointF(0, 50)
Dim b As New PointF(100, 50)
g.DrawLine(p, a, b)
... this does not give my a line on 100 millimeters as I would expect - but a 116 millimeter long line!!!
What are you using to measure? Are you measuring on the monitor or on a printout? Try a screen capture, then print and measure.
ASKER
I am measuring on the monitor with a ruler
I imagine there is a fair amount of distortion. Your monitor might not be adjusted exactly right. If you go into the monitor settings, you can probably fiddle with the settings so whatever guide it offers will match your ruler. Then try measuring your line in VB.
Again, I suggest that you simply print out the line and measure it.
ctm5
Again, I suggest that you simply print out the line and measure it.
ctm5
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Oh, I forgot to say. The DPI setting of your computer is in ControlPanel/ Display/ Settings/ Advanced. Thsi setting is taken as the reference to convert between dimensional (mm or inches) and Pixels
Jack.net
Jack.net