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 "display/nr-filter-units.h"
18 #include "libnr/nr-rect-l.h"
19 #include <vector>
21 namespace Inkscape {
22 namespace Filters {
24 enum FilterConvolveMatrixEdgeMode {
25 CONVOLVEMATRIX_EDGEMODE_DUPLICATE,
26 CONVOLVEMATRIX_EDGEMODE_WRAP,
27 CONVOLVEMATRIX_EDGEMODE_NONE,
28 CONVOLVEMATRIX_EDGEMODE_ENDTYPE
29 };
31 class FilterConvolveMatrix : public FilterPrimitive {
32 public:
33 FilterConvolveMatrix();
34 static FilterPrimitive *create();
35 virtual ~FilterConvolveMatrix();
37 virtual int render(FilterSlot &slot, FilterUnits const &units);
38 virtual void area_enlarge(NRRectL &area, Geom::Matrix const &trans);
39 virtual FilterTraits get_input_traits();
41 void set_targetY(int coord);
42 void set_targetX(int coord);
43 void set_orderY(int coord);
44 void set_orderX(int coord);
45 void set_kernelMatrix(std::vector<gdouble>& km);
46 void set_bias(double b);
47 void set_divisor(double d);
48 void set_edgeMode(FilterConvolveMatrixEdgeMode mode);
49 void set_preserveAlpha(bool pa);
51 private:
52 std::vector<gdouble> kernelMatrix;
53 int targetX, targetY;
54 int orderX, orderY;
55 gdouble divisor, bias;
56 int dx, dy, kernelUnitLength;
57 FilterConvolveMatrixEdgeMode edgeMode;
58 bool preserveAlpha;
59 };
61 } /* namespace Filters */
62 } /* namespace Inkscape */
64 #endif /* __NR_FILTER_CONVOLVE_MATRIX_H__ */
65 /*
66 Local Variables:
67 mode:c++
68 c-file-style:"stroustrup"
69 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
70 indent-tabs-mode:nil
71 fill-column:99
72 End:
73 */
74 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :