Home » Community » Newbie corner » How to get pixels per millimeter for current screen?
How to get pixels per millimeter for current screen? [message #36037] |
Fri, 20 April 2012 11:47  |
slashupp
Messages: 231 Registered: July 2009
|
Experienced Member |
|
|
I'm implementing some WYSIWYG functionality and need to calculate
sizes specified in mm to the correct on-screen representation in
pixels.
Where/how do I get the pixel-to-mm ratio?
[edit]
I'm trying:
void checkresolution::Paint(Draw &w)
{
Size szpmm = w.GetPageMMs();
Size szpp = w.GetPagePixels();
double ppmmx = (double)szpp.cx/(double)szpmm.cx;
double ppmmy = (double)szpp.cy/(double)szpmm.cy;
//double dppmm = (ppmmx + ppmmy)/2;
//int ppmm = (int)(dppmm + 0.5);
int ppmm = (int)(ppmmx + 0.5);
int cm3 = (int)(ppmm * 30.0);
int cm7 = (int)(ppmm * 70.0);
w.DrawLine(10,10,cm3,10,3,Black());
w.DrawLine(10,15,cm7,15,3,Black());
}
The value I get is not quite correct, but seems that this is
the best I can hope for? The error occurs with the rounding
from double to int that Draw requires.
[Updated on: Sat, 21 April 2012 08:15] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Apr 28 02:28:18 CEST 2025
Total time taken to generate the page: 0.00897 seconds
|