how to draw a line of 2.3 mm width on a printer

Started by
4 comments, last by Decrius 15 years, 12 months ago
Hello, Please tell me how to draw a line of 2.3mm width on a printer? If i want to use the glLineWidth then i can specify the width in terms of number of pixels. But how can i find the exact number of pixels that are equal to 2.3mm??. Because the resolution of the printer is different in X and Y directions and i am not sure which resolution should i take to calculate the number of pixels that are equal to 2.3 mm?? Please help. I thank you in advance. Faisal.
Advertisement
This is what DPI (dots per inch) is for. For instance a DPI of 70 means that there are 70 dots, or pixels, for every inch. So to draw a line that is X mm wide, convert it to inches, and use the DPI to find the width in pixels.
But there are two Apis in windows. One for dots per inch in the horizontal direction and the second for the dots per inch in the vertical direction. And my question is that which one to use? horizontal or vertical?

thanks in advance,
faisal
Quote:Original post by f_shaukat
But there are two Apis in windows. One for dots per inch in the horizontal direction and the second for the dots per inch in the vertical direction. And my question is that which one to use? horizontal or vertical?

thanks in advance,
faisal


Math ftw.

If you need a diagonal line which is 2.3 by 2.3 mm (so in length it is sqrt(2 * 2.3^2)), and horizontal DPI is 70, vertical is 80, this means it should vertically be stretched by 80/70 (= 1.1429).

2.3 mm = 0.090551181 inch

pixels = inches * DPI

In width: 0.090551181 * 70 = 6.3386 pixels
In height: 0.090551181 * 80 = 7.2441 pixels

7.2441
------ = 1.1429
6.3386

As I said, it would be vertically streched on screen this way.

Good luck.

[size="2"]SignatureShuffle: [size="2"]Random signature images on fora
I could not understand this solution. Does this mean that i should call glLineWidth(1.1429)? And i also do not understand why you are computing it from the x-length and y-length of the line. Because we are discussing only the width of the line.

regards,
Faisal
Quote:Original post by f_shaukat
I could not understand this solution. Does this mean that i should call glLineWidth(1.1429)? And i also do not understand why you are computing it from the x-length and y-length of the line. Because we are discussing only the width of the line.

regards,
Faisal


Than I don't see why it would matter to you that the Y-axis has a different DPI then the X-axis.

x-length = width

1.1429 = the factor

So you need to do glLineWidth(6.3386) to get a line with width 2.3mm on paper.

PS: did you read my post? Or didn't I add enough comments?

[size="2"]SignatureShuffle: [size="2"]Random signature images on fora

This topic is closed to new replies.

Advertisement