From 4b0bfe18dad276200bdd2ff43fc084da38e76d02 Mon Sep 17 00:00:00 2001 From: Matthew Leibowitz Date: Sat, 7 Jan 2017 03:33:31 +0200 Subject: [PATCH] Added the C API for SkBitmapScaler::Resize --- include/c/sk_pixmap.h | 2 ++ include/c/sk_types.h | 8 ++++++++ src/c/sk_enums.cpp | 8 ++++++++ src/c/sk_pixmap.cpp | 8 ++++++++ 4 files changed, 26 insertions(+) diff --git a/include/c/sk_pixmap.h b/include/c/sk_pixmap.h index 90bdda3..5ee58ab 100644 --- a/include/c/sk_pixmap.h +++ b/include/c/sk_pixmap.h @@ -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 diff --git a/include/c/sk_types.h b/include/c/sk_types.h index 9b99299..d32453b 100644 --- a/include/c/sk_types.h +++ b/include/c/sk_types.h @@ -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; diff --git a/src/c/sk_enums.cpp b/src/c/sk_enums.cpp index 8cbb9de..671172a 100644 --- a/src/c/sk_enums.cpp +++ b/src/c/sk_enums.cpp @@ -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)); diff --git a/src/c/sk_pixmap.cpp b/src/c/sk_pixmap.cpp index 72d43f6..8a94b4f 100644 --- a/src/c/sk_pixmap.cpp +++ b/src/c/sk_pixmap.cpp @@ -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); +} -- 2.7.4