1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 16:04:58 +00:00
Commit graph

42 commits

Author SHA1 Message Date
Nico Weber
fa00d94e82 LibGfx+icc: Add ICCProfile support for parametricCurveType and print it
With this, we can parse all types required in v4
"Three-component matrix-based Input profiles".
2023-01-23 23:37:33 +00:00
Nico Weber
67f718aa3f LibGfx+icc: Add ICCProfile support for curveType and print it 2023-01-23 18:20:55 +00:00
Nico Weber
ea31aba0f4 LibGfx: Tweak an error message in XYZTagData::from_bytes 2023-01-23 18:09:23 +00:00
Nico Weber
9756842734 LibGfx+icc: Add ICCProfile support for s15Fixed16ArrayType and print it
This is the type of the chromaticAdaptationTag, which is a required tag
in v4 profiles for all non-DeviceLink profiles.
2023-01-23 18:09:23 +00:00
Nico Weber
b347aebc3e LibGfx: Do not repeat class name in ICC from_bytes() functions
Makes these more amenable to copy-pasting :^)

No behavior change.
2023-01-23 16:36:02 +01:00
Nico Weber
6cfb057430 LibGfx+icc: Add ICCProfile support for XYZType and print it 2023-01-23 12:08:25 +00:00
Nico Weber
2bfd09b173 LibGfx: Fix typo in an error message in TextTagData::from_bytes() 2023-01-23 10:09:01 +00:00
Nico Weber
e7eccf4ac8 LibGfx+icc: Add ICCProfile support for textDescriptionType and print it
This is used in v2 profiles for the required 'desc' tag. In v2
profiles, it's also used by the 'dmnd', 'dmdd', 'scrd', 'vued' tags.

In v4 profiles, these all use 'mluc' instead (except for 'scrd', which
is no longer part of the spec in v4).
2023-01-23 10:09:01 +00:00
Nico Weber
ec7a2058a2 LibGfx: Add ICCProfile support for multiLocalizedUnicodeType
This is used in v4 profiles for the required 'cprt' and 'desc' tags.
2023-01-22 15:25:58 +00:00
Nico Weber
3dfb012a1a LibGfx: Add ICCProfile support for textType
This is used in v2 profiles for the required 'cprt' tag.
2023-01-22 15:25:58 +00:00
Nico Weber
d33eef14a0 LibGfx: Minorly simplify a line of code in ICCProfile with OptionalNone
No behavior change.
2023-01-21 22:16:38 -05:00
Nico Weber
b56a145a67 LibGfx+icc: Make device manufacturer and device model clickable 2023-01-21 22:16:38 -05:00
Nico Weber
f28b052590 LibGfx: Add scaffolding for reading ICC tag table
The idea is that we'll have one type for each tag type.
For now, this treats all tag types as unknown, but it puts most
of the infrastructure for reading tags in place.
2023-01-20 21:44:36 +00:00
Nico Weber
5017d8fdcb LibGfx: Extract Profile::read_header() function 2023-01-20 21:44:36 +00:00
Nico Weber
e5234f582d LibGfx: Make ICCHeader use FourCC types for fourcc fields
No behavior change. Arguably more expressive.
2023-01-20 21:44:36 +00:00
Nico Weber
7ae97c9fc4 LibGfx+icc: Look at profile_size field
This trims the input bytes to the profile size stored in the file.
Alternatively, we could reject files where the stored size doesn't
match the handed in size. But ICC profiles can be embedded in other
files, and those could conceivably pad the ICC profile data some.
2023-01-08 23:41:14 +01:00
Nico Weber
7d4ec4fecf LibGfx: Rename ICC::DateTimeNumber::hour to hours to match spec 2023-01-08 23:41:14 +01:00
Nico Weber
aee7c44064 LibGfx+icc: Print primary platform
There's a small, old-timey list of platforms in the spec, but as far
as I can tell nobody is using additional platforms on Linux or Android
or what. So let's try going with an enum class instead of the FourCC
machinery for now.
2023-01-08 09:56:07 +00:00
Nico Weber
6d70b6a3a7 LibGfx: Put parse_device_attributes() in spec order 2023-01-08 09:56:07 +00:00
Nico Weber
8f4d2486dd LibGfx: Expand spec comment for parse_device_attributes() in ICCProfile 2023-01-07 13:41:41 +00:00
Nico Weber
fdbe501d3e LibGfx+icc: Print fields that are fourccs registered with the ICC
Namely:
- preferred CMM type
- device manufacturer
- device model
- profile creator

These all have in common that they can take arbitrary values, so I added
a FourCC class to deal with them, instead of using an enum class.
I made distinct types for each of them, so that they aren't accidentally
mixed up.
2023-01-07 13:41:41 +00:00
Nico Weber
d223477bc6 LibGfx+icc: Print device attribute flags
These flags are always 0 in practice in all profiles I've seen so far,
but hey, probably nice to dump them anyways.

And hey, it's just 86 lines to print 4 bits.
2023-01-06 21:33:46 +01:00
Nico Weber
c00ce2fba0 LibGfx+icc: Verify ICCProfile ID at parse time instead of in icc
Always computing computing the md5 takes some time, but most
icc profiles are small. So that's probably fine.

If this ends up being a perf problem in the future, or if it ends up
rejecting tons of embedded proiles from images, we can row it back.
But let's see if we can get away with this first.
2023-01-06 20:26:14 +01:00
Nico Weber
31af741c66 LibGfx: Rename variable in parse_profile_id() to match spec better 2023-01-06 20:26:14 +01:00
Nico Weber
b0068c387b LibGfx: Verify ICC reserved header bytes are zero
I checked that they are zero for all profiles in Compact-ICC-Profiles
and for all .icc files in /Library/ColorSync and
/System/Library/ColorSync on my Mac (running macOS 12.6.2).
2023-01-06 19:17:22 +01:00
Nico Weber
090bd02a88 LibGfx: Extract all_bytes_are_zero() function in ICCProfile 2023-01-06 19:17:22 +01:00
Nico Weber
aa107ef2d6 LibGfx: Add quotes and reflow for glanceability 2023-01-06 19:17:22 +01:00
Nico Weber
478bd97b25 LibGfx: Rename ICCHeader::profile_md5 to profile_id to match spec 2023-01-06 19:17:22 +01:00
Nico Weber
68f678f566 LibGfx+icc: Print if profile id is valid 2023-01-05 10:54:35 +01:00
Nico Weber
d5c8c90ff0 LibGfx: Store profile id MD5 in ICCProfile 2023-01-05 10:54:35 +01:00
Nico Weber
27189850d8 LibGfx: Sort ICC parsing functions by spec number 2023-01-05 10:54:35 +01:00
Linus Groh
b9913f9441 LibGfx: Fix typos in ICC spec comments 2023-01-03 18:53:20 +01:00
Nico Weber
79badfd650 LibGfx+icc: Print pcs illuminant 2023-01-02 15:20:51 +01:00
Nico Weber
47f29170b3 LibGfx+icc: Add profile connection space printing
This is a bit messy: The spec says that PCSXYZ and PCSLAB are the only
valid profile connection spaces -- except for DeviceLink profles, where
all data color spaces are valid.

So this uses the existing ColorSpace enum for profile connection spaces
instead of adding a dedicated enum, to not duplicate all the color space
parsing and printing code.  That matches what the spec does, too.
This saves about 100 lines of code, at the expense of less type
safety -- but further down the line we probably want to be able to
compare data color spaces and profile connection spaces, so the type
safety would likely get in the way then. (But if not, we can change
things around once we get to that point.)
2022-12-31 23:18:35 +01:00
Nico Weber
0b46e572b5 LibGfx+icc: Print profile flags
These flags are always 0 in practice in all profiles I've seen so far,
but hey, probably nice to dump them anyways.
2022-12-31 23:17:48 +01:00
Nico Weber
b1e977e18a LibGfx: Use VERIFY_NOT_REACHED() for impossible states in ICC code
The `parse_` functions reject invalid values, so we know the default is
unreachable.
2022-12-31 12:59:22 -05:00
Nico Weber
a8ee5dd9cd LibGfx: Make ICC name converters return StringView 2022-12-31 12:59:22 -05:00
Nico Weber
743e9fc786 LibGfx: Read rendering intent from ICCProfile header 2022-12-30 17:21:57 +01:00
Nico Weber
eaf1f67bb1 LibGfx: Read data color space from ICCProfile header 2022-12-30 10:14:22 -05:00
Nico Weber
50c6d133a9 LibGfx: Remove now-unneeded casts 2022-12-28 20:13:12 +00:00
Nico Weber
782ab0a11f LibGfx: Read profile creation time from ICCProfile header 2022-12-27 15:58:39 -08:00
Nico Weber
d8867f8077 LibGfx: Start adding a class for handling ICC color profiles
For now, this checks the magic number and reads file version and
device class.
2022-12-27 07:44:37 -07:00