Did something break with the selection?
Cyrille Berger Skott
cberger at cberger.net
Fri Apr 29 15:11:54 CEST 2011
On Friday 29 April 2011, Silvio Heinrich wrote:
> Thank you for this suggestion but I'm afraid that this is not the case :-(
> (I've could have fixed it easily if it where).
> I checked the code and I wasn't able to find anything.
> To make sure I didn't miss anything I enabled all the old composite ops
> again and
> even did a reset of KoCompositeOpCopy2.h to the state before I modified
> anything.
> But the problem was still present :/
> And Btw: Even now the old CompositeOp for the "Normal" blending mode is
> used (KoCompositeOpOver.h), so this weird
> behavior of the build-up mode should only occur with the other blending
> modes (and this isn't the case, too).
>
> Do you have any other suggestion?
Hum I think I figured it out.
Since, the selection mask is handled by KoCompositeOpAlphaBase, and you did
not changed that class. The only logical explanation is that something changed
in a function that class call.
The mask is used on line 83 of KoCompositeOpAlphaBase:
srcAlpha = KoColorSpaceMaths<channels_type, quint8>::multiply(srcAlpha, *mask,
U8_opacity);
I looked at the changes you made for a while, and could not figure out what was
the changed behaviour </mylife ;p>. But you have fixed the behaviour of it,
from:
return (dst_compositetype(a)*b*c) /
(KoColorSpaceMathsTraits<_Tdst>::unitValue *
KoColorSpaceMathsTraits<_Tdst>::unitValue);
to:
return (dst_compositetype(a)*b*c) /
(dst_compositetype(KoColorSpaceMathsTraits<_Tdst>::unitValue) *
KoColorSpaceMathsTraits<_Tdst>::unitValue);
And in the first case, we get an overflow, and if channels_type is 16 bit, we
actually compute:
srcAlpha * mask * U8_opacity / 0xFF
which is what we want (since srcAlpha is 16bits, while both mask and
U8_opacity are 8bits).
However, now, with the fixed behaviour, we get:
srcAlpha * mask * U8_opacity / 0xFFFF
Which is not what we want.
I think we need to change line 83 of KoCompositeOpAlphaBase to
srcAlpha = KoColorSpaceMaths<quint8, channels_type>::multiply(*mask, srcAlpha,
opacity);
And KoColorSpaceMaths::multiply(_T a, _Tdst b, _Tdst c) to:
inline static _Tdst multiply(_T a, _Tdst b, _Tdst c) {
return (dst_compositetype(a)*b*c) /
(dst_compositetype(KoColorSpaceMathsTraits<_Tdst>::unitValue) *
KoColorSpaceMathsTraits<_T>::unitValue);
}
And it should fix it.
--
Cyrille Berger Skott
More information about the kimageshop
mailing list