Round MyPaint dab channels properly
MyPaint dabs do their calculations in terms of floats and then convert to the target channel type. However, instead of rounding the values, they get floored, which for example causes opaque areas drawn over with a MyPaint brush to turn slightly transparent. These errors accumulate over time and make stuff in my drawings see-through.
This patch calls KoColorSpaceMaths::scaleToA
instead of flooring the values, which rounds (as well as multiplies and clamps) the value appropriately.
Also updates the draw_dab.png
used in the MyPaint paintop plugin unit tests, since the old one had the flooring error baked into it. The new image is correct.
Test Plan
There's various ways of reproducing the error, here's one of them:
- Create a fully white layer.
- Create a transparent layer on top.
- Draw fully opaque black strokes on it with a non-MyPaint brush.
- Draw (supposedly) fully opaque black strokes across it with the brush
c) Pencil 1 Sketch (mypaint)
. - Merge the image together.
- Increase the contrast to make the small differences in alpha visible.
Before applying this patch: the MyPaint stroke causes the fully opaque stroke to become slightly transparent.
After applying this patch: the MyPaint stroke doesn't reduce the opacity of the existing stroke.
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.