Recent

Author Topic: User Monitor Resolution - DPI, PPI, Etc.  (Read 8269 times)

Rails

  • Guest
User Monitor Resolution - DPI, PPI, Etc.
« on: April 01, 2012, 06:25:30 pm »
I have Googled and lost.  :'(   :D

I have been looking for a reliable way to find out the resolution of a user's monitor, other than by asking them to input it into a configuration screen. There doesn't appear to be a way to directly query the machine. I think you can query the OS, but it will only return what it in turn thinks or pretends the resolution is. I need to know what it is in fact.

So, am I correct in thinking I will have to ask the user during setup or configuration, or is there a reliable method using code that I missed?


felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: User Monitor Resolution - DPI, PPI, Etc.
« Reply #1 on: April 03, 2012, 08:35:50 am »
I have no idea what you mean about the monitor pretending. My only experience is only in Android where indeed some phones lie about the DPI, but I think that you should just use the value that the system gives you. If the system lies, it's his problem.

The LCL has some routines to get the DPI:

Screen.PixelsPerInch: http://lazarus-ccr.sourceforge.net/docs/lcl/forms/tscreen.pixelsperinch.html

or to get for X and Y axis separately:

LCLIntf.GetDeviceCaps(DC,LOGPIXELSX);
LCLIntf.GetDeviceCaps(DC,LOGPIXELSY);

http://lazarus-ccr.sourceforge.net/docs/lcl/lclintf/getdevicecaps.html

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: User Monitor Resolution - DPI, PPI, Etc.
« Reply #2 on: April 03, 2012, 09:40:43 am »
I think you can query the OS, but it will only return what it in turn thinks or pretends the resolution is.
Are you talking about windows considering all screens as 96 dpi by default?
As Felipe indicated the functions that return screen resolution are named LOGPIXELSX, LOGPIXELSY because they return logical resolutions, not physical.

On modern hardware you could look at the EDID (extended display identification data) to figure out the real monitor size and calculate the real dpi. Sample code can be found here: http://stackoverflow.com/questions/577736/how-to-obtain-the-correct-physical-size-of-the-monitor/579448#579448.

Rails

  • Guest
Re: User Monitor Resolution - DPI, PPI, Etc.
« Reply #3 on: April 03, 2012, 01:47:00 pm »
Yes, OSes deciding that the monitor has a certain DPI, when in fact it may be different. As I understand it, at least some Macs use 72 or 75 (I forget which) as their standard, while Windows likes 96, except for the new high DPI stuff.

I need to know the actual resolution so that my graphics scale correctly, at least as a user option, in which case a ten cm line at 1:1 scale, for example, should be an actual ten cm long on the screen. That requires knowing the physical DPI. 

Thanks for the stackoverflow link and pointing me to the LCL routines. Somehow, I missed those in my search. 

alanphys

  • Jr. Member
  • **
  • Posts: 57
Re: User Monitor Resolution - DPI, PPI, Etc.
« Reply #4 on: April 03, 2012, 03:50:39 pm »
Okay, I've am faced with this problem myself. The screen pixels per inch is very inaccurate, up to 1 cm in 10 depending on the monitor. Currently your options are:

1) Buy a medical grade monitor (hugely expensive);
2) manually calibrate your monitor.

Currently I am looking at photographing an object of known size, such as a small set square and getting the user to define the ends.

Cheers
Alanphys
Fedora 34 + KDE/QT5, Tinycore 8, Windows XP-10
https://github.com/alanphys

Rails

  • Guest
Re: User Monitor Resolution - DPI, PPI, Etc.
« Reply #5 on: April 03, 2012, 06:04:07 pm »
I've been looking into this a little bit. Perusing the ViewSonic site is quite revealing. They seem to be no longer including the monitor's DPI in its specs. I suspect it is because they are now offering the same "resolution" in a number of different screen sizes, resulting in different (and somewhat strange) DPIs. I looked at a half dozen or so 1920 x 1080 models in differing screen sizes, and they ran from roughly 80 to 102 DPI (calculated).   

I suggest the best way to determine a user's monitor DPI is have him either calculate it, using the manufacturer's specs (horizontal resolution divided by horizontal viewing area) or measure it with a screen ruler. You could build the ruler into the application.

I just calculated the DPI of my own monitor using ViewSonic's specs, then confirmed it using a Linux app called simply screenruler measured against a physical ruler. Both came in at 94 DPI. The Laz routine mentioned earlier in the thread reports 96 DPI.

BTW, it looks like the Laz routine defaults to 72 DPI if the OS doesn't return a value.

« Last Edit: April 03, 2012, 09:36:15 pm by Rails »

 

TinyPortal © 2005-2018