Add parsing and serializing for svg11 icc colors with unit tests.
This implements parsing of SVG 1.1's color value as a static function in KoColor. It also implements a serialization function.
We had an initial version in SVGStyleParser, but that didn't handle icc-color. We need icc-color for !668 (merged) , unless we're going to write our own gradient file format. (There's still some weirdness here with that svg says you should interpolate in srgb, but we really would like to interpolate in the image space, so maybe we should ignore svg unless we're explicitly rendering vectors).
Annoyingly, icc-color is deprecated in SVG 2.0, and we'll have to use CSS4 Color, which is still in draft, and a far more complicated spec. I'm planning on tackling that one as well at some point, but let's first start with SVG 1.1.
Test Plan
-
Run the unittest
./libs/pigment/tests/TestKoColor
. -
Load an SVG file with icc-color definitions.
-
load the following gradient :
<svg xmlns:krita="http://krita.org/namespaces/svg/krita" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<color-profile local="ccf9dc6e4f0faf35fb01630dcc305c5f" name="Chemical-proof"/>
</defs>
<linearGradient id="testing-loading-cmyk-colors-1" spreadMethod="pad" gradientUnits="objectBoundingBox">
<stop offset="0" krita:stop-type="color-stop" stop-opacity="1" stop-color="#ff00ff icc-color(Chemical-proof, 1.0, 0, 0, 0)"/>
<stop offset="0.474286" krita:stop-type="color-stop" stop-opacity="1" stop-color="#777777 icc-color(Chemical-proof, 0, .5, 1, 0)"/>
<stop offset="1" krita:stop-type="color-stop" stop-opacity="1" stop-color="#00ff00 icc-color(Chemical-proof, 1.0, 0, 1, 0)"/>
</linearGradient>
</svg>
It should look blue-orange-green.
Finally, to create a stopgradient that is color managed, you can try the following:
- make a cmyk image (or anything non-srgb).
- Draw some splotches of color.
- Create a new stop gradient.
- Use the color sampler in the color dialog to pick the cmyk colors from the image.
- Save.
- Look at the new svg file in the resource folder.
Formalities Checklist
-
I confirmed this builds. -
I confirmed Krita ran and the relevant functions work. -
I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!) -
I made sure my commits build individually and have good descriptions as per KDE guidelines. -
I made sure my code conforms to the standards set in the HACKING file. -
I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.