Commit graph

29 commits

Author SHA1 Message Date
Nico Weber
9bd7048519 LibGfx: Move ICC TagTableEntry to BinaryFormat.h 2023-02-19 00:01:44 +01:00
Nico Weber
0ca620a286 LibGfx: Move ICC ProfileFileSignature into a constant in BinaryFormat.h
...so that it can be used by ICC writing code too.
2023-02-17 20:05:50 -07:00
Nico Weber
78d849bce2 LibGfx: Make ICCHeader use RenderingIntent enum
No behavior change.
2023-02-17 20:05:50 -07:00
Nico Weber
429467f46c LibGfx: Move ICC on-disk structs to new BinaryFormat.h
Removes some existing code duplication and allows future files to use
these structs too.
2023-02-17 20:05:50 -07:00
Nico Weber
9ba3c8e36d LibGfx: Move ICC::Profile towards "Fallible Constructors" pattern
Not quite there yet due to check_required_tags() / check_tag_types(),
but getting closer :^)
2023-02-15 10:15:24 +01:00
Nico Weber
db614b47dd LibGfx: Move ICC::Profile::read_header() out of class
This one is slightly more involved: To make it nice, extract
all the Profile fields that belong to the header into a separate
struct.
2023-02-15 10:15:24 +01:00
Nico Weber
272e5321e3 LibGfx: Move ICC::Profile::read_tag_table() out of class 2023-02-15 10:15:24 +01:00
Nico Weber
006dff6878 LibGfx: Move ICC::Profile::read_tag() out of class 2023-02-15 10:15:24 +01:00
Nico Weber
1c259b7a5a LibGfx: Validate ICC namedColor2Tag consistency 2023-02-14 19:28:13 +01:00
Nico Weber
45e391dae9 LibGfx: Add v2 "ncol" tag, expand comment
I had missed this in 21cc0c0cb2 because this tag is missing in
"Table 32 — Tag list" in the v2 ICC spec O_o. But it's in
"6.4.26 namedColorTag".

Also add a comment pointing to a page saying that all these tags
are very deprecated and not even recommended for new v2 profiles.
(That's how I noticed that namedColorTag was missing.)
2023-02-14 19:28:13 +01:00
Nico Weber
7e915b145b LibGfx: Let ICC code validate tag data alignment
Both when reading the main tag table and when reading embedded
curve data in lutAToBType or lutBToAType.
2023-02-12 20:07:45 +00:00
Nico Weber
cf73e15dc1 LibGfx: Make ICC code handle out-of-memory situations better
...by using adopt_nonnull_ref_or_enomem() via the try_make_ref_counted()
wrapper, instead of adopt_ref().
2023-02-11 10:02:24 +01:00
Nico Weber
4eebe753d1 LibGfx: Validate ICC cicpTag some more 2023-02-10 17:06:40 +00:00
Nico Weber
b232281d15 LibGfx+icc: Read chromaticityTag
This isn't terribly useful. But some profiles, for example the ones at
https://vpifg.com/help/icc-profiles/, do contain this tag and it seems
nice to be able to dump it, just for completeness.

I haven't seen any files that contain a phosphor or colorant type
different from "Unknown", even for the Rec2020 profile on that page.
(It has x,y coordinates that match the values required for Rec2020,
but it doesn't set the phosphor or colorant type to that.)
2023-02-10 14:23:37 +00:00
Nico Weber
c61cfdd5ed LibGfx+icc: Read viewingConditionsType
Not terribly useful in practice either and also mostly for
completionism. But with this, we can dump all types present
in Lightroom Classic-exported jpegs :^)
2023-02-10 14:16:52 +00:00
Nico Weber
664946c543 LibGfx+icc: Read measurementType
Also not terribly useful in practice and mostly for completionism.
Lightroom Classic-exported jpegs contain this type in their ICC data.
2023-02-10 14:02:19 +00:00
Nico Weber
2ff11bac3d LibGfx+icc: Implement half of lutAToBType and lutBToAType
These are among the permitted tag types of ATo0Tag and BToA0Tag,
which are among the required tags of most profiles. They are the
last permitted tag types for those profiles (the other are
lut8Type or lut16Type, which are already implemented).

They are pretty chonky types though, so this only implements
support for the E matrix and the CLUT. Support for the various
curves will be in a future PR.
2023-02-08 19:44:03 +00:00
Nico Weber
839bec14af LibGfx: Validate type of cicpTag in ICC Profile
This should've really been part of e8bbb3d915.
2023-02-08 17:18:54 +00:00
Nico Weber
e8bbb3d915 LibGfx+icc: Read cicpType
This is a very new tag used for HDR content. The only files I know that
use it are the jpegs on https://ccameron-chromium.github.io/hdr-jpeg/
But they have an invalid ICC creation date, so `icc` can't process them.
(Commenting out the check for that does allow to print them.)

If the CIPC tag is present, it takes precedence about the actual data
in the profile and from what I understand, the ICC profile is
basically ignored. See https://www.color.org/events/HDR_experts.xalter
for background, in particular
https://www.color.org/hdr/02-Luke_Wallis.pdf (but the other talks
are very interesting too).

(PNG also has a cICP chunk that's supposed to take precedence over
iCCP.)
2023-02-08 16:41:58 +00:00
Nico Weber
a434b89521 LibGfx: Add another profile ID to ICC quirk list 2023-02-08 16:37:47 +00:00
Nico Weber
21cc0c0cb2 LibGfx: Add ICC v2 tags to tag list 2023-02-08 16:36:31 +00:00
Nico Weber
8bd64f001c LibGfx+icc: Read signatureType
This isn't used by any mandatory tags, and it's not terribly useful.
But jpegs exported by Lightroom Classic write the 'tech' tag, and
it seems nice to be able to dump its contents.

signatureType stores a single u32 which for different tags with this
type means different things.

In each case, the value is one from a short table of valid values,
suggesting this should be a per-tag enum class instead of a
per-tag DistinctFourCC, per the comment at the top of DistincFourCC.h.
On the other hand, 3 of the 4 tables have an explicit "It is possible
that the ICC will define other signature values in the future" note,
which suggests the FourCC might actually be the way to go.

For now, just punt on that and manually dump the u32 in fourcc style
in icc.cpp and don't add any to_string() methods that return a readable
string based on the contents of these tables.
2023-02-08 16:35:57 +00:00
Nico Weber
cbcf8471a6 LibGfx+icc: Read namedColor2Type
This is the type of namedColor2Tag, which is a required tag in
NamedColor profiles.

The implementation is pretty basic for now and only exposes the
numbers stored in the file directly (after endian conversion).
2023-02-08 16:34:24 +00:00
Nico Weber
e9dcc49f9c LibGfx: Validate tag types of AToBNTag, BToANTag, gamutTag, previewNTag
Also rewrite a few of the existing tag type checks using a new helper.
2023-01-29 11:40:14 +00:00
Nico Weber
909c2a73c4 LibGfx+icc: Read and display lut16Type and lut8Type ICC tag types 2023-01-28 21:40:45 +00:00
Nico Weber
a0513a360a LibGfx: Use AssertSize<> in ICC/Profile.cpp 2023-01-28 21:40:45 +00:00
Nico Weber
b5deccf859 LibGfx: Split ICC/Profile.{h,cpp} into several files
s15Fixed16Number and XYZNumber are somewhat awkwardly duplicated
in both Profile.cpp and TagTypes.cpp. Other than that, this is a
pure code move.

No behavior change.
2023-01-28 00:27:07 +00:00
Nico Weber
6d51d8ad32 LibGfx: Bump copyright year in ICC/Profile.{h,cpp} 2023-01-28 00:27:07 +00:00
Nico Weber
721b280849 LibGfx: Move ICCProfile.{h,cpp} to ICC/Profile.{h,cpp} 2023-01-28 00:27:07 +00:00
Renamed from Userland/Libraries/LibGfx/ICCProfile.cpp (Browse further)