-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Thanks for forking / putting this up here!
I noticed in Xcode 12.4, this line raises an error:
long bpp = CGDisplayBitsPerPixel(cgScreenID);
"Implicit declaration of function 'CGDisplayBitsPerPixel' is invalid in C99"
I found that CGDisplayBitsPerPixel is deprecated.
I found this solution:
https://stackoverflow.com/questions/8210824/how-to-avoid-cgdisplaymodecopypixelencoding-to-get-bpp
I replaced the above line with this code and it works again:
CGDisplayModeRef mode = CGDisplayCopyDisplayMode(cgScreenID);
CFDictionaryRef dict = (CFDictionaryRef)*((int64_t *)mode + 2);
CFNumberRef num;
int bpp;
if (CFGetTypeID(dict) == CFDictionaryGetTypeID()
&& CFDictionaryGetValueIfPresent(dict, kCGDisplayBitsPerPixel, (const void**)&num))
{
CFNumberGetValue(num, kCFNumberSInt32Type, (void*)&bpp);
}
Metadata
Metadata
Assignees
Labels
No labels