/* * Copyright (c) 2023, Lucas Chollet * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Gfx { struct Metadata; 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, }; ErrorOr handle_tag(Metadata& metadata, u16 tag, Type type, u32 count, Vector&& value); } 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 {}; }; }