Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Possibly fix saving EXR files with extremely low alpha values

Dmitry Kazakov513b2802260b
diff --git a/plugins/impex/exr/exr_converter.cc b/plugins/impex/exr/exr_converter.cc
index d5b1fbf51f..629fd12086 100644
--- a/plugins/impex/exr/exr_converter.cc
+++ b/plugins/impex/exr/exr_converter.cc
@@ -244,7 +244,7 @@ struct RgbPixelWrapper
}
inline bool checkMultipliedColorsConsistent() const {
- return !(std::abs(pixel.a) < alphaEpsilon<T>() &&
+ return !(std::abs(pixel.a) <= alphaEpsilon<T>() &&
(!qFuzzyIsNull(pixel.r) ||
!qFuzzyIsNull(pixel.g) ||
!qFuzzyIsNull(pixel.b)));
@@ -284,7 +284,7 @@ struct GrayPixelWrapper
}
inline bool checkMultipliedColorsConsistent() const {
- return !(std::abs(pixel.alpha) < alphaEpsilon<T>() &&
+ return !(std::abs(pixel.alpha) <= alphaEpsilon<T>() &&
!qFuzzyIsNull(pixel.gray));
}
@@ -349,7 +349,7 @@ void multiplyAlpha(Pixel *pixel)
if (alphaPos >= 0) {
T alpha = pixel->data[alphaPos];
- if (alpha > 0.0) {
+ if (alpha > alphaEpsilon<T>()) {
for (int i = 0; i < size; ++i) {
if (i != alphaPos) {
pixel->data[i] *= alpha;
@@ -357,6 +357,10 @@ void multiplyAlpha(Pixel *pixel)
}
pixel->data[alphaPos] = alpha;
+ } else {
+ for (int i = 0; i < size; ++i) {
+ pixel->data[i] = 0;
+ }
}
}
}