From a1cd6e8a281afca1fdadf655e4b6780e8384376b Mon Sep 17 00:00:00 2001 From: TazyFoundSoup Date: Wed, 15 Apr 2026 17:34:29 +1000 Subject: feat(tests/png): Add lenna256 test for png --- tests/format/image/png/assets/lenna256.png | Bin 0 -> 473831 bytes tests/format/image/png/png_open.c | 34 ++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 tests/format/image/png/assets/lenna256.png (limited to 'tests') diff --git a/tests/format/image/png/assets/lenna256.png b/tests/format/image/png/assets/lenna256.png new file mode 100644 index 0000000..59ef68a Binary files /dev/null and b/tests/format/image/png/assets/lenna256.png differ diff --git a/tests/format/image/png/png_open.c b/tests/format/image/png/png_open.c index a01a75b..97392fb 100644 --- a/tests/format/image/png/png_open.c +++ b/tests/format/image/png/png_open.c @@ -21,6 +21,23 @@ ff_result fftest_rgb2x2(ff_ctx* ctx) { return res; } +ff_result fftest_lenna256(ff_ctx* ctx) { + FILE* file = fopen("tests/format/image/png/assets/lenna256.png", "rb"); + if (!file) { + printf("file failed to open\n"); + return FF_RESULT_ERROR_INVALID_FILE; + } + + ff_stream stream = ff_create_file_stream(file); + + ff_png_ctx* png_ctx = NULL; + ff_result res = ff_open_png(ctx, &stream, &png_ctx, FF_ENABLE); + + fclose(file); + ff_close_png(ctx, png_ctx); + return res; +} + int main() { ff_allocator alloc = { malloc, free, calloc }; ff_ctx* ctx = ff_init(&alloc); @@ -28,14 +45,25 @@ int main() { ff_stream out = ff_create_file_stream(stdout); ff_set_debug_stream(&out, ctx); + + // rgb2x2 ff_result res = fftest_rgb2x2(ctx); if (res == FF_RESULT_OK) { - printf("Works!\n"); + printf("rgb2x2: Works!\n"); } else { - printf("Doesn't work :(\n"); + printf("rgb2x2: Doesn't work :(\n"); } - + + + // lenna256 + res = fftest_lenna256(ctx); + if (res == FF_RESULT_OK) { + printf("lenna256: Works!\n"); + } else { + printf("lenna256: Doesn't work :(\n"); + } + ff_cleanup(ctx); return 0; -- cgit v1.2.3