|
From: | Thomas Treichl |
Subject: | Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties |
Date: | Fri, 23 Jan 2009 22:29:45 +0100 |
User-agent: | Thunderbird 2.0.0.19 (Macintosh/20081209) |
Ben Abbott schrieb:
On Thursday, January 22, 2009, at 03:07PM, "Thomas Treichl" <address@hidden> wrote:John, you were asking for CGDirectDisplay.h and CGDisplayConfiguration.h on all systems? Generally yes, since MacOSX 10.3.9 and until at least 10.4.11 which is my system (Ben can you please verify on your 10.5.x system).Yes they also exist for Leopard. I wrote the short script below to do the job. #!/bin/sh -ev export INC="/Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Headers" g++ try.cc -Wl,-framework,ApplicationServices -I$INC -o try
Hi Ben,I had some problems with the example program that John wrote for us (also means that I cannot compile the current Octave src/display.cc file). Can you please verify my modified version that I attached to this email if this also works on your 10.5 system (comments about what has been changed and what should be done are included)... Does it compile and produce the same output?
Another thing is that on Mac we might have Carbon && X11. If this is the case then should we still use Carbon or should we use the traditional Unix way, cf. src/display.cc line 31ff ?
Thomas
#include <iostream> // I changed the following two #include lines because it's much easier // to include just the right one header of the Carbon framework so // that this simple line compiles foo-osx.cc without another -I flag: // // g++ foo-osx.cc -framework Carbon -o foo-osx // // #include <CGDirectDisplay.h> // #include <CGDisplayConfiguration.h> #include <Carbon/Carbon.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); // In the next two code lines I replaced CGFloat by float because // on my 10.4.11 system and on 10.3.x system the CGSize struct is // defined in Developer/Headers/CFMCarbon/CGGeometry.h as // // struct CGSize { // float width; // float height; // }; // typedef struct CGSize CGSize; float ht_mm = sz_mm.height; float 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; }
[Prev in Thread] | Current Thread | [Next in Thread] |