I'm working on an Android app and need to optimize bitmap loading based on the device's screen color space. My questions are:
- How can I find out the color space used by the device's screen?
- Does the app's rendering color space always match the device's screen color space?
- For bitmap loading in BitmapFactory, how do I choose the right color space for the inPreferredColorSpace property?
Please note that my app is rendered on an OpenGL surface. Do I need also to configure the openGL surface to match the device's screen colorspace ?
Any guidance or code examples would be greatly appreciated!
I don't think that the term device's screen color space is applicable here(at least for Android). One screen(both physical and logical) can use different color spaces since all the color spaces represent the same colors and can be indistinguishable from one another with a proper device-specific approach. I guess you are talking about the apparatus(GPU, engine, renderer) that supports specific color spaces better than another.
The rendering of the colorspaces may differ from renderer to renderer because some renderers work better with certain color spaces than with others and vice-versa - usually, it is due to the specifics of the actual implementation.
As you've specified you are using OpenGL rather than Vulkan(which is color space agnostic - since it has optimized rendering pretty much any color space and is not supported by old machines) - for OpenGL, the most natural and proficient color space is sRGB(of course, if the GPU can perform the correct conversion - if it cannot - the color space won't matter - because in the end all of them will be converted to the GPUs default one which is typically linear if I remember correctly) and if you have all the bitmap resources as sRGB (or at least can convert to it) - use it.
For older devices with low-quality old GPUs - the answer would be linear which is more natural but heavier.
For Vulcan supporting devices - use whatever suits you best in any given situation.
OpenGL can also use YUV(which should be more performant, etc.), but it is not natively supported by it - so to be rendered on the screen, the YUV file will be converted to RGB...
In all cases, some gamma correction may be needed afterward depending on the device it is used at - that is why this option is present in most of the games - this value is not uniform for all the different screens and GPUs and their combination.
Hope it helps.