diff --git a/library/src/main/java/com/bumptech/glide/load/PreferredColorSpace.java b/library/src/main/java/com/bumptech/glide/load/PreferredColorSpace.java index 5e4540ae20..ff346ef6c9 100644 --- a/library/src/main/java/com/bumptech/glide/load/PreferredColorSpace.java +++ b/library/src/main/java/com/bumptech/glide/load/PreferredColorSpace.java @@ -29,8 +29,6 @@ * Bitmap will actually use the requested color space. */ public enum PreferredColorSpace { - /** don't set prefer ColorSpace. */ - NULL, /** Prefers to decode images using {@link android.graphics.ColorSpace.Named#SRGB}. */ SRGB, /** Prefers to decode images using {@link android.graphics.ColorSpace.Named#DISPLAY_P3}. */ diff --git a/library/src/main/java/com/bumptech/glide/load/resource/ImageDecoderResourceDecoder.java b/library/src/main/java/com/bumptech/glide/load/resource/ImageDecoderResourceDecoder.java index 69be855367..63f33a69d0 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/ImageDecoderResourceDecoder.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/ImageDecoderResourceDecoder.java @@ -129,17 +129,18 @@ public boolean onPartialImage(@NonNull DecodeException e) { } decoder.setTargetSize(resizeWidth, resizeHeight); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - boolean isP3Eligible = - preferredColorSpace == PreferredColorSpace.DISPLAY_P3 - && info.getColorSpace() != null - && info.getColorSpace().isWideGamut(); - decoder.setTargetColorSpace( - ColorSpace.get( - isP3Eligible ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB)); - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB)); + if (preferredColorSpace != null) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + boolean isP3Eligible = + preferredColorSpace == PreferredColorSpace.DISPLAY_P3 + && info.getColorSpace() != null + && info.getColorSpace().isWideGamut(); + decoder.setTargetColorSpace( + ColorSpace.get( + isP3Eligible ? ColorSpace.Named.DISPLAY_P3 : ColorSpace.Named.SRGB)); + } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + decoder.setTargetColorSpace(ColorSpace.get(ColorSpace.Named.SRGB)); + } } } }); diff --git a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java index e33e40d090..d30f4a3f73 100644 --- a/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java +++ b/library/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java @@ -62,9 +62,7 @@ public final class Downsampler { * limitations. */ public static final Option PREFERRED_COLOR_SPACE = - Option.memory( - "com.bumptech.glide.load.resource.bitmap.Downsampler.PreferredColorSpace", - PreferredColorSpace.SRGB); + Option.memory("com.bumptech.glide.load.resource.bitmap.Downsampler.PreferredColorSpace"); /** * Indicates the {@link com.bumptech.glide.load.resource.bitmap.DownsampleStrategy} option that * will be used to calculate the sample size to use to downsample an image given the original and @@ -376,7 +374,7 @@ private Bitmap decodeFromWrappedStreams( } } - if (preferredColorSpace != PreferredColorSpace.NULL) { + if (preferredColorSpace != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { boolean isP3Eligible = preferredColorSpace == PreferredColorSpace.DISPLAY_P3