#define IMPORT_CORE #include #include #include "../Tests.h" #include "core/Image.h" static void testReadPNG8(const char* path, const char* name, int width, int height, int channels) { char fullPath[512]; snprintf(fullPath, sizeof(fullPath), "%s/%s.png", path, name); CoreImage8 image; CORE_TEST_BOOL(width == 0, coreInitImage8(&image, fullPath)); if(width != 0) { CORE_TEST_NOT_NULL(image.data); } CORE_TEST_INT(width, image.width); CORE_TEST_INT(height, image.height); CORE_TEST_INT(channels, image.channels); coreDestroyImage8(&image); } static void testReadPNG16(const char* path, const char* name, int width, int height, int channels) { char fullPath[512]; snprintf(fullPath, sizeof(fullPath), "%s/%s.png", path, name); CoreImage16 image; CORE_TEST_BOOL(width == 0, coreInitImage16(&image, fullPath)); if(width != 0) { CORE_TEST_NOT_NULL(image.data); } CORE_TEST_INT(width, image.width); CORE_TEST_INT(height, image.height); CORE_TEST_INT(channels, image.channels); coreDestroyImage16(&image); } void coreTestImageReader(const char* path) { testReadPNG8(path, "rgb8", 32, 64, 3); testReadPNG8(path, "rgb16", 32, 64, 3); testReadPNG8(path, "rgba8", 32, 64, 4); testReadPNG8(path, "rgba16", 32, 64, 4); testReadPNG8(path, "gray8", 32, 64, 1); testReadPNG8(path, "gray16", 32, 64, 1); testReadPNG8(path, "graya8", 32, 64, 2); testReadPNG8(path, "graya16", 32, 64, 2); logLevel = LOG_NONE; testReadPNG8(path, "nope", 0, 0, 0); logLevel = LOG_DEBUG; testReadPNG16(path, "rgb8", 32, 64, 3); testReadPNG16(path, "rgb16", 32, 64, 3); testReadPNG16(path, "rgba8", 32, 64, 4); testReadPNG16(path, "rgba16", 32, 64, 4); testReadPNG16(path, "gray8", 32, 64, 1); testReadPNG16(path, "gray16", 32, 64, 1); testReadPNG16(path, "graya8", 32, 64, 2); testReadPNG16(path, "graya16", 32, 64, 2); logLevel = LOG_NONE; testReadPNG16(path, "nope", 0, 0, 0); logLevel = LOG_DEBUG; }