[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties
From: |
Ben Abbott |
Subject: |
Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties |
Date: |
Thu, 22 Jan 2009 12:56:12 -0500 |
On Thursday, January 22, 2009, at 10:36AM, "John W. Eaton" <address@hidden>
wrote:
>On 22-Jan-2009, Ben Abbott wrote:
>
>| Better yet, if octave is able to parse compressed XML files, the information
>can be read directly.
>
>I'd rather call a few simple functions from C++ like on other
>systems. Does the following work?
>
>jwe
>
>
>#include <iostream>
>
>#include <CGDirectDisplay.h>
>#include <CGDisplayConfiguration.h>
>
>int
>main (void)
>{
> CGDirectDisplayID display = CGMainDisplayID ();
>
> if (display)
> {
>
> size_t ht = CGDisplayPixelsHigh (display);
> size_t wd = CGDisplayPixelsWide (display);
>
> std::cerr << wd << "x" << ht << " pixels" << std::endl;
>
> CGSize sz_mm = CGDisplayScreenSize (display);
>
> CGFloat ht_mm = sz_mm.height;
> CGFloat wd_mm = sz_mm.width;
>
> std::cerr << wd_mm << "x" << ht_mm << " mm" << std::endl;
>
> double resy = wd * 25.4 / wd_mm;
> double resx = ht * 25.4 / ht_mm;
>
> std::cerr << resx << " resx" << std::endl;
> std::cerr << resy << " resx" << std::endl;
>
> std::cerr << (resx + resy) / 2 << " avg dpi" << std::endl;
>
> size_t depth = CGDisplayBitsPerPixel (display);
>
> std::cerr << depth << " bit depth" << std::endl;
> }
> else
> std::cerr << "failed to find display" << std::endl;
>
> return 0;
>}
The program's output is below.
1280x1024 pixels
380x310 mm
83.9019 resx
85.5579 resx
84.7299 avg dpi
32 bit depth
I can confirm the numbers are correct as well ... well almost. The physical
size of my screen is 14.75x11.75 inches.
>> [1280,1024]./[14.75,11.75]
ans =
86.7797 87.1489
The manufacturer likes to claim 15x12inches
>> [1280,1024]./[15,12]
ans =
85.3333 85.3333
In any event, looks good to me.
Ben
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, (continued)
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, John W. Eaton, 2009/01/21
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, Shai Ayal, 2009/01/22
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, John W. Eaton, 2009/01/22
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, Michael Goffioul, 2009/01/22
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, John W. Eaton, 2009/01/22
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, Michael Goffioul, 2009/01/22
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, Michael Goffioul, 2009/01/22
- Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, John W. Eaton, 2009/01/22
Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, Ben Abbott, 2009/01/22
Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties,
Ben Abbott <=
Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, Ben Abbott, 2009/01/22
Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties, Ben Abbott, 2009/01/22