mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
LibPDF: Sketch out Lab color space
Same as other recent color spaces: Enough to make us not assert, but not enough to actually produce color. Fixes 2 asserts on the `-n 500` 0000.zip pdfa dataset.
This commit is contained in:
parent
1a4df4ffe7
commit
2878af5968
3 changed files with 39 additions and 0 deletions
|
@ -62,6 +62,9 @@ PDFErrorOr<NonnullRefPtr<ColorSpace>> ColorSpace::create(Document* document, Non
|
||||||
if (color_space_name == CommonNames::Indexed)
|
if (color_space_name == CommonNames::Indexed)
|
||||||
return Error::rendering_unsupported_error("Indexed color spaces not yet implemented");
|
return Error::rendering_unsupported_error("Indexed color spaces not yet implemented");
|
||||||
|
|
||||||
|
if (color_space_name == CommonNames::Lab)
|
||||||
|
return TRY(LabColorSpace::create(document, move(parameters)));
|
||||||
|
|
||||||
if (color_space_name == CommonNames::Pattern)
|
if (color_space_name == CommonNames::Pattern)
|
||||||
return Error::rendering_unsupported_error("Pattern color spaces not yet implemented");
|
return Error::rendering_unsupported_error("Pattern color spaces not yet implemented");
|
||||||
|
|
||||||
|
@ -382,6 +385,26 @@ Vector<float> ICCBasedColorSpace::default_decode() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PDFErrorOr<NonnullRefPtr<LabColorSpace>> LabColorSpace::create(Document*, Vector<Value>&& parameters)
|
||||||
|
{
|
||||||
|
if (parameters.size() != 1)
|
||||||
|
return Error { Error::Type::MalformedPDF, "Lab color space expects one parameter" };
|
||||||
|
|
||||||
|
auto color_space = adopt_ref(*new LabColorSpace());
|
||||||
|
// FIXME: Implement.
|
||||||
|
return color_space;
|
||||||
|
}
|
||||||
|
|
||||||
|
PDFErrorOr<Color> LabColorSpace::color(ReadonlySpan<Value>) const
|
||||||
|
{
|
||||||
|
return Error::rendering_unsupported_error("Lab color spaces not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<float> LabColorSpace::default_decode() const
|
||||||
|
{
|
||||||
|
return { 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f };
|
||||||
|
}
|
||||||
|
|
||||||
PDFErrorOr<NonnullRefPtr<SeparationColorSpace>> SeparationColorSpace::create(Document*, Vector<Value>&&)
|
PDFErrorOr<NonnullRefPtr<SeparationColorSpace>> SeparationColorSpace::create(Document*, Vector<Value>&&)
|
||||||
{
|
{
|
||||||
auto color_space = adopt_ref(*new SeparationColorSpace());
|
auto color_space = adopt_ref(*new SeparationColorSpace());
|
||||||
|
|
|
@ -144,6 +144,21 @@ private:
|
||||||
NonnullRefPtr<Gfx::ICC::Profile> m_profile;
|
NonnullRefPtr<Gfx::ICC::Profile> m_profile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class LabColorSpace final : public ColorSpace {
|
||||||
|
public:
|
||||||
|
static PDFErrorOr<NonnullRefPtr<LabColorSpace>> create(Document*, Vector<Value>&& parameters);
|
||||||
|
|
||||||
|
~LabColorSpace() override = default;
|
||||||
|
|
||||||
|
PDFErrorOr<Color> color(ReadonlySpan<Value> arguments) const override;
|
||||||
|
int number_of_components() const override { return 3; }
|
||||||
|
Vector<float> default_decode() const override;
|
||||||
|
ColorSpaceFamily const& family() const override { return ColorSpaceFamily::Lab; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
LabColorSpace() = default;
|
||||||
|
};
|
||||||
|
|
||||||
class SeparationColorSpace final : public ColorSpace {
|
class SeparationColorSpace final : public ColorSpace {
|
||||||
public:
|
public:
|
||||||
static PDFErrorOr<NonnullRefPtr<SeparationColorSpace>> create(Document*, Vector<Value>&& parameters);
|
static PDFErrorOr<NonnullRefPtr<SeparationColorSpace>> create(Document*, Vector<Value>&& parameters);
|
||||||
|
|
|
@ -99,6 +99,7 @@
|
||||||
X(LJ) \
|
X(LJ) \
|
||||||
X(LW) \
|
X(LW) \
|
||||||
X(LZWDecode) \
|
X(LZWDecode) \
|
||||||
|
X(Lab) \
|
||||||
X(Last) \
|
X(Last) \
|
||||||
X(LastChar) \
|
X(LastChar) \
|
||||||
X(Length) \
|
X(Length) \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue