Bug 474583

Summary: Swatchbooker CMYK color palette may be rendered incorrectly
Product: [Applications] krita Reporter: cmyk.student
Component: File formatsAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: minor    
Priority: NOR    
Version: 5.2.0-rc1   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Swatchbooker palette loaded in GIMP, with Cyan row highlighted
Same file in Krita, but Cyan row is white

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