diff options
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkImageEncoder.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/include/core/SkImageEncoder.h b/include/core/SkImageEncoder.h index 87d5170c69..a6d7cb8c68 100644 --- a/include/core/SkImageEncoder.h +++ b/include/core/SkImageEncoder.h @@ -9,6 +9,7 @@ #define SkImageEncoder_DEFINED #include "SkBitmap.h" +#include "SkData.h" #include "SkEncodedImageFormat.h" #include "SkStream.h" @@ -33,6 +34,7 @@ */ SK_API bool SkEncodeImage(SkWStream* dst, const SkPixmap& src, SkEncodedImageFormat format, int quality); + /** * The following helper function wraps SkEncodeImage(). */ @@ -41,4 +43,26 @@ inline bool SkEncodeImage(SkWStream* dst, const SkBitmap& src, SkEncodedImageFor return src.peekPixels(&pixmap) && SkEncodeImage(dst, pixmap, f, q); } +/** + * Encode SkPixmap in the given binary image format. + * + * @param src source pixels. + * @param format image format, not all formats are supported. + * @param quality range from 0-100, this is supported by jpeg and webp. + * higher values correspond to improved visual quality, but less compression. + * + * @return encoded data or nullptr if input is bad or format is unsupported. + * + * Will always return nullptr if Skia is compiled without image + * encoders. + * + * Note that webp encodes will use webp lossy compression. + */ +SK_API sk_sp<SkData> SkEncodePixmap(const SkPixmap& src, SkEncodedImageFormat format, int quality); + +/** + * Helper that extracts the pixmap from the bitmap, and then calls SkEncodePixmap() + */ +SK_API sk_sp<SkData> SkEncodeBitmap(const SkBitmap& src, SkEncodedImageFormat format, int quality); + #endif // SkImageEncoder_DEFINED |