mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
LibPDF: Extract ICCBasedColorSpace::sRGB() helper
This commit is contained in:
parent
4704e6aa5f
commit
c161b2d2f9
2 changed files with 10 additions and 4 deletions
|
@ -499,9 +499,6 @@ ICCBasedColorSpace::ICCBasedColorSpace(NonnullRefPtr<Gfx::ICC::Profile> profile)
|
||||||
|
|
||||||
PDFErrorOr<ColorOrStyle> ICCBasedColorSpace::style(ReadonlySpan<Value> arguments) const
|
PDFErrorOr<ColorOrStyle> ICCBasedColorSpace::style(ReadonlySpan<Value> arguments) const
|
||||||
{
|
{
|
||||||
if (!s_srgb_profile)
|
|
||||||
s_srgb_profile = TRY(Gfx::ICC::sRGB());
|
|
||||||
|
|
||||||
Vector<u8> bytes;
|
Vector<u8> bytes;
|
||||||
for (size_t i = 0; i < arguments.size(); ++i) {
|
for (size_t i = 0; i < arguments.size(); ++i) {
|
||||||
auto const& arg = arguments[i];
|
auto const& arg = arguments[i];
|
||||||
|
@ -522,7 +519,7 @@ PDFErrorOr<ColorOrStyle> ICCBasedColorSpace::style(ReadonlySpan<Value> arguments
|
||||||
|
|
||||||
auto pcs = TRY(m_profile->to_pcs(bytes));
|
auto pcs = TRY(m_profile->to_pcs(bytes));
|
||||||
Array<u8, 3> output;
|
Array<u8, 3> output;
|
||||||
TRY(s_srgb_profile->from_pcs(m_profile, pcs, output.span()));
|
TRY(sRGB()->from_pcs(m_profile, pcs, output.span()));
|
||||||
|
|
||||||
return Color(output[0], output[1], output[2]);
|
return Color(output[0], output[1], output[2]);
|
||||||
}
|
}
|
||||||
|
@ -553,6 +550,13 @@ Vector<float> ICCBasedColorSpace::default_decode() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NonnullRefPtr<Gfx::ICC::Profile> ICCBasedColorSpace::sRGB()
|
||||||
|
{
|
||||||
|
if (!s_srgb_profile)
|
||||||
|
s_srgb_profile = MUST(Gfx::ICC::sRGB());
|
||||||
|
return *s_srgb_profile;
|
||||||
|
}
|
||||||
|
|
||||||
PDFErrorOr<NonnullRefPtr<LabColorSpace>> LabColorSpace::create(Document* document, Vector<Value>&& parameters)
|
PDFErrorOr<NonnullRefPtr<LabColorSpace>> LabColorSpace::create(Document* document, Vector<Value>&& parameters)
|
||||||
{
|
{
|
||||||
if (parameters.size() != 1)
|
if (parameters.size() != 1)
|
||||||
|
|
|
@ -188,6 +188,8 @@ public:
|
||||||
Vector<float> default_decode() const override;
|
Vector<float> default_decode() const override;
|
||||||
ColorSpaceFamily const& family() const override { return ColorSpaceFamily::ICCBased; }
|
ColorSpaceFamily const& family() const override { return ColorSpaceFamily::ICCBased; }
|
||||||
|
|
||||||
|
static NonnullRefPtr<Gfx::ICC::Profile> sRGB();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ICCBasedColorSpace(NonnullRefPtr<Gfx::ICC::Profile>);
|
ICCBasedColorSpace(NonnullRefPtr<Gfx::ICC::Profile>);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue