If there's no context we're using the simple API functions - fall back to malloc and free.

This commit is contained in:
Jorge Rodriguez 2014-09-07 10:02:51 -07:00
parent 36db03f390
commit 8cc6a3abfc

View File

@ -33,7 +33,7 @@ public:
void* stbir_malloc(void* context, size_t size)
{
if (!context)
return 0;
return malloc(size);
stbir_context* real_context = (stbir_context*)context;
if (size > real_context->size)
@ -44,6 +44,8 @@ void* stbir_malloc(void* context, size_t size)
void stbir_free(void* context, void* memory)
{
if (!context)
return free(memory);
}
void stbir_progress(float p)
@ -645,6 +647,19 @@ void test_suite(int argc, char **argv)
}
#endif
/*resize_image("white-stripes.png", 0.5f, 0.5f, STBIR_FILTER_BOX, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-50-nearest.png");
resize_image("white-stripes.png", 0.5f, 0.5f, STBIR_FILTER_BILINEAR, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-50-bilinear.png");
resize_image("white-stripes.png", 0.5f, 0.5f, STBIR_FILTER_BICUBIC, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-50-bicubic.png");
resize_image("white-stripes.png", 0.5f, 0.5f, STBIR_FILTER_MITCHELL, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-50-mitchell.png");
resize_image("white-stripes.png", 0.5f, 0.5f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-50-catmullrom.png");
resize_image("white-stripes.png", 0.25f, 0.25f, STBIR_FILTER_BOX, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-25-nearest.png");
resize_image("white-stripes.png", 0.25f, 0.25f, STBIR_FILTER_BILINEAR, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-25-bilinear.png");
resize_image("white-stripes.png", 0.25f, 0.25f, STBIR_FILTER_BICUBIC, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-25-bicubic.png");
resize_image("white-stripes.png", 0.25f, 0.25f, STBIR_FILTER_MITCHELL, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-25-mitchell.png");
resize_image("white-stripes.png", 0.25f, 0.25f, STBIR_FILTER_CATMULLROM, STBIR_EDGE_WRAP, STBIR_COLORSPACE_LINEAR, "test-output/white-stripes-down-25-catmullrom.png");
return;*/
test_filters();
test_subpixel_1();