[PATCH 13/15] Added channel flags test for KoCompositeOpCopyChannel class and changed Color Dodge and Burn.
Silvio Heinrich
plassy at web.de
Mon Jan 10 00:39:47 CET 2011
The dodge and burn algorithms where changed to fit the definition
in ISO 32000 part 2.
---
.../compositeops/KoCompositeOpCopyChannel.h | 9 +++++--
libs/pigment/compositeops/KoCompositeOpFunctions.h | 24 +++++++++++++++-----
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/libs/pigment/compositeops/KoCompositeOpCopyChannel.h b/libs/pigment/compositeops/KoCompositeOpCopyChannel.h
index 7bb6b40..1747334 100644
--- a/libs/pigment/compositeops/KoCompositeOpCopyChannel.h
+++ b/libs/pigment/compositeops/KoCompositeOpCopyChannel.h
@@ -48,10 +48,13 @@ public:
inline static channels_type composeColorChannels(const channels_type* src, channels_type srcAlpha,
channels_type* dst, channels_type dstAlpha,
channels_type opacity, const QBitArray& channelFlags) {
- if(channel_pos == alpha_pos)
- return lerp(dstAlpha, srcAlpha, opacity);
+ if(allChannelFlags || channelFlags.testBit(channel_pos)) {
+ if(channel_pos == alpha_pos)
+ return lerp(dstAlpha, srcAlpha, opacity);
+
+ dst[channel_pos] = lerp(dst[channel_pos], src[channel_pos], opacity);
+ }
- dst[channel_pos] = lerp(dst[channel_pos], src[channel_pos], opacity);
return dstAlpha;
}
};
diff --git a/libs/pigment/compositeops/KoCompositeOpFunctions.h b/libs/pigment/compositeops/KoCompositeOpFunctions.h
index a6ec380..9b75faf 100644
--- a/libs/pigment/compositeops/KoCompositeOpFunctions.h
+++ b/libs/pigment/compositeops/KoCompositeOpFunctions.h
@@ -214,9 +214,15 @@ inline void cfHue(TReal sr, TReal sg, TReal sb, TReal& dr, TReal& dg, TReal& db)
template<class T>
inline T cfColorBurn(T src, T dst) {
- if(src != KoColorSpaceMathsTraits<T>::zeroValue)
- return inv(clamp<T>(div(inv(dst), src)));
- return KoColorSpaceMathsTraits<T>::zeroValue;
+ if(dst == KoColorSpaceMathsTraits<T>::unitValue)
+ return KoColorSpaceMathsTraits<T>::unitValue;
+
+ T invDst = inv(dst);
+
+ if(src < invDst)
+ return KoColorSpaceMathsTraits<T>::zeroValue;
+
+ return inv(clamp<T>(div(invDst, src)));
}
template<class T>
@@ -227,9 +233,15 @@ inline T cfLinearBurn(T src, T dst) {
template<class T>
inline T cfColorDodge(T src, T dst) {
- if(src != KoColorSpaceMathsTraits<T>::unitValue)
- return clamp<T>(div(dst, inv(src)));
- return KoColorSpaceMathsTraits<T>::unitValue;
+ if(dst == KoColorSpaceMathsTraits<T>::zeroValue)
+ return KoColorSpaceMathsTraits<T>::zeroValue;
+
+ T invSrc = inv(src);
+
+ if(invSrc < dst)
+ return KoColorSpaceMathsTraits<T>::unitValue;
+
+ return clamp<T>(div(dst, invSrc));
}
template<class T>
--
1.7.1
More information about the kimageshop
mailing list