Enum PreferredColorSpace

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<PreferredColorSpace>

    public enum PreferredColorSpace
    extends java.lang.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 Summary

      Enum Constants 
      Enum Constant Description
      DISPLAY_P3
      Prefers to decode images using ColorSpace.Named.DISPLAY_P3.
      SRGB
      Prefers to decode images using ColorSpace.Named.SRGB.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static PreferredColorSpace valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static PreferredColorSpace[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • SRGB

        public static final PreferredColorSpace SRGB
        Prefers to decode images using ColorSpace.Named.SRGB.
      • DISPLAY_P3

        public static final PreferredColorSpace DISPLAY_P3
        Prefers to decode images using ColorSpace.Named.DISPLAY_P3.
    • Method Detail

      • values

        public static PreferredColorSpace[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (PreferredColorSpace c : PreferredColorSpace.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static PreferredColorSpace valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null