aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/core/SkImage.h6
-rw-r--r--include/core/SkPixelSerializer.h4
-rw-r--r--src/image/SkImage.cpp15
3 files changed, 25 insertions, 0 deletions
diff --git a/include/core/SkImage.h b/include/core/SkImage.h
index f63ba41fea..862dc6691e 100644
--- a/include/core/SkImage.h
+++ b/include/core/SkImage.h
@@ -390,6 +390,12 @@ public:
*/
sk_sp<SkData> refEncodedData() const;
+#ifdef SK_SUPPORT_LEGACY_IMAGE_ENCODE_API
+ SkData* encode(SkEncodedImageFormat, int quality) const;
+ SkData* encode(SkPixelSerializer* = nullptr) const;
+ SkData* refEncoded() const;
+#endif
+
const char* toString(SkString*) const;
/**
diff --git a/include/core/SkPixelSerializer.h b/include/core/SkPixelSerializer.h
index 28d5f5d2e6..c3cbc0ad01 100644
--- a/include/core/SkPixelSerializer.h
+++ b/include/core/SkPixelSerializer.h
@@ -35,6 +35,10 @@ public:
return sk_sp<SkData>(this->onEncode(pixmap));
}
+#ifdef SK_SUPPORT_LEGACY_IMAGE_ENCODE_API
+ SkData* encode(const SkPixmap& pixmap);
+#endif
+
protected:
/**
* Return true if you want to serialize the encoded data, false if you want
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 841e83cc2b..8cb526746c 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -138,6 +138,21 @@ sk_sp<SkImage> SkImage::MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* su
return SkImage::MakeFromGenerator(SkImageGenerator::MakeFromEncoded(encoded), subset);
}
+#ifdef SK_SUPPORT_LEGACY_IMAGE_ENCODE_API
+SkData* SkImage::encode(SkEncodedImageFormat format, int quality) const {
+ return this->encodeToData(format, quality).release();
+}
+SkData* SkImage::encode(SkPixelSerializer* serial) const {
+ return this->encodeToData(serial).release();
+}
+SkData* SkImage::refEncoded() const {
+ return this->refEncodedData().release();
+}
+SkData* SkPixelSerializer::encode(const SkPixmap& pixmap) {
+ return this->encodeToData(pixmap).release();
+}
+#endif
+
///////////////////////////////////////////////////////////////////////////////////////////////////
const char* SkImage::toString(SkString* str) const {