chalk

kis_convolution_painter.h
1/*
2 * Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18#ifndef KIS_CONVOLUTION_PAINTER_H_
19#define KIS_CONVOLUTION_PAINTER_H_
20
21#include <tqimage.h>
22
23#include "ksharedptr.h"
24#include "kis_types.h"
25#include "kis_painter.h"
26
27#include "koffice_export.h"
28
29enum KisConvolutionBorderOp {
30 BORDER_DEFAULT_FILL = 0, // Use the default pixel to make up for the missing pixels on the border or the pixel that lies beyond
31 // the rect we are convolving.
32 BORDER_WRAP = 1, // Use the pixel on the opposite side to make up for the missing pixels on the border. XXX: Not implemented yet
33 BORDER_REPEAT = 2, // Use the border for the missing pixels, too.
34 BORDER_AVOID = 3 // Skip convolving the border pixels at all.
35};
36
37class KisKernel;
38typedef TDESharedPtr<KisKernel> KisKernelSP;
39
40class KisKernel : public TDEShared
41{
42
43public:
44
45 TQ_UINT32 width;
46 TQ_UINT32 height;
47 TQ_INT32 offset;
48 TQ_INT32 factor;
49 TQ_INT32 * data;
50
51 KisKernel() : width(0), height(0), offset(0), factor(0), data(0) {};
52
53 virtual ~KisKernel() { delete [] data; };
54
55 static KisKernelSP fromTQImage(const TQImage& img);
56
57};
58
59
60class KRITACORE_EXPORT KisConvolutionPainter : public KisPainter
61{
62
63 typedef KisPainter super;
64
65public:
66
67 KisConvolutionPainter();
68 KisConvolutionPainter(KisPaintDeviceSP device);
69
83 void applyMatrix(KisKernelSP kernel, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h,
84 KisConvolutionBorderOp borderOp = BORDER_AVOID,
85 KisChannelInfo::enumChannelFlags channelFlags = KisChannelInfo::FLAG_COLOR);
86private:
90 void applyMatrixRepeat(KisKernelSP kernel, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h,
91 KisChannelInfo::enumChannelFlags channelFlags);
92
93
94};
95#endif //KIS_CONVOLUTION_PAINTER_H_
KisPainter contains the graphics primitives necessary to draw on a KisPaintDevice.
Definition kis_painter.h:56