diff --git a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp index c77c41ffbf..4bc57c553e 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace Gfx { @@ -23,13 +24,6 @@ public: FrameDecoded, }; - template x32> - struct Rational { - using Type = x32; - x32 numerator; - x32 denominator; - }; - TIFFLoadingContext(NonnullOwnPtr stream) : m_stream(move(stream)) { @@ -77,49 +71,6 @@ private: BigEndian, }; - enum class Type { - Byte = 1, - ASCII = 2, - UnsignedShort = 3, - UnsignedLong = 4, - UnsignedRational = 5, - Undefined = 7, - SignedLong = 9, - SignedRational = 10, - Float = 11, - Double = 12, - UTF8 = 129, - }; - - using Value = Variant, i32, Rational>; - - // This enum is progessively defined across sections but summarized in: - // Appendix A: TIFF Tags Sorted by Number - enum class Compression { - NoCompression = 1, - CCITT = 2, - Group3Fax = 3, - Group4Fax = 4, - LZW = 5, - JPEG = 6, - PackBits = 32773, - }; - - enum class Predictor { - None = 1, - HorizontalDifferencing = 2, - }; - - struct Metadata { - IntSize size {}; - Array bits_per_sample {}; - Compression compression {}; - Predictor predictor {}; - Vector strip_offsets {}; - u32 rows_per_strip {}; - Vector strip_bytes_count {}; - }; - template ErrorOr loop_over_pixels(ByteReader&& byte_reader, Function(u32)> initializer = {}) { @@ -677,8 +628,8 @@ ErrorOr TIFFImageDecoderPlugin::frame(size_t index, Option } template -struct AK::Formatter> : Formatter { - ErrorOr format(FormatBuilder& builder, Gfx::TIFF::TIFFLoadingContext::Rational value) +struct AK::Formatter> : Formatter { + ErrorOr format(FormatBuilder& builder, Gfx::TIFF::Rational value) { return Formatter::format(builder, "{} ({}/{})"sv, static_cast(value.numerator) / value.denominator, value.numerator, value.denominator); } diff --git a/Userland/Libraries/LibGfx/ImageFormats/TIFFMetadata.h b/Userland/Libraries/LibGfx/ImageFormats/TIFFMetadata.h new file mode 100644 index 0000000000..f98fb620d7 --- /dev/null +++ b/Userland/Libraries/LibGfx/ImageFormats/TIFFMetadata.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2023, Lucas Chollet + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include + +namespace Gfx { + +namespace TIFF { + +enum class Type { + Byte = 1, + ASCII = 2, + UnsignedShort = 3, + UnsignedLong = 4, + UnsignedRational = 5, + Undefined = 7, + SignedLong = 9, + SignedRational = 10, + Float = 11, + Double = 12, + UTF8 = 129, +}; + +template x32> +struct Rational { + using Type = x32; + x32 numerator; + x32 denominator; +}; + +using Value = Variant, i32, Rational>; + +// This enum is progessively defined across sections but summarized in: +// Appendix A: TIFF Tags Sorted by Number +enum class Compression { + NoCompression = 1, + CCITT = 2, + Group3Fax = 3, + Group4Fax = 4, + LZW = 5, + JPEG = 6, + PackBits = 32773, +}; + +enum class Predictor { + None = 1, + HorizontalDifferencing = 2, +}; + +} + +struct Metadata { + IntSize size {}; + Array bits_per_sample {}; + TIFF::Compression compression {}; + TIFF::Predictor predictor {}; + Vector strip_offsets {}; + u32 rows_per_strip {}; + Vector strip_bytes_count {}; +}; + +}