ICC: Implement Profile::to_pcs() for grayscale colors

There's probably a nicer way of doing this where we don't need to expand
the gray value into a full Vector3, but for now this is good enough.

Makes PDFs written by macOS 13.5.2's "Save as PDF..." feature show up.
This commit is contained in:
Nico Weber 2023-09-28 10:06:47 -04:00 committed by Sam Atkins
parent 6b4da8680d
commit 563bb9d20c

View file

@ -1437,9 +1437,12 @@ ErrorOr<FloatVector3> Profile::to_pcs(ReadonlyBytes color) const
};
if (data_color_space() == ColorSpace::Gray) {
VERIFY(color.size() == 1); // True because of color.size() check further up.
// ICC v4, F.2 grayTRCTag
// FIXME
return Error::from_string_literal("ICC::Profile::to_pcs: Gray handling not yet implemented");
// "connection = grayTRC[device]"
float gray = evaluate_curve(grayTRCTag, color[0] / 255.f);
return FloatVector3 { gray, gray, gray };
}
// FIXME: Per ICC v4, A.1 General, this should also handle HLS, HSV, YCbCr.