1 #ifndef __NR_FILTER_CONVOLVE_MATRIX_H__
2 #define __NR_FILTER_CONVOLVE_MATRIX_H__
4 /*
5 * feConvolveMatrix filter primitive renderer
6 *
7 * Authors:
8 * Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
9 *
10 * Copyright (C) 2007 authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include "display/nr-filter-primitive.h"
16 #include "display/nr-filter-slot.h"
17 #include "libnr/nr-matrix.h"
18 #include "libnr/nr-rect-l.h"
19 #include <vector>
21 namespace NR {
23 enum FilterConvolveMatrixEdgeMode {
24 CONVOLVEMATRIX_EDGEMODE_DUPLICATE,
25 CONVOLVEMATRIX_EDGEMODE_WRAP,
26 CONVOLVEMATRIX_EDGEMODE_NONE,
27 CONVOLVEMATRIX_EDGEMODE_ENDTYPE
28 };
30 class FilterConvolveMatrix : public FilterPrimitive {
31 public:
32 FilterConvolveMatrix();
33 static FilterPrimitive *create();
34 virtual ~FilterConvolveMatrix();
36 virtual int render(FilterSlot &slot, Matrix const &trans);
37 virtual void area_enlarge(NRRectL &area, Matrix const &trans);
39 void set_targetY(int coord);
40 void set_targetX(int coord);
41 void set_orderY(int coord);
42 void set_orderX(int coord);
43 void set_kernelMatrix(std::vector<gdouble>& km);
44 void set_bias(double b);
45 void set_divisor(double d);
46 void set_edgeMode(FilterConvolveMatrixEdgeMode mode);
47 void set_preserveAlpha(bool pa);
49 private:
50 std::vector<gdouble> kernelMatrix;
51 int targetX, targetY;
52 int orderX, orderY;
53 gdouble divisor, bias;
54 int dx, dy, kernelUnitLength;
55 FilterConvolveMatrixEdgeMode edgeMode;
56 bool preserveAlpha;
57 };
59 } /* namespace NR */
61 #endif /* __NR_FILTER_CONVOLVE_MATRIX_H__ */
62 /*
63 Local Variables:
64 mode:c++
65 c-file-style:"stroustrup"
66 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
67 indent-tabs-mode:nil
68 fill-column:99
69 End:
70 */
71 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :