From 06b7b00696ad5ad20c8f672d5f1122a083ab7340 Mon Sep 17 00:00:00 2001 From: Jorge Rodriguez Date: Mon, 21 Jul 2014 16:14:32 -0700 Subject: [PATCH] It does nothing now but I want to support edge behavior in the future. --- stb_resample.h | 11 ++++++++--- tests/resample_test.c | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/stb_resample.h b/stb_resample.h index 684d199..b7b1680 100644 --- a/stb_resample.h +++ b/stb_resample.h @@ -18,7 +18,7 @@ Initial implementation by Jorge L Rodriguez #define STBR_INCLUDE_STB_RESAMPLE_H // Basic usage: -// result = stbr_resize(input_data, input_w, input_h, input_components, STBR_FILTER_NEAREST, output_data, output_w, output_h); +// result = stbr_resize(input_data, input_w, input_h, input_components, output_data, output_w, output_h, STBR_FILTER_NEAREST, STBR_EDGE_CLAMP); // // input_data is your supplied texels. // output_data will be the resized texels. It should be of size output_w * output_h * input_components. @@ -29,6 +29,11 @@ typedef enum STBR_FILTER_NEAREST = 1, } stbr_filter; +typedef enum +{ + STBR_EDGE_CLAMP = 1, +} stbr_edge; + typedef unsigned char stbr_uc; @@ -47,7 +52,7 @@ extern "C" { // PRIMARY API - resize an image // - STBRDEF int stbr_resize(const stbr_uc* input_data, int input_w, int input_h, int input_components, stbr_filter filter, stbr_uc* output_data, int output_w, int output_h); + STBRDEF int stbr_resize(const stbr_uc* input_data, int input_w, int input_h, int input_components, stbr_uc* output_data, int output_w, int output_h, stbr_filter filter, stbr_edge edge); #ifdef __cplusplus @@ -154,7 +159,7 @@ static void stbr__filter_nearest_n(const stbr_uc* input_data, stbr_uc* output_da typedef void (stbr__filter_fn)(const stbr_uc* input_data, stbr_uc* output_data, size_t input_texel_index, size_t output_texel_index, size_t n); -STBRDEF int stbr_resize(const stbr_uc* input_data, int input_w, int input_h, int input_components, stbr_filter filter, stbr_uc* output_data, int output_w, int output_h) +STBRDEF int stbr_resize(const stbr_uc* input_data, int input_w, int input_h, int input_components, stbr_uc* output_data, int output_w, int output_h, stbr_filter filter, stbr_edge edge) { int x, y; int width_stride_input = input_components * input_w; diff --git a/tests/resample_test.c b/tests/resample_test.c index 7d5b0eb..2c775c6 100644 --- a/tests/resample_test.c +++ b/tests/resample_test.c @@ -39,7 +39,7 @@ int main(int argc, char** argv) output_data = malloc(out_w * out_h * n); - stbr_resize(input_data, w, h, n, STBR_FILTER_NEAREST, output_data, out_w, out_h); + stbr_resize(input_data, w, h, n, output_data, out_w, out_h, STBR_FILTER_NEAREST, STBR_EDGE_CLAMP); stbi_write_png("output.png", out_w, out_h, n, output_data, out_w * n);