Enum Class PreferredColorSpace

java.lang.Object
java.lang.Enum<PreferredColorSpace>
com.bumptech.glide.load.PreferredColorSpace
All Implemented Interfaces:
Serializable, Comparable<PreferredColorSpace>, java.lang.constant.Constable

public enum PreferredColorSpace extends Enum<PreferredColorSpace>
Glide's supported handling of color spaces on Android O+, defaults to null.

On Android O, Glide will always request SRGB and will ignore this option if set. A bug on Android O prevents P3 images from being compressed correctly and can result in color distortion. We may eventually work around this in Glide if sufficient demand arises, but doing so will require a memory intensive conversion to SRGB prior to compressing Bitmaps to Glide's disk cache. This work around would also work only for Glide's compression, not for any compression that a caller performs on a Bitmap returned by Glide.

On Android P+, Glide supports SRGB and display P3. However, if display p3 is requested, we will still decode to SRGB unless BitmapFactory.Options.outColorSpace is also ColorSpace.Named.DISPLAY_P3. Preferring P3 for SRGB images adds unnecessary CPU work to convert back and forth between the color spaces at decode time.

Using DISPLAY_P3 is wasteful if either the screen or the renderer do not support P3. Currently Glide does not attempt to detect whether or not this support is present. Do not use DISPLAY_P3 thinking that you're going to get higher quality by default. Only use DISPLAY_P3 if you're confident you understand color spaces, your application is working with a display that supports wide gamut and you've set the appropriate options to render wide gamut colors. If you've missed one or more of these steps, DISPLAY_P3 can lead to poor color quality and washed out looking images. When in doubt, always use SRGB, which is Glide's default.

As with DecodeFormat we cannot directly set color spaces, we can only suggest to the framework which one we want. Setting one of these values is not a guarantee that any returned Bitmap will actually use the requested color space.

  • Enum Constant Details

  • Method Details

    • values

      public static PreferredColorSpace[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static PreferredColorSpace valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null