|
|
|
@ -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; |
|
|
|
|