Nico Weber
efabfd4c66
LibGfx: Fill in remaining values in built-in sRGB profile
...
The values aren't 100% self-consistent, but it probably doesn't make
a difference for u8 color data. Good enough for now. See all the links
on #17714 for some more background.
2023-03-05 18:21:43 +00:00
Nico Weber
0ba532e14e
LibGfx: Add a function to create an in-memory sRGB profile
...
This might be useful for converting data from arbitrary profiles to
sRGB.
For now, this only encodes the transfer function and puts in zero values
for chromaticities, whitepoint, and chromatic adaptation matrix.
This makes the profile unusable for now. But I've spent a very long time
reading things and need to check in some code, and it's some progress.
The encoded transfer function exactly matches the one in GIMP's built-in
sRGB ICC profile (but not the Compact-ICC-Profiles v4 one or the
RawTherapee v4 one -- I'll add a comment about why later.)
2023-03-04 21:38:47 +00:00
Nico Weber
8f415e7b21
LibGfx: Introduce ICC::Profile::create
...
This can be used to programmatically create ICC::Profile objects.
2023-03-04 21:38:47 +00:00
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
b161f5ea05
LibGfx: Make ICC reader check that profile size is a multiple of 4
...
With this, I would've found e8bd067ce5
earlier.
(If this turns out to be too strict in practice, we can always relax
it again.)
2023-02-24 19:17:20 +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
4bafdaba3f
LibGfx: Make Lut16TagData and Lut8TagData ctors verify table sizes
...
The from_bytes() methods error out on invalid table sizes,
but let's make sure other potential future callers get it right too.
2023-02-19 23:46:36 +01:00
Nico Weber
51be964884
LibGfx: Fix 7-bit ASCII checks in textDescriptionType and textType
...
This used to check the empty, moved-from parameter instead of
the member variable (-‸ლ)
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
eac9941766
LibGfx: Make NamedColor2TagData verify inputs are 32-byte 7-bit ASCII
...
NamedColor2TagData::from_bytes() errors out if that isn't the case,
but let's make sure other potential future callers get it right too.
2023-02-19 23:46:36 +01:00
Nico Weber
7ad11fa59a
LibGfx: Mark a few ICC:NamedColor2TagData methods as const
2023-02-19 23:46:36 +01:00
Nico Weber
47cfcf5dca
LibGfx: Move NamedColorHeader to BinaryFormat.h
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
8179327068
LibGfx: Add fallible ICC::Profile::try_for_each_tag
...
Similar to 13b18a1
or d0f3f3d
.
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
b2cf773d85
LibGfx: Make TextDescriptionTagData verify input is 7-bit ASCII
...
TextDescriptionTagData::from_bytes() errors out if that isn't the case,
but let's make sure other potential future callers get it right too.
2023-02-19 22:31:41 +01:00
Nico Weber
e76f1caf79
LibGfx: Re-alphabetize TagData classes
...
This moves TextDescriptionTagData below SignatureTagData.
It just moves code around and doesn't change anything.
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
Sam Atkins
2db168acc1
LibTextCodec+Everywhere: Port Decoders to new Strings
2023-02-19 17:15:47 +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
933002ae5a
LibGfx: Move ICC ViewingConditionsHeader to BinaryFormat.h
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
8e5392f9c0
LibGfx: Move ICC MeasurementHeader to BinaryFormat.h
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
eaa0e3484b
LibGfx: Make TextTagData verify input is 7-bit ASCII
...
TextTagData::from_bytes() errors out if that isn't the case, but
let's make sure other potential future callers get it right too.
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
4a62cf35fc
LibGfx: Move MultiLocalizedUnicodeRawRecord to BinaryFormat.h
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
9bd7048519
LibGfx: Move ICC TagTableEntry to BinaryFormat.h
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
Nico Weber
e8a2c17f8f
LibGfx: Add an accessor for the raw ICC Version minor_and_bugfix byte
...
This is makes it easier to write this value back out.
2023-02-17 20:05:50 -07:00
Nico Weber
0ab3f45135
LibGfx: Add a XYZ->XYZNumber conversion constructor
...
This is useful for converting XYZs back to the on-disk format.
2023-02-17 20:05:50 -07: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