Patch: Many composite/blend modes mostly compatible to Adobe Photoshop (c)

Silvio Heinrich plassy at web.de
Sat Feb 5 22:47:53 CET 2011


> Don't think we have forgotten about this patch :) I have played a bit with it.
> I still need to read the code in more depth, and check that it does not
> introduces a regression with respect to this bug
> https://bugs.kde.org/show_bug.cgi?id=176536 .
>
Ok, thx you are looking at it.
I can give a rough overview on how everything works.
I'ts acctually not much different from your approach but i wanted it a 
bit more generic.

The derivation tree is like this:

            KoCompositeOp
                        |
                KoCompositeOpBase
                  |           |
KoCompositeOpGenericSC   KoCompositeOpGenericHSL


The KoCompositeOpBase class is like your KoCompositeOpAlphaBase class
(but i didn't want to change it because I wasn't sure what sideeffects 
it may cause).

the KoCompositeOpGenericSC and KoCompositeOpGenericHSL are the classes
that do the compositing. The two classes take a constant function 
pointer as template parameter.
These function pointers are the blending functions.

So it should be easy to create new blending modes by just writing a 
blending function.
For example the darken blending function:

template<class T>
inline T cfDarkenOnly(T src, T dst) { return qMin(src, dst); }

Notice that the blending function does not need to handle transparency 
and masking, this is
done in the KoCompositeOpGenericSC and KoCompositeOpGenericHSL classes 
and works for all
blending modes equally :-) .

This function is then passed to an instance of KoCompositeOpGenericSC:

new KoCompositeOpGenericSC<Traits, &cfDarkenOnly>(colSpace, 
COMPOSITE_DARKEN, i18n("Darken"), KoCompositeOp::categoryLight());

Thats all.
It's not this much :-D .




More information about the kimageshop mailing list