mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-07 08:29:58 +00:00
LibPDF: Extract ICCBasedColorSpace::sRGB() helper
This commit is contained in:
parent
4704e6aa5f
commit
c161b2d2f9
|
@ -499,9 +499,6 @@ ICCBasedColorSpace::ICCBasedColorSpace(NonnullRefPtr<Gfx::ICC::Profile> profile)
|
|||
|
||||
PDFErrorOr<ColorOrStyle> ICCBasedColorSpace::style(ReadonlySpan<Value> arguments) const
|
||||
{
|
||||
if (!s_srgb_profile)
|
||||
s_srgb_profile = TRY(Gfx::ICC::sRGB());
|
||||
|
||||
Vector<u8> bytes;
|
||||
for (size_t i = 0; i < arguments.size(); ++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));
|
||||
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]);
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
if (parameters.size() != 1)
|
||||
|
|
|
@ -188,6 +188,8 @@ public:
|
|||
Vector<float> default_decode() const override;
|
||||
ColorSpaceFamily const& family() const override { return ColorSpaceFamily::ICCBased; }
|
||||
|
||||
static NonnullRefPtr<Gfx::ICC::Profile> sRGB();
|
||||
|
||||
private:
|
||||
ICCBasedColorSpace(NonnullRefPtr<Gfx::ICC::Profile>);
|
||||
|
||||
|
|
Loading…
Reference in a new issue