Respect SkColorSpace in SkPNGImageEncoder
This only changes behavior when the input SkBitmap/SkPixmap is
tagged with a non-null SkColorSpace. Android tags their bitmaps
as sRGB when linear blending is enabled. So this only changes
behavior in Android when linear blending is turned on.
*If linear blending is turned on, this will do a color correct
encode (which is the desired behavior).
*If linear blending is turned off, this will do a legacy encode.
TODO: Add support for F16.
TODO: Add color space support to WEBP.
TODO: Tag encoded images with ICC profiles (when it makes sense).
BUG=skia:
Change-Id: Idd8a2836371d24a453d953e6fe2e76a87751be96
Reviewed-on: https://skia-review.googlesource.com/6498
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Matt Sarett <msarett@google.com>
diff --git a/src/images/SkImageEncoderPriv.h b/src/images/SkImageEncoderPriv.h
index 22f8f4b..7748204 100644
--- a/src/images/SkImageEncoderPriv.h
+++ b/src/images/SkImageEncoderPriv.h
@@ -10,6 +10,18 @@
#include "SkImageEncoder.h"
+struct SkEncodeOptions {
+ enum class PremulBehavior {
+ // Convert to a linear space before premultiplying or unpremultiplying.
+ kGammaCorrect,
+
+ // Ignore the transfer function when premultiplying or unpremultiplying.
+ kLegacy,
+ };
+
+ PremulBehavior fPremulBehavior = PremulBehavior::kLegacy;
+};
+
#ifdef SK_HAS_JPEG_LIBRARY
bool SkEncodeImageAsJPEG(SkWStream*, const SkPixmap&, int quality);
#else
@@ -17,7 +29,7 @@
#endif
#ifdef SK_HAS_PNG_LIBRARY
- bool SkEncodeImageAsPNG(SkWStream*, const SkPixmap&);
+ bool SkEncodeImageAsPNG(SkWStream*, const SkPixmap&, const SkEncodeOptions&);
#else
#define SkEncodeImageAsPNG(...) false
#endif