MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / test_float

Function test_float

engine/3rdparty/stb/tests/resample_test.cpp:271–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

269}
270
271void test_float(const char* file, float width_percent, float height_percent, stbir_datatype type, stbir_colorspace colorspace)
272{
273 int w, h, n;
274 unsigned char* input_data = stbi_load(file, &w, &h, &n, 0);
275
276 if (input_data == NULL)
277 return;
278
279 int new_w = (int)(w * width_percent);
280 int new_h = (int)(h * height_percent);
281
282 float* T_data = (float*)malloc(w * h * n * sizeof(float));
283 convert_image_float(input_data, T_data, w * h * n);
284
285 float* output_data = (float*)malloc(new_w * new_h * n * sizeof(float));
286
287 stbir_resize_float_generic(T_data, w, h, 0, output_data, new_w, new_h, 0, n, STBIR_ALPHA_CHANNEL_NONE, 0, STBIR_EDGE_CLAMP, STBIR_FILTER_CATMULLROM, colorspace, &g_context);
288
289 free(T_data);
290 stbi_image_free(input_data);
291
292 unsigned char* char_data = (unsigned char*)malloc(new_w * new_h * n * sizeof(char));
293 convert_image_float(output_data, char_data, new_w * new_h * n);
294
295 char output[200];
296 sprintf(output, "test-output/type-%d-%d-%d-%d-%s", type, colorspace, new_w, new_h, file);
297 stbi_write_png(output, new_w, new_h, n, char_data, 0);
298
299 free(char_data);
300 free(output_data);
301}
302
303void test_channels(const char* file, float width_percent, float height_percent, int channels)
304{

Callers 1

test_suiteFunction · 0.85

Calls 6

convert_image_floatFunction · 0.85
sprintfFunction · 0.85
stbi_loadFunction · 0.50
stbi_image_freeFunction · 0.50
stbi_write_pngFunction · 0.50

Tested by

no test coverage detected