From 7501fa8719f6ebbe33cc9bfb84f45a0ec36a2508 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 22 Mar 2024 18:59:28 -0400 Subject: [PATCH] Tests/JPEG2000: Add a simple JPEG2000 test We can't decode any actual image data yet, but it shows that we can read the basics of the container format. (...as long as there's an Annex I container around the data, not just an Annex A codestream. All files I've found so far have the container.) --- Tests/LibGfx/TestImageDecoder.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 54a3f7366fec3f8..f000a7abe31cbca 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -550,6 +551,15 @@ TEST_CASE(test_jpeg_malformed_frame) } } +TEST_CASE(test_jpeg2000_simple) +{ + auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("jpeg2000/simple.jp2"sv))); + EXPECT(Gfx::JPEG2000ImageDecoderPlugin::sniff(file->bytes())); + auto plugin_decoder = TRY_OR_FAIL(Gfx::JPEG2000ImageDecoderPlugin::create(file->bytes())); + + EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(119, 101)); +} + TEST_CASE(test_pam_rgb) { auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("pnm/2x1.pam"sv)));