mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibGfx/JPEG+CMYKBitmap: Extract the CMYK to RGB conversion code
Right now, the JPEG decoder is the only one supporting CMYK, but that won't last for long. So, let's move the conversion to CMYKBitmap.
This commit is contained in:
parent
0462858247
commit
09b2b3539b
3 changed files with 23 additions and 19 deletions
|
@ -15,4 +15,21 @@ ErrorOr<NonnullRefPtr<CMYKBitmap>> CMYKBitmap::create_with_size(IntSize const& s
|
|||
return adopt_ref(*new CMYKBitmap(size, move(data)));
|
||||
}
|
||||
|
||||
ErrorOr<RefPtr<Bitmap>> CMYKBitmap::to_low_quality_rgb() const
|
||||
{
|
||||
if (!m_rgb_bitmap) {
|
||||
m_rgb_bitmap = TRY(Bitmap::create(BitmapFormat::BGRx8888, { m_size.width(), m_size.height() }));
|
||||
|
||||
for (int y = 0; y < m_size.height(); ++y) {
|
||||
for (int x = 0; x < m_size.width(); ++x) {
|
||||
auto const& cmyk = scanline(y)[x];
|
||||
u8 k = 255 - cmyk.k;
|
||||
m_rgb_bitmap->scanline(y)[x] = Color((255 - cmyk.c) * k / 255, (255 - cmyk.m) * k / 255, (255 - cmyk.y) * k / 255).value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_rgb_bitmap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue