From 563bb9d20cac75245c595333f7511cf1414008ef Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 28 Sep 2023 10:06:47 -0400 Subject: [PATCH] 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. --- Userland/Libraries/LibGfx/ICC/Profile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/ICC/Profile.cpp b/Userland/Libraries/LibGfx/ICC/Profile.cpp index bbf7743602..5825970834 100644 --- a/Userland/Libraries/LibGfx/ICC/Profile.cpp +++ b/Userland/Libraries/LibGfx/ICC/Profile.cpp @@ -1437,9 +1437,12 @@ ErrorOr 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.