1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +00:00

LibPDF: Add support for the CalRGB ColorSpace

This isn't tested all that well, as the PDF I am testing with only uses
it for black (which is trivial). It can be tested further when LibPDF
is able to process more complex PDFs that actually use this color space
non-trivially.
This commit is contained in:
Matthew Olsson 2021-05-27 14:03:29 -07:00 committed by Ali Mohammad Pur
parent 7b4e36bf88
commit 006f5498de
3 changed files with 205 additions and 0 deletions

View file

@ -517,6 +517,25 @@ RefPtr<ColorSpace> Renderer::get_color_space(const Value& value)
return DeviceRGBColorSpace::the();
if (name == CommonNames::DeviceCMYK)
return DeviceCMYKColorSpace::the();
if (name == CommonNames::Pattern)
TODO();
// The color space is a complex color space with parameters that resides in
// the resource dictionary
auto color_space_resource_dict = m_page.resources->get_dict(m_document, CommonNames::ColorSpace);
if (!color_space_resource_dict->contains(name))
TODO();
auto color_space_array = color_space_resource_dict->get_array(m_document, name);
name = color_space_array->get_name_at(m_document, 0)->name();
Vector<Value> parameters;
parameters.ensure_capacity(color_space_array->size() - 1);
for (size_t i = 1; i < color_space_array->size(); i++)
parameters.unchecked_append(color_space_array->at(i));
if (name == CommonNames::CalRGB)
return CalRGBColorSpace::create(m_document, move(parameters));
TODO();
}