1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 21:34:59 +00:00
Commit graph

72 commits

Author SHA1 Message Date
Lucas CHOLLET
234d084876 LibGfx/TIFF: Add support for bit-depth up to 32 bits per sample
This makes us support every "minisblack" and "rgb-contig" images from
the depth folder of libtiff's test suite:
https://libtiff.gitlab.io/libtiff/images.html
2023-12-09 21:47:33 +01:00
Lucas CHOLLET
2691651abf LibGfx/TIFF: Generated the code to output debug prints
When the `TIFF_DEBUG` flag is set, the TIFF decoder logs every tag and
their values. This is already useful but require the developer to have
the spec handy in order to decrypt each value to its signification. None
of this information is available at runtime, but this is known by the
Python generator. So by generating these debug logs, we drastically
increase their value.

As a bonus point, most of these functions should be useful when we will
display image's metadata in Serenity.
2023-12-07 11:10:55 +01:00
Lucas CHOLLET
1d345109c4 LibGfx/TIFF: Move Formatter<Rational>'s definition to TIFFMetadata.h
This will soon be used in TIFFTagHandler.cpp, so the definition needs to
be shared.
2023-12-07 11:10:55 +01:00
Lucas CHOLLET
da134f6867 LibGfx/TIFF: Add support for grayscale images
Images with a single sample per pixel should be interpreted as
grayscale.
2023-12-07 08:17:46 +00:00
Lucas CHOLLET
ff73d5464a LibGfx/TIFF: Make loop_over_pixels autonomous for reading samples
Let's make the "read a sample" part independent of the decoder. That
will soon allow us to read samples based on the image's parameter
without duplicating the code for every decoder.
2023-12-07 08:17:46 +00:00
Lucas CHOLLET
0a80daef90 LibGfx/TIFF: Don't include the null-byte terminator when reading strings 2023-12-03 20:27:00 +01:00
Lucas CHOLLET
1ede4f249d LibGfx/TIFF: Decode all PackedBits beforehand
This change doesn't change much on its own. The idea behind this
refactoring is to separate the sample reading from the decoding step.
The decoder returning data byte per byte was fine as we only support
8 bits images, but this assumption won't hold for a long time. So let's
decode everything beforehand and strictly partition the sample reading
code somewhere else.
2023-12-02 10:37:07 +01:00
Lucas CHOLLET
4994609af0 LibGfx/TIFF: Add support for the ICCProfile tag 2023-12-02 10:36:02 +01:00
Lucas CHOLLET
62f28d9968 LibGfx/TIFF: Teach the generator how to handle tags of type Undefined
This tag type is a bit different as even if it fits in the general
definition given in the TIFF specification. That is the value will be of
one specified type multiplied by a known count. Having a
`Vector<Variant<u8, ...>>` will be very painful to use. So let's deviate
a bit from the normal way and use a `ByteBuffer` directly instead this
complicated type.
2023-12-02 10:36:02 +01:00
Lucas CHOLLET
e6fc18d96a LibGfx/TIFF: Support TIFF 5.0 LZW images
This makes us decode `quad-lzw.tif` from libtiff's test suite:
https://libtiff.gitlab.io/libtiff/images.html
2023-12-02 08:04:44 +01:00
Lucas CHOLLET
cc816b486c LibGfx/TIFF: Use LZWDecoder::decode_all() 2023-12-01 12:58:14 +01:00
Lucas CHOLLET
9836a9ad0e LibGfx/TIFF: Introduce a code generator
This will allow us to generate code that handle and provide easy access
to metadata stored in TIFF's tags. The generator is a Python script, and
it output both TIFFMetadata.h and TIFFTagHandler.cpp files.

The generator will definitely need some update to support all TIFF and
EXIF tags, but that will still be easier than writing everything
ourselves.

Some small modifications are needed in TIFFLoader.cpp to make it
compatible with the new `Metadata` class.
2023-11-27 09:07:16 -07:00
Lucas CHOLLET
1afdf7f3c7 LibGfx/TIFF: Take the TIFF value by rvalue reference in handle_tag() 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
4ab2903e25 LibGfx/TIFF: Make TIFFLoadingContext::handle_tag be a free function
And move it to another file. This code is going to be generated soon, so
let's put it in another file.
2023-11-18 11:14:37 +00:00
Lucas CHOLLET
34d91dec5b LibGfx/TIFF: Extract metadata-related definition to their own file 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
1d1e7abba7 LibGfx/TIFF: Put the TIFFLoadingContext class in a TIFF namespace 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
b78f93d0b5 LibGfx/TIFF: Put metadata fields in their own struct 2023-11-18 11:14:37 +00:00
Lucas CHOLLET
272be6b20a LibGfx/TIFF: Add support for LZW compression 2023-11-12 13:56:27 +01:00
Lucas CHOLLET
4f5a0227e2 LibGfx/TIFF: Add support for the differencing predictor
The differencing predictor is a different way to encode pixels in TIFF
images. Every pixel is encoded as a difference with the previous column
of the image, except the first column, obviously.

This parameter is materialized by a new tag for which reading was also
implemented.
2023-11-12 13:56:27 +01:00
Lucas CHOLLET
81794df280 LibGfx/TIFF: Add support for images with PackBits compression 2023-11-08 09:28:36 +01:00
Lucas CHOLLET
472a886dfc LibGfx/TIFF: Refactor the decoding loop
This is done to ease the introduction of the support of other
compressions.
2023-11-08 09:28:36 +01:00
Lucas CHOLLET
75caccafa4 LibGfx: Add a TIFF loader 2023-11-06 12:29:30 -07:00