mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
LibGfx: Use libjxl to decode JPEG XL images
It currently doesn't support animated image. Note that Gfx::Bitmap has no support for get_pixel when the format is RGBA8888. This is why it has been removed from the tests.
This commit is contained in:
parent
d417b75683
commit
1039561280
Notes:
github-actions[bot]
2024-07-22 07:16:05 +00:00
Author: https://github.com/LucasChollet Commit: https://github.com/LadybirdBrowser/ladybird/commit/10395612807 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/756
6 changed files with 124 additions and 2652 deletions
|
@ -986,27 +986,6 @@ TEST_CASE(test_jxl_modular_simple_tree_upsample2_10bits)
|
||||||
TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 128, 128 }));
|
TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 128, 128 }));
|
||||||
|
|
||||||
auto frame = TRY_OR_FAIL(plugin_decoder->frame(0));
|
auto frame = TRY_OR_FAIL(plugin_decoder->frame(0));
|
||||||
EXPECT_EQ(frame.image->get_pixel(42, 57), Gfx::Color::from_string("#4c0072"sv));
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE(test_jxl_modular_property_8)
|
|
||||||
{
|
|
||||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("jxl/modular_property_8.jxl"sv)));
|
|
||||||
EXPECT(Gfx::JPEGXLImageDecoderPlugin::sniff(file->bytes()));
|
|
||||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::JPEGXLImageDecoderPlugin::create(file->bytes()));
|
|
||||||
|
|
||||||
TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 32, 32 }));
|
|
||||||
|
|
||||||
auto frame = TRY_OR_FAIL(plugin_decoder->frame(0));
|
|
||||||
for (u8 i = 0; i < 32; ++i) {
|
|
||||||
for (u8 j = 0; j < 32; ++j) {
|
|
||||||
auto const color = frame.image->get_pixel(i, j);
|
|
||||||
if ((i + j) % 2 == 0)
|
|
||||||
EXPECT_EQ(color, Gfx::Color::Black);
|
|
||||||
else
|
|
||||||
EXPECT_EQ(color, Gfx::Color::Yellow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(test_avif_simple_lossy)
|
TEST_CASE(test_avif_simple_lossy)
|
||||||
|
|
Binary file not shown.
|
@ -93,6 +93,7 @@ find_package(JPEG REQUIRED)
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
find_package(LIBAVIF REQUIRED)
|
find_package(LIBAVIF REQUIRED)
|
||||||
find_package(WebP REQUIRED)
|
find_package(WebP REQUIRED)
|
||||||
|
pkg_check_modules(Jxl REQUIRED IMPORTED_TARGET libjxl)
|
||||||
|
|
||||||
target_link_libraries(LibGfx PRIVATE PkgConfig::WOFF2 JPEG::JPEG PNG::PNG avif WebP::webp WebP::webpdecoder
|
target_link_libraries(LibGfx PRIVATE PkgConfig::WOFF2 JPEG::JPEG PkgConfig::Jxl PNG::PNG avif WebP::webp WebP::webpdecoder
|
||||||
WebP::webpdemux WebP::libwebpmux)
|
WebP::webpdemux WebP::libwebpmux)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2023, Lucas Chollet <lucas.chollet@serenityos.org>
|
* Copyright (c) 2023-2024, Lucas Chollet <lucas.chollet@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +30,7 @@ public:
|
||||||
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) override;
|
virtual ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JPEGXLImageDecoderPlugin(NonnullOwnPtr<FixedMemoryStream>);
|
JPEGXLImageDecoderPlugin(OwnPtr<JPEGXLLoadingContext>);
|
||||||
|
|
||||||
OwnPtr<JPEGXLLoadingContext> m_context;
|
OwnPtr<JPEGXLLoadingContext> m_context;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
},
|
},
|
||||||
"icu",
|
"icu",
|
||||||
"libjpeg-turbo",
|
"libjpeg-turbo",
|
||||||
|
"libjxl",
|
||||||
{
|
{
|
||||||
"name": "libpng",
|
"name": "libpng",
|
||||||
"features": [
|
"features": [
|
||||||
|
@ -70,6 +71,10 @@
|
||||||
"name": "libjpeg-turbo",
|
"name": "libjpeg-turbo",
|
||||||
"version": "3.0.2"
|
"version": "3.0.2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "libjxl",
|
||||||
|
"version": "0.10.2"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "libpng",
|
"name": "libpng",
|
||||||
"version": "1.6.43#1"
|
"version": "1.6.43#1"
|
||||||
|
|
Loading…
Reference in a new issue