00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KOCOMPOSITEOPERASE_H_
00021 #define KOCOMPOSITEOPERASE_H_
00022
00023 #include "KoColorSpaceMaths.h"
00024 #include "KoCompositeOp.h"
00025
00026 #define NATIVE_OPACITY_OPAQUE KoColorSpaceMathsTraits<channels_type>::max()
00027 #define NATIVE_OPACITY_TRANSPARENT KoColorSpaceMathsTraits<channels_type>::min()
00028
00032 template<class _CSTraits>
00033 class KoCompositeOpErase : public KoCompositeOp {
00034 typedef typename _CSTraits::channels_type channels_type;
00035
00036 public:
00037
00038 KoCompositeOpErase(KoColorSpace * cs)
00039 : KoCompositeOp(cs, COMPOSITE_ERASE, i18n("Erase" ) )
00040 {
00041 }
00042
00043 public:
00044
00045 void composite(quint8 *dstRowStart,
00046 qint32 dststride,
00047 const quint8 *srcRowStart,
00048 qint32 srcstride,
00049 const quint8 *maskRowStart,
00050 qint32 maskstride,
00051 qint32 rows,
00052 qint32 cols,
00053 quint8 U8_opacity,
00054 const QBitArray & channelFlags) const
00055 {
00056 Q_UNUSED( U8_opacity );
00057 Q_UNUSED( channelFlags );
00058 while (rows-- > 0)
00059 {
00060 const channels_type *s = reinterpret_cast<const channels_type *>(srcRowStart);
00061 channels_type *d = reinterpret_cast<channels_type *>(dstRowStart);
00062 const quint8 *mask = maskRowStart;
00063
00064 for (qint32 i = cols; i > 0; i--, s+=_CSTraits::channels_nb, d+=_CSTraits::channels_nb)
00065 {
00066 channels_type srcAlpha = s[_CSTraits::alpha_pos];
00067
00068
00069 if (mask != 0) {
00070 quint8 U8_mask = *mask;
00071
00072 if (U8_mask != OPACITY_OPAQUE) {
00073 srcAlpha = UINT16_BLEND(srcAlpha, NATIVE_OPACITY_OPAQUE,
00074 KoColorSpaceMaths<quint8, channels_type>::scaleToA( U8_mask) );
00075 }
00076 mask++;
00077 }
00078 d[_CSTraits::alpha_pos] = KoColorSpaceMaths<channels_type>::multiply(srcAlpha, d[_CSTraits::alpha_pos]);
00079 }
00080
00081 dstRowStart += dststride;
00082 srcRowStart += srcstride;
00083 if(maskRowStart) {
00084 maskRowStart += maskstride;
00085 }
00086 }
00087 }
00088 };
00089
00090 #endif