Skip to content

Commit

Permalink
Tests/JPEG2000: Add a simple JPEG2000 test
Browse files Browse the repository at this point in the history
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.)

I drew the thes input in Acorn.app and used "Save as..." to save it as
JPEG2000.  It's an RGBA image.
  • Loading branch information
nico committed Mar 23, 2024
1 parent 3bf1d17 commit ca5a4a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Tests/LibGfx/TestImageDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <LibGfx/ImageFormats/ILBMLoader.h>
#include <LibGfx/ImageFormats/ImageDecoder.h>
#include <LibGfx/ImageFormats/JBIG2Loader.h>
#include <LibGfx/ImageFormats/JPEG2000Loader.h>
#include <LibGfx/ImageFormats/JPEGLoader.h>
#include <LibGfx/ImageFormats/JPEGXLLoader.h>
#include <LibGfx/ImageFormats/PAMLoader.h>
Expand Down Expand Up @@ -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)));
Expand Down
Binary file added Tests/LibGfx/test-inputs/jpeg2000/simple.jp2
Binary file not shown.

0 comments on commit ca5a4a4

Please sign in to comment.