5
$\begingroup$

I'm a programmer working in Java and I'm not sure if this is the right place to ask this kind of question, here it goes:

In my program, I need to show an image (.jpeg .png etc.) based on the screen size, this image is used to compare to real size (physical) of an actual label which is later printed on a specific machine.

The issue is, for example on my machine I have the laptop screen and a '27 monitor they are both using the same resolution 1920x1080 but as you imagine if you resize any window/program/image it looks smaller on the laptop as the physical screen size is different although it has the same resolution (I imagine is because the physical size of the pixel is smaller than the ones on my monitor)

Now what I would need to do is somehow always show the image on it's corect physical size (as it were printed), on any type of screen.

Regarding to programming I could easily get the screens size and resize the image but, this is because the OS gives the size (it's set up size) back to the program, yet even if I have the correct size the physical screen could display the image smaller for example, as the screen's pixels are smaller.

Any ideas where to start with this? How can I know the real physical screen size? This seems to be more a hardware issue than graphics..

$\endgroup$
4
$\begingroup$

The OS does not, in many or most cases, know the physical screen size! Often the only thing you can glean is the make and model, sometimes not even that. So if you do not want to have a database then the best you can do is ask your user.

There are also some interesting corner cases. What do you do if the monitor is in fact a projector? What do you do in multi monitor setups? What if the image is halfway between 2 monitors? What do you do if the operator is using pixel zoom for accessibility reasons? What do you do if the image is shown on 2 monitors at the same time? What do you do if the monitor is huge, like one used in a conference room and your image turns out to be very small in comparison (like 4 by 4 pixels)? ...

$\endgroup$
  • $\begingroup$ Yep, thank you for adding these questions; some of them I already had them on my list. I am a bit puzzled how to use or create a proper DB for this as it seems to require a lot of accurate resources. I was hoping for an alternate/possible solution.. $\endgroup$ – 4673_j Jan 5 '17 at 11:44
  • $\begingroup$ @4673_j This is why even Adobe does not implement this function. Even though their users would benefit (and they would get the DB in no time by asking users). Basically its not entirely feasible at current date. $\endgroup$ – joojaa Jan 5 '17 at 11:47
  • $\begingroup$ Hm.. I might have a partial solution in my case, as there might be ~10 different monitors/screens. I'm searching now how to extract that information from the system. Thanks for your effort. I think this kind of "feature/info" has to be provided by the OS, not just the resolution; as the OS has direct access to all physical components. $\endgroup$ – 4673_j Jan 5 '17 at 11:55
  • $\begingroup$ @4673_j Its good that this info did not exist back in 1995 or oherwise the web would still be designed like a print publication. Its a good thing that the os does not try to react to my monitors DPI or it would defeat many normal operations. $\endgroup$ – joojaa Jan 5 '17 at 11:58
2
$\begingroup$

Back in the days, MSDN defined a couple of values which in most cases are useless (total crap):

https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877%28v=vs.85%29.aspx

int width_mm = GetDeviceCaps(hdx, HORZSIZE);
int height_mm = GetDeviceCaps(hdx, VERTSIZE);

However, there is a way to retrieve the information through VESA. Any modern monitor should be able to handle that. Only I have no clue how that's done. Under Linux you have a command called xrandr which can be used to find out the info:

% xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
VGA-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 553mm x 311mm
   1920x1080     60.00*+
   1680x1050     59.95  
   1600x1200     60.00  
   1440x900      59.89  
   1280x1024     60.02  
   1280x960      60.00  
   1280x720      60.00  
   1024x768      60.00  
   800x600       60.32  
   640x480       59.94  
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
  • Note that I verified and my monitor dimensions in mm are correct in the output of my xrandr -q command.

I would suggest you look at how that xrandr tool does it and you'd get your info right at hand.

From what I've read over the years, the VESA info can be wrong once in a while, but it's quite reliable now a day, I would think.

$\endgroup$
  • $\begingroup$ Hm.. sounds interesting, I'll have a look over VESA. I'm fine with linux, yet most of the users for this program are using Windows. I'll start here, see how far I can get. Thanks for your time. $\endgroup$ – 4673_j Apr 20 '18 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.