Enum PreferredColorSpace
- java.lang.Object
-
- java.lang.Enum<PreferredColorSpace>
-
- com.bumptech.glide.load.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.outColorSpaceis alsoColorSpace.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_P3is 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 useDISPLAY_P3thinking that you're going to get higher quality by default. Only useDISPLAY_P3if 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_P3can lead to poor color quality and washed out looking images. When in doubt, always useSRGB, which is Glide's default.As with
DecodeFormatwe 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_P3Prefers to decode images usingColorSpace.Named.DISPLAY_P3.SRGBPrefers to decode images usingColorSpace.Named.SRGB.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PreferredColorSpacevalueOf(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.
-
-
-
Enum Constant Detail
-
SRGB
public static final PreferredColorSpace SRGB
Prefers to decode images usingColorSpace.Named.SRGB.
-
DISPLAY_P3
public static final PreferredColorSpace DISPLAY_P3
Prefers to decode images usingColorSpace.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 namejava.lang.NullPointerException- if the argument is null
-
-