Commit graph

28 commits

Author SHA1 Message Date
Nico Weber
4bf639b635 LibGfx: Drop tags of unknown type instead of writing invalid icc files
We could make UnknownTagData hold on to undecoded, raw input data and
write that back out when serializing. But for now, we don't.

On the flipside, this _does_ write unknown tags that have known types.
We could have a mode where we drop unknown tags with known types.
But for now, we don't have that either.

With this, we can for example reencode
/Library/ColorSync/Profiles/WebSafeColors.icc and icc (and other
tools) can dump the output icc file. The 'ncpi' tag with type 'ncpi'
is dropped while writing it, while the unknown tag 'dscm' with
known type 'mluc' is written to the output. (That file is a v2 file,
so 'desc' has to have type 'desc' instead of type 'mluc' which
it would have in v4 files -- 'dscm' emulates an 'mluc' description
in v2 files.)
2023-02-24 19:42:00 +01:00
Nico Weber
e8bd067ce5 LibGfx: Pad last element in ICC files to 4-byte boundary too
The spec wants that to happen.
2023-02-23 16:39:17 +01:00
Nico Weber
7853be7869 LibGfx: Implement serialization of LutAToBTagData and LutBToATagData
With this, we can write all tag types we can currently read :^)
2023-02-23 15:35:02 +01:00
Nico Weber
1d124af66f LibGfx: Implement serialization of Lut16TagData and Lut8TagData 2023-02-19 23:46:36 +01:00
Nico Weber
8f181e0e94 LibGfx: Implement serialization of NamedColor2TagData 2023-02-19 23:46:36 +01:00
Nico Weber
937d018fc6 LibGfx: Use ICC::Profile::try_for_each_tag in encode_tag_datas() 2023-02-19 23:46:36 +01:00
Nico Weber
0f0694edb1 LibGfx: Remove an ICC writing FIXME, and a comment 2023-02-19 23:46:36 +01:00
Nico Weber
e2dde64628 LibGfx: Use static_cast in ICC writing code
It's what project leadership wants.
2023-02-19 22:31:41 +01:00
Nico Weber
0e66a5c3ed LibGfx: Write multiLocalizedUnicodeType with multiple strings correctly
Found by reencoding Tests/LibGfx/test-inputs/icc-v2.png, the 'dscm' tag.
2023-02-19 22:31:41 +01:00
Nico Weber
07bf2d944c LibGfx: Add a FIXME to ICC encode_tag_data() 2023-02-19 22:31:41 +01:00
Nico Weber
7e769c7217 LibGfx: Partially implement serialization of TextDescriptionTagData
It only implements serialization of the 7-bit ASCII string, not yet
serialization of the UCS-2 and Macintosh ScriptCode strings.

With this, matrix-based v2 profiles can be reencoded :^)
2023-02-19 22:31:41 +01:00
Nico Weber
4d972ab975 LibGfx: Add spec comment to ICC encode_tag_table() 2023-02-19 22:31:41 +01:00
Nico Weber
19e91e5211 LibGfx: Dedupe identical tag data objects when writing ICC data
With this, common v4 profiles, such as embedded into jpgs by iPhones
(when configured to write jpegs) or Pixel phones, are identical to
the input when reexported :^)
2023-02-19 08:12:04 +00:00
Nico Weber
2504f2035c LibGfx: Implement serialization of ViewingConditionsTagData 2023-02-19 08:12:04 +00:00
Nico Weber
22c0e6b60e LibGfx: Implement serialization of MeasurementTagData 2023-02-19 00:01:44 +01:00
Nico Weber
a1de65c34f LibGfx: Implement serialization of TextTagData 2023-02-19 00:01:44 +01:00
Nico Weber
df5dbc180f LibGfx: Implement serialization of SignatureTagData 2023-02-19 00:01:44 +01:00
Nico Weber
3690305794 LibGfx: Implement serialization of CurveTagData 2023-02-19 00:01:44 +01:00
Nico Weber
1ca7f109a1 LibGfx: Implement serialization of CicpTagData 2023-02-19 00:01:44 +01:00
Nico Weber
fd590fe55d LibGfx: Implement serialization of ChromaticityTagData 2023-02-19 00:01:44 +01:00
Nico Weber
ececea9a1c LibGfx: Implement serialization of ParametricCurveTagData
With this, simple v4 matrix profiles using parametric curves, such as
Compact-ICC-Profiles/profiles/sRGB-v4.icc, can be completely serialized
and the serialized file can be read again by `icc` :^)
2023-02-19 00:01:44 +01:00
Nico Weber
685e2da302 LibGfx: Implement serialization of S15Fixed16ArrayTagData 2023-02-19 00:01:44 +01:00
Nico Weber
931594fce3 LibGfx: Implement serialization of XYZTagData 2023-02-19 00:01:44 +01:00
Nico Weber
eb6dccb675 LibGfx: Implement serialization of MultiLocalizedUnicodeTagData 2023-02-19 00:01:44 +01:00
Nico Weber
4e72a35398 LibGfx: Add scaffolding for writing tag data
This doesn't deduplicate identical TagDatas yet.

It also doesn't implement actual serialization of TagData yet.
2023-02-19 00:01:44 +01:00
Nico Weber
1457e36b79 LibGfx: Write ICC tag table
All offsets and sizes are set to 0 for now, so this still doesn't
produce a valid icc file. It gets closer, though.
2023-02-19 00:01:44 +01:00
Nico Weber
026d9ceaf9 LibGfx: Extract encode_header() function in ICC writing code 2023-02-19 00:01:44 +01:00
Nico Weber
8b8b7b232e LibGfx: Add start of an ICC profile writer
For now, this can write the profile header.

`icc` refuses to dump its contents since the required copyrightTag,
profileDescriptionTag, and required per-device-class tags are missing,
but it looks ok in a hex editor.
2023-02-17 20:05:50 -07:00