mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 20:58:16 +00:00
LibGfx: Fix colour with Photoshop JPEG files using CMYK
This is based on the original functionality Lucus wrote prior to using libjpeg. Co-authored-by: Lucas CHOLLET <lucas.chollet@free.fr>
This commit is contained in:
parent
738eb68dda
commit
97746fb574
Notes:
github-actions[bot]
2025-08-20 10:05:41 +00:00
Author: https://github.com/jamierocks
Commit: 97746fb574
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5849
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/trflynn89
1 changed files with 18 additions and 0 deletions
|
@ -145,6 +145,24 @@ ErrorOr<void> JPEGLoadingContext::decode()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Photoshop writes inverted CMYK data (i.e. Photoshop's 0 should be 255). We convert this
|
||||
// to expected values.
|
||||
if (cinfo.saw_Adobe_marker) {
|
||||
for (int i = 0; i < cmyk_bitmap->size().height(); ++i) {
|
||||
auto* line = cmyk_bitmap->scanline(i);
|
||||
|
||||
for (int j = 0; j < cmyk_bitmap->size().width(); ++j) {
|
||||
auto const& cmyk = line[j];
|
||||
line[j] = {
|
||||
static_cast<u8>(255 - cmyk.c),
|
||||
static_cast<u8>(255 - cmyk.m),
|
||||
static_cast<u8>(255 - cmyk.y),
|
||||
static_cast<u8>(255 - cmyk.k),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JOCTET* icc_data_ptr = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue