Skip to content

Determining physical display dimensions

3 messages · Bert Gunter, Earl F. Glynn, Marc Schwartz

#
Folks:

(Basically a non-R question).

Is there any (simple) OS independent way for (the latest version of) R to
determine the physical dimensions in pixels of the current display device?

Failing that, (how) can this be done for Windows (XP or 2000, say) ?

Thanks.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
"The business of the statistician is to catalyze the scientific learning
process."  - George E. P. Box
#
"Berton Gunter" <gunter.berton at gene.com> wrote in message
news:200508191747.j7JHlEBV017029 at faraday.gene.com...
Take a look at the Windows GetDeviceCaps API call
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_88s3.asp

Parameters that can be queried include:
HORZRES  Width, in pixels, of the screen.
VERTRES Height, in raster lines, of the screen.

HORZSIZE Width, in millimeters, of the physical screen
VERTSIZE  Height, in millimeters, of the physical screen

The specifics of how to use this API call will vary by language.  Google
will be your friend.

efg
Bioinformatics
Stowers Institute for Medical Research
#
On Fri, 2005-08-19 at 13:17 -0500, Earl F. Glynn wrote:
FWIW, in case anyone should see this thread and wonder how to do this
somewhat easily in R for systems running X, there is a CLI utility
called 'xdpyinfo' that returns a great deal of data on the connected
display(s).
[1] "  dimensions:    1600x1200 pixels (301x231 millimeters)"
[1] "  resolution:    135x132 dots per inch"


One can then parse the above using R functions as required. Such as:
[1] ""            ""            "dimensions:" ""
[5] ""            ""            "1600"        "1200"
[9] "pi"          "els"         ""            "301"
[13] "231"         "millimeters"
h.pix, v.pix)
The current display is 1600 x 1200 pixels
with a physical size of 301 x 231 mm


This can get more complicated with multi-monitor systems, depending upon
whether you are running in xinerama (multi-monitor spanning mode) or
non-xinerama mode and consideration for symmetric or asymmetric
resolutions. 'man xdpyinfo' and 'man X' (noting the 'DISPLAY'
environment variable) will be helpful here to determine which
display/screen R is running on.

For example, on my system which has two displays, each with 1600x1200, I
get:
DISPLAY
 ":0.0"

with R running on the main laptop LCD (15" diag), versus:
DISPLAY
 ":0.1"

with R running on the external LCD (20.1" diag), with the DISPLAY
variable indicating:

":DisplayNumber.ScreenNumber"


Thus, on my system, the output of the system() calls are actually:
[1] "  dimensions:    1600x1200 pixels (301x231 millimeters)"
[2] "  dimensions:    1600x1200 pixels (411x311 millimeters)"
[1] "  resolution:    135x132 dots per inch"
[2] "  resolution:    99x98 dots per inch"


HTH,

Marc Schwartz