Bug 474583 - Swatchbooker CMYK color palette may be rendered incorrectly
Summary: Swatchbooker CMYK color palette may be rendered incorrectly
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: 5.2.0-rc1
Platform: Other Other
: NOR minor
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-16 01:52 UTC by cmyk.student
Modified: 2023-09-18 14:57 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Swatchbooker palette loaded in GIMP, with Cyan row highlighted (41.76 KB, image/png)
2023-09-16 01:52 UTC, cmyk.student
Details
Same file in Krita, but Cyan row is white (19.40 KB, image/png)
2023-09-16 01:58 UTC, cmyk.student
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cmyk.student 2023-09-16 01:52:26 UTC
Created attachment 161652 [details]
Swatchbooker palette loaded in GIMP, with Cyan row highlighted

GIMP recently added support for importing Swatchbooker color palettes. While comparing the results with Krita, I noticed that Krita might be rendering the CMYK colors incorrectly. In the sample file from the Swatchbooker repository, there is a row of "Cyan (%)" colors that are in the CMYK color space. In GIMP, these show up as Cyan (see attached image). In Krita, they show up as white.

Swatchbooker stores the CMYK percentages as floating point (0.0 to 1.0). I think what's happening is that Krita is treating those as 0.5% rather than multiplying them to get 50.0% 
The relevant code for Krita is at https://invent.kde.org/graphics/krita/-/blob/master/libs/pigment/resources/KoColorSet.cpp#L1832

(Note that Krita does have a test .sbz file at https://invent.kde.org/graphics/krita/-/blob/master/libs/pigment/tests/data/swatchbook.sbz, but the "CMYK" palette is commented out from the Swatchbooker site example and replaced with RGB).


STEPS TO REPRODUCE
1. Download a valid .sbz file with a CMYK color palette (https://github.com/olivierberten/SwatchBooker/blob/master/data/sample.sbz)
2. Import into Krita
3. Look at the "Cyan" colors in the palette

OBSERVED RESULT
The "Cyan" colors appear to be white

EXPECTED RESULT
The "Cyan" colors should be Cyan
Comment 1 cmyk.student 2023-09-16 01:58:44 UTC
Created attachment 161653 [details]
Same file in Krita, but Cyan row is white

Example of loading the same file in Krita 5.2RC1, with the now white "Cyan" field highlighted
Comment 2 Dmitry Kazakov 2023-09-18 14:55:50 UTC
Git commit ee47d8934a79f51713529c162419a24b2fd5e815 by Dmitry Kazakov.
Committed on 18/09/2023 at 16:55.
Pushed by dkazakov into branch 'krita/5.2'.

Fix loading swatchbook CMYK palettes

And add a unittest for that

M  +4    -4    libs/pigment/resources/KoColorSet.cpp
M  +74   -2    libs/pigment/tests/TestKoColorSet.cpp
M  +1    -0    libs/pigment/tests/TestKoColorSet.h
A  +-    --    libs/pigment/tests/data/sample_swatchbook.sbz

https://invent.kde.org/graphics/krita/-/commit/ee47d8934a79f51713529c162419a24b2fd5e815
Comment 3 Dmitry Kazakov 2023-09-18 14:57:04 UTC
Git commit 604ba0507cef70f616fc527d16a4ff443334a879 by Dmitry Kazakov.
Committed on 18/09/2023 at 16:56.
Pushed by dkazakov into branch 'master'.

Fix loading swatchbook CMYK palettes

And add a unittest for that

M  +4    -4    libs/pigment/resources/KoColorSet.cpp
M  +74   -2    libs/pigment/tests/TestKoColorSet.cpp
M  +1    -0    libs/pigment/tests/TestKoColorSet.h
A  +-    --    libs/pigment/tests/data/sample_swatchbook.sbz

https://invent.kde.org/graphics/krita/-/commit/604ba0507cef70f616fc527d16a4ff443334a879