[PATCH 15/15] Introduced a comparison with an epsilon value in the setSaturation function.
Silvio Heinrich
plassy at web.de
Wed Jan 12 22:23:48 CET 2011
The blend modes "Saturation" and "Hue" are actually broken.
Since the modes "Luminosity" and "Color" are working i expect the
error somewhere in the setSaturation function.
I programmed it after the ISO 32000-1 spec and cannot find where i made a mistake.
---
libs/pigment/compositeops/KoCompositeOpFunctions.h | 24 ++++++++++----------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/libs/pigment/compositeops/KoCompositeOpFunctions.h b/libs/pigment/compositeops/KoCompositeOpFunctions.h
index c70d27e..9fb9af8 100644
--- a/libs/pigment/compositeops/KoCompositeOpFunctions.h
+++ b/libs/pigment/compositeops/KoCompositeOpFunctions.h
@@ -140,37 +140,37 @@ inline TReal getSaturation(TReal r, TReal g, TReal b) {
template<class TReal>
inline void setSaturation(TReal& r, TReal& g, TReal& b, TReal sat) {
- TReal& min = r;
- TReal& mid = g;
- TReal& max = b;
+ TReal* min = &r;
+ TReal* mid = &g;
+ TReal* max = &b;
if(mid < min) {
- TReal& tmp = min;
+ TReal* tmp = min;
min = mid;
mid = tmp;
}
if(max < mid) {
- TReal& tmp = mid;
+ TReal* tmp = mid;
mid = max;
max = tmp;
}
if(mid < min) {
- TReal& tmp = min;
+ TReal* tmp = min;
min = mid;
mid = tmp;
}
- if(max > min) {
- mid = ((mid-min) * sat) / (max-min);
- max = sat;
+ if((*max - *min) > TReal(0.0001)) {
+ *mid = ((*mid-*min) * sat) / (*max-*min);
+ *max = sat;
} else {
- mid = TReal(0.0);
- max = TReal(0.0);
+ *mid = TReal(0.0);
+ *max = TReal(0.0);
}
- min = TReal(0.0);
+ *min = TReal(0.0);
}
/* ---------------- Blending/Compositing functions ------------------------ /
--
1.7.1
--------------080501060900080908060607--
More information about the kimageshop
mailing list