|
@@ -495,11 +495,12 @@ PDFErrorOr<NonnullRefPtr<ColorSpace>> ICCBasedColorSpace::create(Document* docum
|
|
|
ICCBasedColorSpace::ICCBasedColorSpace(NonnullRefPtr<Gfx::ICC::Profile> profile)
|
|
|
: m_profile(profile)
|
|
|
{
|
|
|
+ m_map = sRGB()->matrix_matrix_conversion(profile);
|
|
|
}
|
|
|
|
|
|
PDFErrorOr<ColorOrStyle> ICCBasedColorSpace::style(ReadonlySpan<Value> arguments) const
|
|
|
{
|
|
|
- Vector<u8> bytes;
|
|
|
+ Vector<float, 4> components;
|
|
|
for (size_t i = 0; i < arguments.size(); ++i) {
|
|
|
auto const& arg = arguments[i];
|
|
|
VERIFY(arg.has_number());
|
|
@@ -514,9 +515,16 @@ PDFErrorOr<ColorOrStyle> ICCBasedColorSpace::style(ReadonlySpan<Value> arguments
|
|
|
number = (number + 128.0f) / 255.0f;
|
|
|
}
|
|
|
|
|
|
- bytes.append(static_cast<u8>(number * 255.0f));
|
|
|
+ components.append(number);
|
|
|
}
|
|
|
|
|
|
+ if (m_map.has_value())
|
|
|
+ return m_map->map(FloatVector3 { components[0], components[1], components[2] });
|
|
|
+
|
|
|
+ Vector<u8, 4> bytes;
|
|
|
+ for (auto component : components)
|
|
|
+ bytes.append(static_cast<u8>(component * 255.0f));
|
|
|
+
|
|
|
auto pcs = TRY(m_profile->to_pcs(bytes));
|
|
|
Array<u8, 3> output;
|
|
|
TRY(sRGB()->from_pcs(m_profile, pcs, output.span()));
|