mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-14 20:03:29 +00:00
Tests: Add a basic ICC profile test
icc-v4.jpg is Meta/Websites/serenityos.org/happy/3rd/bgianf.jpg. There are a whole bunch of jpgs with v4 color profiles and I just picked one fairly arbitrarily. It looks like a fairly standard v4 matrix profile that in this form is also present in many jpgs taken by mobile phone cameras. It uses parametric curves. icc-v2.png is based on ./Documentation/WebServer_localhost.jpg since that is the only image in the repo with a v2 color profile. It also has all kinds of interesting and somewhat exotic tags, such as an 'dscm' (an Apple extension to have a description of type 'mluc', since normal 'desc' is required ot have type 'desc' in v2 files -- in v4, 'desc' has type 'mluc') tag of type 'mluc' that actually contains data in several languages and that exercises the non-BMP UTF-16BE decoder. It's however still also a fairly standard v2 matrix profile, which uses 'curv' instead of 'para' for its curves ('para' is v4-only). I converted that jpeg file to png, and cropped most of the image data to save on file size by running: sips -s format png --cropToHeightWidth 21 42 in.jpg --out out.png
This commit is contained in:
parent
d43b306814
commit
fb79fc0ba6
|
@ -1,6 +1,7 @@
|
||||||
set(TEST_SOURCES
|
set(TEST_SOURCES
|
||||||
BenchmarkGfxPainter.cpp
|
BenchmarkGfxPainter.cpp
|
||||||
TestFontHandling.cpp
|
TestFontHandling.cpp
|
||||||
|
TestICCProfile.cpp
|
||||||
TestImageDecoder.cpp
|
TestImageDecoder.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
41
Tests/LibGfx/TestICCProfile.cpp
Normal file
41
Tests/LibGfx/TestICCProfile.cpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023, Nico Weber <thakis@chromium.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibCore/MappedFile.h>
|
||||||
|
#include <LibGfx/ICC/Profile.h>
|
||||||
|
#include <LibGfx/JPGLoader.h>
|
||||||
|
#include <LibGfx/PNGLoader.h>
|
||||||
|
#include <LibTest/TestCase.h>
|
||||||
|
|
||||||
|
#ifdef AK_OS_SERENITY
|
||||||
|
# define TEST_INPUT(x) ("/usr/Tests/LibGfx/test-inputs/" x)
|
||||||
|
#else
|
||||||
|
# define TEST_INPUT(x) ("test-inputs/" x)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TEST_CASE(png)
|
||||||
|
{
|
||||||
|
auto file = MUST(Core::MappedFile::map(TEST_INPUT("icc-v2.png"sv)));
|
||||||
|
auto png = MUST(Gfx::PNGImageDecoderPlugin::create(file->bytes()));
|
||||||
|
EXPECT(png->initialize());
|
||||||
|
auto icc_bytes = MUST(png->icc_data());
|
||||||
|
EXPECT(icc_bytes.has_value());
|
||||||
|
|
||||||
|
auto icc_profile = MUST(Gfx::ICC::Profile::try_load_from_externally_owned_memory(icc_bytes.value()));
|
||||||
|
EXPECT(icc_profile->is_v2());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE(jpg)
|
||||||
|
{
|
||||||
|
auto file = MUST(Core::MappedFile::map(TEST_INPUT("icc-v4.jpg"sv)));
|
||||||
|
auto jpg = MUST(Gfx::JPGImageDecoderPlugin::create(file->bytes()));
|
||||||
|
EXPECT(jpg->initialize());
|
||||||
|
auto icc_bytes = MUST(jpg->icc_data());
|
||||||
|
EXPECT(icc_bytes.has_value());
|
||||||
|
|
||||||
|
auto icc_profile = MUST(Gfx::ICC::Profile::try_load_from_externally_owned_memory(icc_bytes.value()));
|
||||||
|
EXPECT(icc_profile->is_v4());
|
||||||
|
}
|
BIN
Tests/LibGfx/test-inputs/icc-v2.png
Normal file
BIN
Tests/LibGfx/test-inputs/icc-v2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
BIN
Tests/LibGfx/test-inputs/icc-v4.jpg
Normal file
BIN
Tests/LibGfx/test-inputs/icc-v4.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
Loading…
Reference in a new issue