Bug 445799

Summary: Some brush tip previews opaque, some not (git: afcbeae084)
Product: [Applications] krita Reporter: Andreas Resch <andreas>
Component: Resource ManagementAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: minor CC: dimula73, tamtamy.tymona
Priority: NOR Keywords: regression
Version First Reported In: nightly build (please specify the git hash!)   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Andreas Resch 2021-11-20 10:26:19 UTC
A minor bug that I just found.

One of the brush previews is displayed in black and white (opaque) while most other ones are displayed transparent (black on dark grey). But all of them are opaque PNG files without alpha channels.

Here are three files. A screenshot of the issue and two brush tips of which the rounder one is displayed transparently and the longer one is displayed opaque.

http://www.argfx.at/upload/Krita_BrushSettings_02.zip

SOFTWARE/OS VERSIONS
Windows: 10 64-Bit
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Dmitry Kazakov 2022-06-13 07:56:40 UTC
Yes, there is something weird with parsing PNG brushes. Evevn fully transparent PNGs are loaded with white background in the preview. Though it doesn't happen with GBR brushes. It looks as if the background generation code is resource type dependent.
Comment 3 Bug Janitor Service 2022-06-15 09:03:39 UTC
A possibly relevant merge request was started @ https://invent.kde.org/graphics/krita/-/merge_requests/1474
Comment 4 Dmitry Kazakov 2022-06-15 09:28:20 UTC
Git commit d1dd249f9e7e39d01e6cd72f9d475a14e28a6333 by Dmitry Kazakov.
Committed on 15/06/2022 at 09:27.
Pushed by dkazakov into branch 'master'.

Fix background painting in the predefined brush selector

The patch does multiple fixes:

1) Removes a hacky conversion of a PNG brush into a mask brush if the
   brush is all gray. All-gray brushes can easily be used in lightness
   mask mode.

2) Implements separator lines in the predefined brush selector and fixes
   hidpi support in it.

3) Implements checkers background painting for the brushes that support
   transparency, and therefore, lightness mode.

4) All other brushes are now painted on white background

5) To let the selector know if the brush has transparency, this property
   is written into the brush'es metadat. To do that, a special class
   KisBrushTypeMetaDataFixup is implemented. It updates the database,
   if finds any inconsistent reconrds at the database.

M  +1    -0    libs/brush/CMakeLists.txt
A  +58   -0    libs/brush/KisBrushTypeMetaDataFixup.cpp     [License: GPL(v2.0+)]
A  +19   -0    libs/brush/KisBrushTypeMetaDataFixup.h     [License: GPL(v2.0+)]
M  +3    -0    libs/brush/kis_brush.cpp
M  +2    -0    libs/brush/kis_brush.h
M  +0    -9    libs/brush/kis_png_brush.cpp
M  +2    -7    libs/brush/kis_svg_brush.cpp
M  +2    -0    libs/brush/tests/CMakeLists.txt
A  +-    --    libs/brush/tests/data/bw-alpha-solid.png
A  +-    --    libs/brush/tests/data/bw-alpha-transp.png
A  +-    --    libs/brush/tests/data/bw-no-alpha-solid.png
A  +-    --    libs/brush/tests/data/color-alpha-solid.png
A  +-    --    libs/brush/tests/data/color-alpha-transp.png
A  +49   -0    libs/brush/tests/kis_png_brush_test.cpp     [License: GPL(v2.0+)]
A  +22   -0    libs/brush/tests/kis_png_brush_test.h     [License: GPL(v2.0+)]
M  +24   -1    libs/resources/KisResourceLoaderRegistry.cpp
M  +18   -0    libs/resources/KisResourceLoaderRegistry.h
M  +8    -1    libs/resources/KisResourceLocator.cpp
M  +1    -0    libs/resources/KisResourceLocator.h
M  +3    -0    libs/ui/KisApplication.cpp
M  +48   -8    plugins/paintops/libpaintop/kis_predefined_brush_chooser.cpp

https://invent.kde.org/graphics/krita/commit/d1dd249f9e7e39d01e6cd72f9d475a14e28a6333
Comment 5 Dmitry Kazakov 2022-06-15 10:34:25 UTC
Git commit 159bbd6e0392298361b7427e315e7b14b09e996c by Dmitry Kazakov.
Committed on 15/06/2022 at 09:28.
Pushed by dkazakov into branch 'krita/5.1'.

Fix background painting in the predefined brush selector

The patch does multiple fixes:

1) Removes a hacky conversion of a PNG brush into a mask brush if the
   brush is all gray. All-gray brushes can easily be used in lightness
   mask mode.

2) Implements separator lines in the predefined brush selector and fixes
   hidpi support in it.

3) Implements checkers background painting for the brushes that support
   transparency, and therefore, lightness mode.

4) All other brushes are now painted on white background

5) To let the selector know if the brush has transparency, this property
   is written into the brush'es metadat. To do that, a special class
   KisBrushTypeMetaDataFixup is implemented. It updates the database,
   if finds any inconsistent reconrds at the database.

M  +1    -0    libs/brush/CMakeLists.txt
A  +58   -0    libs/brush/KisBrushTypeMetaDataFixup.cpp     [License: GPL(v2.0+)]
A  +19   -0    libs/brush/KisBrushTypeMetaDataFixup.h     [License: GPL(v2.0+)]
M  +3    -0    libs/brush/kis_brush.cpp
M  +2    -0    libs/brush/kis_brush.h
M  +0    -9    libs/brush/kis_png_brush.cpp
M  +2    -7    libs/brush/kis_svg_brush.cpp
M  +2    -0    libs/brush/tests/CMakeLists.txt
A  +-    --    libs/brush/tests/data/bw-alpha-solid.png
A  +-    --    libs/brush/tests/data/bw-alpha-transp.png
A  +-    --    libs/brush/tests/data/bw-no-alpha-solid.png
A  +-    --    libs/brush/tests/data/color-alpha-solid.png
A  +-    --    libs/brush/tests/data/color-alpha-transp.png
A  +49   -0    libs/brush/tests/kis_png_brush_test.cpp     [License: GPL(v2.0+)]
A  +22   -0    libs/brush/tests/kis_png_brush_test.h     [License: GPL(v2.0+)]
M  +24   -1    libs/resources/KisResourceLoaderRegistry.cpp
M  +18   -0    libs/resources/KisResourceLoaderRegistry.h
M  +8    -1    libs/resources/KisResourceLocator.cpp
M  +1    -0    libs/resources/KisResourceLocator.h
M  +3    -0    libs/ui/KisApplication.cpp
M  +48   -8    plugins/paintops/libpaintop/kis_predefined_brush_chooser.cpp

https://invent.kde.org/graphics/krita/commit/159bbd6e0392298361b7427e315e7b14b09e996c