octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OS X help needed


From: John Swensen
Subject: Re: OS X help needed
Date: Thu, 27 Oct 2016 10:44:16 -0700


On Oct 27, 2016, at 10:05 AM, John W. Eaton <address@hidden> wrote:

We have the following code to get the number of bits per pixel for the current display on OS X systems:

#if defined (HAVE_CARBON_CGDISPLAYBITSPERPIXEL)

     *dp = CGDisplayBitsPerPixel (display);

#else

     /* FIXME: This will only work for MacOS > 10.5.  For earlier versions
        this code is not needed (use CGDisplayBitsPerPixel instead).  */

     CGDisplayModeRef mode = CGDisplayCopyDisplayMode (display);
     CFStringRef pixelEncoding = CGDisplayModeCopyPixelEncoding (mode);

     if (CFStringCompare (pixelEncoding, CFSTR (IO32BitDirectPixels), 0) == 0)
       *dp = 32;
     else if (CFStringCompare (pixelEncoding,
                               CFSTR (IO16BitDirectPixels), 0) == 0)
       *dp = 16;
     else
       *dp = 8;

#endif

But now I see that the function CGDisplayModeCopyPixelEncoding has been deprecated for OS X 10.11.  Is there a replacement?  It doesn't have to be a direct replacement for this function, we just need some way to get a value for the number of bits per pixel for the display.

jwe



Unfortunately, I don’t think there are any good options. As far as I can tell, Apple is trying to move toward “act like you have 30 bit depth and we will take care of making it look right if it is something less”.
See http://stackoverflow.com/questions/36902312/detecting-if-a-display-supports-30-bit-color

There is a hack shown how to do it linked from https://github.com/SFML/SFML/issues/1122 to http://stackoverflow.com/questions/8210824/how-to-avoid-cgdisplaymodecopypixelencoding-to-get-bpp/33519316#33519316. The likelihood of that dictionary changing in the future is probably pretty good, so probably not a good/satisfying solution.

Sorry to not be more help.

John S.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]