Bug 301443 - CandleGlass.exr is not loaded correctly
Summary: CandleGlass.exr is not loaded correctly
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: File formats (show other bugs)
Version: git master (please specify the git hash!)
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-08 13:04 UTC by Halla Rempt
Modified: 2014-05-30 15:29 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Halla Rempt 2012-06-08 13:04:54 UTC
The background should be black, but it is transparent. This is probably a bug in the de-multiplying of alpha, see the openexr documentation

Reproducible: Always
Comment 1 Dmitry Kazakov 2014-02-07 11:25:43 UTC
Ok, the bug happens because alpha==0 && color != 0 is a correct situation in EXR. See page 21 of:
http://www.openexr.com/TechnicalIntroduction.pdf
Comment 2 Dmitry Kazakov 2014-04-04 10:13:53 UTC
Git commit 625faf4dff96934923afbeae427a9bf475cdf44d by Dmitry Kazakov.
Committed on 04/04/2014 at 10:05.
Pushed by dkazakov into branch 'master'.

Fixed loading of the EXR files with zero alpha and non-zero colors

EXR works with premultiplied colors, so it suports having zero alpha and
non-zero colors. Krita doesn't support premultiplied colors, so we just
set alpha to HALF_EPSILON on loading and reset it back to zero on saving.

This introduces subtle round-trip bugs, but they happen for alpha < 0.01
values only (which is 1%).

TODO:
Now we also need to reset default projection color of the image to black
to load the EXR properly

M  +1    -1    krita/plugins/formats/exr/CMakeLists.txt
M  +194  -90   krita/plugins/formats/exr/exr_converter.cc
M  +3    -5    krita/plugins/formats/exr/exr_converter.h
M  +1    -1    krita/plugins/formats/exr/exr_export.cc
M  +2    -1    krita/plugins/formats/exr/exr_import.cc
A  +-    --    krita/plugins/formats/exr/tests/data/CandleGlass.exr
M  +57   -1    krita/plugins/formats/exr/tests/kis_exr_test.cpp
M  +1    -0    krita/plugins/formats/exr/tests/kis_exr_test.h
M  +39   -0    krita/sdk/tests/testutil.h

http://commits.kde.org/calligra/625faf4dff96934923afbeae427a9bf475cdf44d
Comment 3 Dmitry Kazakov 2014-04-04 17:35:56 UTC
Git commit c20ee318b7c4f768fdcda6969c5861a87f67743a by Dmitry Kazakov.
Committed on 04/04/2014 at 17:25.
Pushed by dkazakov into branch 'master'.

Added a Background Color feature to KisImage

Now the user can choose the Background color for the projection.
Just go to Image->Properties->Background Color and choose the one
you want. And you'll never see the checkers anymore :)

This also fixes EXR images, which should have a black BG color

M  +16   -10   krita/image/kis_group_layer.cc
M  +30   -0    krita/image/kis_image.cc
M  +11   -0    krita/image/kis_image.h
M  +3    -0    krita/plugins/formats/exr/exr_converter.cc
M  +23   -0    krita/ui/dialogs/kis_dlg_image_properties.cc
M  +4    -0    krita/ui/dialogs/kis_dlg_image_properties.h
M  +1    -7    krita/ui/forms/wdgcolorspaceselector.ui
M  +62   -32   krita/ui/forms/wdgimageproperties.ui
M  +11   -0    krita/ui/kra/kis_kra_loader.cpp
M  +10   -0    krita/ui/kra/kis_kra_saver.cpp
M  +1    -0    krita/ui/kra/kis_kra_saver.h
M  +5    -0    krita/ui/tests/kis_kra_saver_test.cpp

http://commits.kde.org/calligra/c20ee318b7c4f768fdcda6969c5861a87f67743a
Comment 4 Dmitry Kazakov 2014-04-10 11:53:28 UTC
Git commit 5726aed45b0034f6425bd2659a0c10ef8e64fe62 by Dmitry Kazakov.
Committed on 10/04/2014 at 11:52.
Pushed by dkazakov into branch 'master'.

Fix saving/loading of exr images with small alpha values

There are several issues possible:

1) The image has zero alpha + non-zero color pixels. We artificially raise
   the alpha value to allow premultiplication.

2) The image has tiny non-zero alpha + non-zero color pixels, but division
   is possible without overflow of color channels. Then we must not change
   anything.

3) The image has tiny non-zero alpha + non-zero color pixels, but division
   is not possible due to a half overflow. In this case we must also raise
   alpha a bit (as in case 1) ) to allow correct rendering of the image.

M  +39   -38   krita/plugins/formats/exr/exr_converter.cc

http://commits.kde.org/calligra/5726aed45b0034f6425bd2659a0c10ef8e64fe62
Comment 5 Stuart Dickson 2014-05-30 15:29:55 UTC
Git commit 6f54affba1f5b4005d451e1e46f2c7eb10e743f4 by Stuart Dickson, on behalf of Dmitry Kazakov.
Committed on 04/04/2014 at 10:05.
Pushed by dickson into tag 'steam-233896_233900'.

Fixed loading of the EXR files with zero alpha and non-zero colors

EXR works with premultiplied colors, so it suports having zero alpha and
non-zero colors. Krita doesn't support premultiplied colors, so we just
set alpha to HALF_EPSILON on loading and reset it back to zero on saving.

This introduces subtle round-trip bugs, but they happen for alpha < 0.01
values only (which is 1%).

TODO:
Now we also need to reset default projection color of the image to black
to load the EXR properly

M  +1    -1    krita/plugins/formats/exr/CMakeLists.txt
M  +194  -90   krita/plugins/formats/exr/exr_converter.cc
M  +3    -5    krita/plugins/formats/exr/exr_converter.h
M  +1    -1    krita/plugins/formats/exr/exr_export.cc
M  +2    -1    krita/plugins/formats/exr/exr_import.cc
A  +-    --    krita/plugins/formats/exr/tests/data/CandleGlass.exr
M  +57   -1    krita/plugins/formats/exr/tests/kis_exr_test.cpp
M  +1    -0    krita/plugins/formats/exr/tests/kis_exr_test.h
M  +39   -0    krita/sdk/tests/testutil.h

http://commits.kde.org/calligra/6f54affba1f5b4005d451e1e46f2c7eb10e743f4