Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine if current device does have a P3 capable display?

Is there a way to conditionally select a Standard RGB color or a P3 color if the device supports it?

I thought about something like the following for iOS versions:

if #available(iOS 12.0, *) {
    ...
} else {
    ...
}
like image 286
tomaculum Avatar asked Jun 28 '19 09:06

tomaculum


People also ask

What is display P3 used for?

So what is then Display P3? Very simply put it's a color space within the RGB color model that represents a larger spectrum of colors than the current industry standard sRGB. And most of us have been using sRGB for probably over a decade now, but with display P3 we get a 25 percent larger color space compared to sRGB.

Is DCI P3 the same as display P3?

P3 is an RGB color space. DCI-P3 (Digital Cinema Initiative) is used with digital theatrical motion picture distribution (DCDM). Display P3 is a variant developed by Apple Inc. for wide-gamut displays.


1 Answers

UITraitCollection has a displayGamut property, which is an enum UIDisplayGamut

@available(iOS 10.0, *)
public enum UIDisplayGamut : Int {
    case unspecified // UIKit will not set this anymore, instead a sensible default is chosen based on the device capabilities and settings always
    case SRGB
    case P3
}

You can query the “main screen”

let hasP3Display = UIScreen.main.traitCollection.displayGamut == .P3 

or the display of a specific view (which can be different if an external monitor is used)

let hasP3Display = view.traitCollection.displayGamut == .P3
like image 177
Martin R Avatar answered Sep 19 '22 20:09

Martin R