Added the C API for SkBitmapScaler::Resize
authorMatthew Leibowitz <mattleibow@live.com>
Sat, 7 Jan 2017 01:33:31 +0000 (03:33 +0200)
committerMatthew Leibowitz <mattleibow@live.com>
Sat, 7 Jan 2017 01:33:31 +0000 (03:33 +0200)
include/c/sk_pixmap.h
include/c/sk_types.h
src/c/sk_enums.cpp
src/c/sk_pixmap.cpp

index 90bdda3..5ee58ab 100644 (file)
@@ -25,6 +25,8 @@ SK_API size_t sk_pixmap_get_row_bytes(sk_pixmap_t* cpixmap);
 SK_API const void* sk_pixmap_get_pixels(sk_pixmap_t* cpixmap);
 SK_API sk_colortable_t* sk_pixmap_get_colortable(sk_pixmap_t* cpixmap);
 
+SK_API bool sk_bitmapscaler_resize(const sk_pixmap_t* dst, const sk_pixmap_t* src, sk_bitmapscaler_resizemethod_t method);
+
 SK_C_PLUS_PLUS_END_GUARD
 
 #endif
index 9b99299..d32453b 100644 (file)
@@ -546,6 +546,14 @@ typedef struct sk_colortable_t sk_colortable_t;
 typedef struct sk_pixelref_factory_t sk_pixelref_factory_t;
 
 typedef enum {
+    BOX_SK_BITMAP_SCALER_RESIZE_METHOD,
+    TRIANGLE_SK_BITMAP_SCALER_RESIZE_METHOD,
+    LANCZOS3_SK_BITMAP_SCALER_RESIZE_METHOD,
+    HAMMING_SK_BITMAP_SCALER_RESIZE_METHOD,
+    MITCHELL_SK_BITMAP_SCALER_RESIZE_METHOD,
+} sk_bitmapscaler_resizemethod_t;
+
+typedef enum {
     TOP_LEFT_GR_SURFACE_ORIGIN = 1,
     BOTTOM_LEFT_GR_SURFACE_ORIGIN,
 } gr_surfaceorigin_t;
index 8cbb9de..671172a 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "sk_types_priv.h"
 #include "SkShadowMaskFilter.h"
+#include "SkBitmapScaler.h"
 
 #if __cplusplus >= 199711L
 
@@ -289,6 +290,13 @@ static_assert ((int)GrBackendTextureFlags::kRenderTarget_GrBackendTextureFlag
 static_assert ((int)GrBackend::kOpenGL_GrBackend   == (int)OPENGL_GR_BACKEND,   ASSERT_MSG(GrBackend, gr_backend_t));
 static_assert ((int)GrBackend::kVulkan_GrBackend   == (int)VULKAN_GR_BACKEND,   ASSERT_MSG(GrBackend, gr_backend_t));
 
+// sk_bitmapscaler_resizemethod_t
+static_assert ((int)SkBitmapScaler::ResizeMethod::RESIZE_BOX        == (int)BOX_SK_BITMAP_SCALER_RESIZE_METHOD,        ASSERT_MSG(SkBitmapScaler::ResizeMethod, sk_bitmapscaler_resizemethod_t));
+static_assert ((int)SkBitmapScaler::ResizeMethod::RESIZE_TRIANGLE   == (int)TRIANGLE_SK_BITMAP_SCALER_RESIZE_METHOD,   ASSERT_MSG(SkBitmapScaler::ResizeMethod, sk_bitmapscaler_resizemethod_t));
+static_assert ((int)SkBitmapScaler::ResizeMethod::RESIZE_LANCZOS3   == (int)LANCZOS3_SK_BITMAP_SCALER_RESIZE_METHOD,   ASSERT_MSG(SkBitmapScaler::ResizeMethod, sk_bitmapscaler_resizemethod_t));
+static_assert ((int)SkBitmapScaler::ResizeMethod::RESIZE_HAMMING    == (int)HAMMING_SK_BITMAP_SCALER_RESIZE_METHOD,    ASSERT_MSG(SkBitmapScaler::ResizeMethod, sk_bitmapscaler_resizemethod_t));
+static_assert ((int)SkBitmapScaler::ResizeMethod::RESIZE_MITCHELL   == (int)MITCHELL_SK_BITMAP_SCALER_RESIZE_METHOD,   ASSERT_MSG(SkBitmapScaler::ResizeMethod, sk_bitmapscaler_resizemethod_t));
+
 // SkBudgeted
 static_assert ((bool)SkBudgeted::kNo    == (bool)false,   ASSERT_MSG(SkBudgeted, bool));
 static_assert ((bool)SkBudgeted::kYes   == (bool)true,    ASSERT_MSG(SkBudgeted, bool));
index 72d43f6..8a94b4f 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "SkPixmap.h"
+#include "SkBitmapScaler.h"
 
 #include "sk_pixmap.h"
 
@@ -62,3 +63,10 @@ sk_colortable_t* sk_pixmap_get_colortable(sk_pixmap_t* cpixmap)
 {
     return ToColorTable(AsPixmap(cpixmap)->ctable());
 }
+
+bool sk_bitmapscaler_resize(const sk_pixmap_t* cdst, const sk_pixmap_t* csrc, sk_bitmapscaler_resizemethod_t method)
+{
+    const SkPixmap& dst = AsPixmap(*cdst);
+    const SkPixmap& src = AsPixmap(*csrc);
+    return SkBitmapScaler::Resize(dst, src, (SkBitmapScaler::ResizeMethod)method);
+}