krita

kis_convolution_painter.h

00001 /*
00002  *  Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program 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
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #ifndef KIS_CONVOLUTION_PAINTER_H_
00019 #define KIS_CONVOLUTION_PAINTER_H_
00020 
00021 #include <qimage.h>
00022 
00023 #include "ksharedptr.h"
00024 #include "kis_types.h"
00025 #include "kis_painter.h"
00026 
00027 #include "koffice_export.h"
00028 
00029 enum KisConvolutionBorderOp {
00030     BORDER_DEFAULT_FILL = 0, // Use the default pixel to make up for the missing pixels on the border or the pixel that lies beyond
00031                              // the rect we are convolving.
00032     BORDER_WRAP = 1, // Use the pixel on the opposite side to make up for the missing pixels on the border. XXX: Not implemented yet
00033     BORDER_REPEAT = 2, // Use the border for the missing pixels, too.
00034     BORDER_AVOID = 3 // Skip convolving the border pixels at all.
00035 };
00036 
00037 class KisKernel;
00038 typedef KSharedPtr<KisKernel> KisKernelSP;
00039 
00040 class KisKernel : public KShared 
00041 {
00042 
00043 public:
00044     
00045     Q_UINT32 width;
00046     Q_UINT32 height;
00047     Q_INT32 offset;
00048     Q_INT32 factor;
00049     Q_INT32 * data;
00050 
00051     KisKernel() : width(0), height(0), offset(0), factor(0), data(0) {};
00052 
00053     virtual ~KisKernel() { delete [] data; };
00054 
00055     static KisKernelSP fromQImage(const QImage& img);
00056 
00057 };
00058 
00059 
00060 class KRITACORE_EXPORT KisConvolutionPainter : public KisPainter
00061 {
00062 
00063     typedef KisPainter super;
00064 
00065 public:
00066 
00067     KisConvolutionPainter();
00068     KisConvolutionPainter(KisPaintDeviceSP device);
00069 
00083     void applyMatrix(KisKernelSP kernel, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h,
00084                      KisConvolutionBorderOp borderOp = BORDER_AVOID,
00085                      KisChannelInfo::enumChannelFlags channelFlags = KisChannelInfo::FLAG_COLOR);
00086 private:
00090     void applyMatrixRepeat(KisKernelSP kernel, Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h,
00091                            KisChannelInfo::enumChannelFlags channelFlags);
00092 
00093 
00094 };
00095 #endif //KIS_CONVOLUTION_PAINTER_H_
KDE Home | KDE Accessibility Home | Description of Access Keys