I want to fetch all the supported resolutions for mac screen. I'm using the below code for achieving all supported resolutions:CFArrayRef modeList;modeList=CGDisplayCopyAllDisplayModes(displays[i], NULL);By using the above code, I'm only getting the resolutions as shown in below image:I have installed one app which shows supported resolutions for my mac screen. It shows the resolutions as shown into below image. I also want to get the higher resolutions as they are showing.I have referred the below link:CGDisplayCopyAllDisplayModes leaves out one valid modeBut I don't know how to get other supported resolutions using kCGDisplayShowDuplicateLowResolutionModes. 解决方案 The accepted answer at the link you provide does present the answer you need, though it's using an undocumented options flag which is unfortunate. You have to pass in the options dictionary to your call to CGDisplayCopyAllDisplayModes as it indicates:CGDirectDisplayID mainDisplayID = CGMainDisplayID();CFStringRef keys[1] = { kCGDisplayShowDuplicateLowResolutionModes };CFBooleanRef values[1] = { kCFBooleanTrue };CFDictionaryRef options = CFDictionaryCreate(kCFAllocatorDefault, (const void**) keys, (const void**) values, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );CFArrayRef modesArray = CGDisplayCopyAllDisplayModes( mainDisplayID, options );and then look through the returned display modes seems to work for me. Note that you'll probably want to check the boolean returned by CGDisplayModeIsUsableForDesktopGUI(…) to filter out those that are invalid (depending on your use case).Obviously you'll be passing in each of the different display ids in turn and get output more like this:Display 3: external, mainpoints: (2560 x 1440), pixels: (2560, 1440)points: (1280 x 720), pixels: (1280, 720)points: (800 x 600), pixels: (800, 600)points: (1024 x 768), pixels: (1024, 768)points: (1280 x 960), pixels: (1280, 960)points: (1344 x 1008), pixels: (1344, 1008)points: (1344 x 756), pixels: (1344, 756)points: (1600 x 1200), pixels: (1600, 1200)points: (1600 x 900), pixels: (1600, 900)points: (2048 x 1152), pixels: (2048, 1152)Display 2: builtin,points: (2880 x 1800), pixels: (2880, 1800)points: (1440 x 900), pixels: (1440, 900)points: (3360 x 2100), pixels: (3360, 2100)points: (2560 x 1600), pixels: (2560, 1600)points: (2048 x 1280), pixels: (2048, 1280)points: (1650 x 1050), pixels: (1650, 1050)points: (1280 x 800), pixels: (1280, 800)points: (1152 x 720), pixels: (1152, 720)points: (1024 x 768), pixels: (1024, 768)points: (800 x 600), pixels: (800, 600)Display 5: external,points: (1920 x 1200), pixels: (1920, 1200)points: (960 x 600), pixels: (960, 600)points: (800 x 600), pixels: (800, 600)points: (1024 x 768), pixels: (1024, 768)points: (1024 x 640), pixels: (1024, 640)points: (1280 x 960), pixels: (1280, 960)points: (1280 x 800), pixels: (1280, 800)points: (1344 x 1008), pixels: (1344, 1008)points: (1344 x 840), pixels: (1344, 840)points: (1600 x 1200), pixels: (1600, 1200)points: (1600 x 1000), pixels: (1600, 1000)Also note that these numbers don't line up with what's showing for MBP, for example. "looks like 1920 x 1200" which doesn't match any of the listed resolutions.Another dev was having trouble getting this to work, so I pushed my quick hacked together test project that works up to github so others can see the entire working project. Hopefully that'll help someone (DO clean up that code before you use it in any kind of product though - it's just a quickest possible hacked together test code). 这篇关于如何获得可可中所有可能的屏幕分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 19:21