Bindings for encoding the pixels under a pixmap
authorMatthew Leibowitz <mattleibow@live.com>
Tue, 21 Mar 2017 14:56:59 +0000 (10:56 -0400)
committerMatthew Leibowitz <mattleibow@live.com>
Tue, 21 Mar 2017 14:56:59 +0000 (10:56 -0400)
include/c/sk_pixmap.h
src/c/sk_pixmap.cpp

index 5cb7c33..ed905ea 100644 (file)
@@ -33,6 +33,8 @@ SK_C_API void sk_color_unpremultiply_array(const sk_pmcolor_t* pmcolors, int siz
 SK_C_API void sk_color_premultiply_array(const sk_color_t* colors, int size, sk_pmcolor_t* pmcolors);
 SK_C_API void sk_color_get_bit_shift(int* a, int* r, int* g, int* b);
 
+SK_C_API bool sk_pixmap_encode_image(sk_wstream_t* dst, const sk_pixmap_t* src, sk_encoded_image_format_t encoder, int quality);
+
 SK_C_PLUS_PLUS_END_GUARD
 
 #endif
index 743a320..d7fe298 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "SkPixmap.h"
 #include "SkBitmapScaler.h"
+#include "SkImageEncoder.h"
 
 #include "sk_pixmap.h"
 
@@ -95,9 +96,15 @@ void sk_color_premultiply_array(const sk_color_t* colors, int size, sk_pmcolor_t
     }
 }
 
-void sk_color_get_bit_shift(int* a, int* r, int* g, int* b) {
+void sk_color_get_bit_shift(int* a, int* r, int* g, int* b)
+{
     *a = (int)SK_A32_SHIFT;
     *r = (int)SK_R32_SHIFT;
     *g = (int)SK_G32_SHIFT;
     *b = (int)SK_B32_SHIFT;
 }
+
+bool sk_pixmap_encode_image(sk_wstream_t* dst, const sk_pixmap_t* src, sk_encoded_image_format_t encoder, int quality)
+{
+    return SkEncodeImage(AsWStream(dst), AsPixmap(*src), (SkEncodedImageFormat)encoder, quality);
+}