I have an MFC application displaying images where I need to display the image in true-size i.e. the image should be rendered such that physical length of the object captured on the image should be same as the displayed length. For example, if I captured a object of 5 cm length the image should be displayed such that if I take a scale and measure its length on the monitor it should be 5 cm. I know the distance between the pixels in the image. But I need to display these images on different types of monitors. How do I get the physical distance between the pixels on the monitor? Any clues? Or is there any other way to implement it?
A:
As you rightly point out you need to know the size of the monitor. Short of asking the user to input the size you are unable to do this.
Goz
2010-02-21 13:40:42
+1
A:
The proper way would be calling GetDeviceCaps
with LOGPIXELSX
and LOGPIXELSY
. For a screen device context, however, it is very likely that the value will simply be set to 96 (it is set by the user in a control panel). The function works fine for printer DCs.
avakar
2010-02-21 18:55:43
but those are just logical values isn't? Can I rely on it for my physical measurements?
Naveen
2010-02-22 08:51:26
No - there's too much broken code around. And users abuse it instead of choosing different font sizes when they can't read text. But it's still the best you can do.
MSalters
2010-02-22 09:48:09
The values reflect the number of physical pixels per inch for a printer. For a display, the value is the one set by the user, so no, you can't rely on that. The system has no way of detecting the monitor's pixel density, it is not stored in the EDID block.
avakar
2010-02-22 09:49:00
thanks for the reply, so my best option seems to be ask the user to calibrate the monitor by using some known object.
Naveen
2010-02-22 16:53:00