F:/KPlato/koffice/libs/pigment/compositeops/KoCompositeOpErase.h

Aller à la documentation de ce fichier.
00001 /*
00002  *  Copyright (c) 2006 Cyrille Berger <cberger@cberger.net>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
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             // apply the alphamask
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

Généré le Wed Nov 22 23:41:13 2006 pour KPlato par  doxygen 1.5.1-p1