Hi guys! I found another bug with color custom/clipboard brush and rotation. Screenshot: http://i.imgur.com/EUe0g37.png Kra file for testing (hide background before making a custom brush): https://dl.dropboxusercontent.com/u/26887202/blender/brush_rotation_bug.kra Reproducible: Always
I also see artifacts even if i use only Opacity pressure. It's dificult to notice. But if you scale to 200% you will see artifacts. I guess this is important too. https://dl.dropboxusercontent.com/u/26887202/blender/brush_color_artifacts.png
Those are transformation artefacts from Qt's QImage transformation functions :-(
This bug happens because of two reasons: 1) We do our own hard-coded Premultiplied conversions in KisScaleBrush without changing QImage format. This results in the transformation in QImage being wrong. 2) We do something weird in KisBrush::scaleImage() function. This is also related to the hard-coded multiplication, but simple making the format consistent doesn't help. Only removing this function from the pipeline helps.
Ok, one of the reasons of the artifacts is that the premultiplication makes the value of semi-transparent pixels unstable, this leads to weird colors appearing when the color in de-multiplacated later. This means the solution should be: remove the pre-multiplication entirely.
Removing the pre-multiplication also fixes the sparks brush bug: https://bugs.kde.org/show_bug.cgi?id=300665
Git commit b9d749eb4e7c6bbc00332c9d1c090c9a2293af74 by Dmitry Kazakov. Committed on 16/07/2013 at 10:43. Pushed by dkazakov into branch 'master'. A significant refactoring in the Predefined Brush engine This patch ports the predefined brush engine to the new capabilities of Qt. It removes a huge chunk of hand-written code. Here is a short list of changes: 1) All the operations are now performed on non-premultiplied RGB values. The use of premultiplication resulted in instability of the color, which caused artifacts on scaling and rotation of the brushes. 2) Trilinear filtering of the brushes is now substituted with simple bilinear filtering from the nearest pyramid level. It turned out that trilinear filtering not only impacted the performance, but also introduced heavy aliasing artifacts on specific zoom levels. 3) After the patch the speed of the dab generation raised 3-5 times. Here are the values for 512px brush: Before patch: Scaling: 34 ms Rotation: 19 ms After patch: Scaling: 6 ms Rotation: 9 ms Related: bug 319944, bug 300665, bug 320651 CCMAIL:kimageshop@kde.org M +1 -2 krita/plugins/paintops/libbrush/CMakeLists.txt M +0 -1 krita/plugins/paintops/libbrush/kis_abr_brush.cpp M +1 -1 krita/plugins/paintops/libbrush/kis_auto_brush.cpp M +70 -778 krita/plugins/paintops/libbrush/kis_brush.cpp M +3 -26 krita/plugins/paintops/libbrush/kis_brush.h M +2 -3 krita/plugins/paintops/libbrush/kis_gbr_brush.cpp D +0 -135 krita/plugins/paintops/libbrush/kis_qimage_mask.cpp D +0 -138 krita/plugins/paintops/libbrush/kis_qimage_mask.h A +196 -0 krita/plugins/paintops/libbrush/kis_qimage_pyramid.cpp [License: GPL (v2+)] A +52 -0 krita/plugins/paintops/libbrush/kis_qimage_pyramid.h [License: GPL (v2+)] D +0 -64 krita/plugins/paintops/libbrush/kis_scaled_brush.cpp D +0 -62 krita/plugins/paintops/libbrush/kis_scaled_brush.h A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_0_sc_0.871853_rot_3.55731_sub_0.137199.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_1_sc_0.861342_rot_3.45867_sub_0.20933.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_2_sc_1.80941_rot_4.97706_sub_0.113862.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_3_sc_0.46124_rot_4.18791_sub_0.167627.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_4_sc_0.963137_rot_2.82314_sub_0.444059.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_5_sc_0.592981_rot_0.439579_sub_0.45074.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_6_sc_1.86775_rot_3.12606_sub_0.365777.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_7_sc_1.13937_rot_3.47854_sub_0.458733.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_8_sc_1.53198_rot_3.68719_sub_0.410264.png A +- -- krita/plugins/paintops/libbrush/tests/data/brush_masks/_brush_9_sc_1.46566_rot_2.88023_sub_0.474873.png M +- -- krita/plugins/paintops/libbrush/tests/data/result_autobrush_3.png M +- -- krita/plugins/paintops/libbrush/tests/data/result_autobrush_4.png A +- -- krita/plugins/paintops/libbrush/tests/data/testing_brush_512_bars.gbr M +24 -28 krita/plugins/paintops/libbrush/tests/kis_auto_brush_test.cpp M +91 -17 krita/plugins/paintops/libbrush/tests/kis_brush_test.cpp M +7 -2 krita/plugins/paintops/libbrush/tests/kis_brush_test.h M +5 -4 krita/plugins/paintops/libbrush/tests/kis_imagepipe_brush_test.cpp http://commits.kde.org/calligra/b9d749eb4e7c6bbc00332c9d1c090c9a2293af74