facebook / fresco

An Android library for managing images and the memory they use.
https://frescolib.org/
MIT License
17.06k stars 3.75k forks source link

[Feature Request] Explicit color management #2318

Open lpy opened 5 years ago

lpy commented 5 years ago

Description

Right now ImagePipeline allows to specify whether to transform to srgb and there are some APIs that use this bit. A more future-proof approach would be explicitly passing a target color space.

Before API level 26, Android only recognized all images as sRGB, right now it looks like old APIs just simply pass a false to its new variants to not decode to sRGB, which means the encoded color space of the images would likely be the target color space, applications that use the new version of Fresco and run on new OS might end up not getting what they want if they don't do color management, maybe consider only decode images to sRGB color space for old APIs?

Solution

Just some thoughts:

  1. Consider updating ImageDecodeOptions to have a ColorSpace, and use it instead of transformToSRGB;

  2. Update current APIs that accepts transformToSRGB to accept a ColorSpace instead;

  3. Update old APIs (introduced before API level 26) that don't accept transformToSRGB to explicit decode images to sRGB.

lpy commented 5 years ago

Not sure the backward compatible rules of this project, can API like DefaultDecoder#decodeJPEGFromEncodedImageWithColorSpace be changed?

zmroczek commented 5 years ago

Hi @lpy

Thanks for suggesting this idea! The approach looks good so far but we would need to discuss more about how to solve it and will come back to you soon.

lpy commented 5 years ago

Upload a pull request, please take a review :) If the direction looks good, I can proceed to sign the CLA, thanks!

lpy commented 5 years ago

Thanks for taking the pull request. That should cover all places that would use the Android decoder, but I am not sure whether there are other places that we should manage the color. Is there any place that decodes images without using the Android decoder?

lambdapioneer commented 5 years ago

@Lpy thanks a lot for doing this! There are two places where we decode without proper colour management, but these places are phasing out slowly:

@oprisnik for input regarding the animation backends