aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/images/SkImageEncoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/images/SkImageEncoder.cpp')
-rw-r--r--src/images/SkImageEncoder.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/images/SkImageEncoder.cpp b/src/images/SkImageEncoder.cpp
index 52ad03283a..7472a02f51 100644
--- a/src/images/SkImageEncoder.cpp
+++ b/src/images/SkImageEncoder.cpp
@@ -79,3 +79,13 @@ bool SkEncoder::encodeRows(int numRows) {
return true;
}
+
+sk_sp<SkData> SkEncodePixmap(const SkPixmap& src, SkEncodedImageFormat format, int quality) {
+ SkDynamicMemoryWStream stream;
+ return SkEncodeImage(&stream, src, format, quality) ? stream.detachAsData() : nullptr;
+}
+
+sk_sp<SkData> SkEncodeBitmap(const SkBitmap& src, SkEncodedImageFormat format, int quality) {
+ SkPixmap pixmap;
+ return src.peekPixels(&pixmap) ? SkEncodePixmap(pixmap, format, quality) : nullptr;
+}