diff --git a/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn index f027701b560..b20fcb50216 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibGfx/BUILD.gn @@ -72,6 +72,7 @@ shared_library("LibGfx") { "ImageFormats/ICOLoader.cpp", "ImageFormats/ILBMLoader.cpp", "ImageFormats/ISOBMFF/Boxes.cpp", + "ImageFormats/ISOBMFF/JPEG2000Boxes.cpp", "ImageFormats/ISOBMFF/Reader.cpp", "ImageFormats/ImageDecoder.cpp", "ImageFormats/JBIG2Loader.cpp", diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 1fb695f601a..70228efbc6b 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -46,6 +46,7 @@ set(SOURCES ImageFormats/ILBMLoader.cpp ImageFormats/ImageDecoder.cpp ImageFormats/ISOBMFF/Boxes.cpp + ImageFormats/ISOBMFF/JPEG2000Boxes.cpp ImageFormats/ISOBMFF/Reader.cpp ImageFormats/JBIG2Loader.cpp ImageFormats/JPEGLoader.cpp diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp new file mode 100644 index 00000000000..13764a4c35e --- /dev/null +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024, Nico Weber + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include "JPEG2000Boxes.h" + +namespace Gfx::ISOBMFF { + +ErrorOr JPEG2000SignatureBox::read_from_stream(BoxStream& stream) +{ + signature = TRY(stream.read_value>()); + return {}; +} + +void JPEG2000SignatureBox::dump(String const& prepend) const +{ + Box::dump(prepend); + outln("{}- signature = {:#08x}", prepend, signature); +} + +} diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h new file mode 100644 index 00000000000..511da0823da --- /dev/null +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/JPEG2000Boxes.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024, Nico Weber + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include "Boxes.h" + +namespace Gfx::ISOBMFF { + +struct JPEG2000SignatureBox final : public Box { + BOX_SUBTYPE(JPEG2000SignatureBox); + + u32 signature { 0 }; +}; + +} diff --git a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp index 36ce4b5f1bb..6a66c7de3ed 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/ISOBMFF/Reader.cpp @@ -5,6 +5,8 @@ */ #include "Reader.h" +#include "JPEG2000Boxes.h" +#include namespace Gfx::ISOBMFF { @@ -34,6 +36,9 @@ ErrorOr Reader::read_entire_file() case BoxType::JPEG2000HeaderBox: TRY(top_level_boxes.try_append(TRY(SuperBox::create_from_stream(box_header.type, box_stream)))); break; + case BoxType::JPEG2000SignatureBox: + TRY(top_level_boxes.try_append(TRY(JPEG2000SignatureBox::create_from_stream(box_stream)))); + break; default: TRY(top_level_boxes.try_append(TRY(UnknownBox::create_from_stream(box_header.type, box_stream)))); break;