Code

f6afc109b114f1608e62b38176b0efca20364afc
[inkscape.git] / src / display / nr-filter-gaussian.h
1 #ifndef __NR_FILTER_GAUSSIAN_H__
2 #define __NR_FILTER_GAUSSIAN_H__
4 /*
5  * Gaussian blur renderer
6  *
7  * Authors:
8  *   Niko Kiirala <niko@kiirala.com>
9  *   bulia byak
10  *   Jasper van de Gronde <th.v.d.gronde@hccnet.nl>
11  *
12  * Copyright (C) 2006 authors
13  *
14  * Released under GNU GPL, read the file 'COPYING' for more information
15  */
17 #include "display/nr-filter-primitive.h"
18 #include "display/nr-filter-slot.h"
19 #include "libnr/nr-pixblock.h"
20 #include "libnr/nr-matrix.h"
22 enum {
23     BLUR_QUALITY_BEST = 2,
24     BLUR_QUALITY_BETTER = 1,
25     BLUR_QUALITY_NORMAL = 0,
26     BLUR_QUALITY_WORSE = -1,
27     BLUR_QUALITY_WORST = -2
28 };
30 namespace NR {
32 class FilterGaussian : public FilterPrimitive {
33 public:
34     FilterGaussian();
35     static FilterPrimitive *create();
36     virtual ~FilterGaussian();
38     virtual int render(FilterSlot &slot, Matrix const &trans);
39     virtual int get_enlarge(Matrix const &m);
41     /**
42      * Set the standard deviation value for gaussian blur. Deviation along
43      * both axis is set to the provided value.
44      * Negative value, NaN and infinity are considered an error and no
45      * changes to filter state are made. If not set, default value of zero
46      * is used, which means the filter results in transparent black image.
47      */
48     void set_deviation(double deviation);
49     /**
50      * Set the standard deviation value for gaussian blur. First parameter
51      * sets the deviation alogn x-axis, second along y-axis.
52      * Negative value, NaN and infinity are considered an error and no
53      * changes to filter state are made. If not set, default value of zero
54      * is used, which means the filter results in transparent black image.
55      */
56     void set_deviation(double x, double y);
58 private:
59     double _deviation_x;
60     double _deviation_y;
62     int _kernel_size(double expansionX, double expansionY);
63     void _make_kernel(double *kernel, double deviation, double expansion);
64     int _effect_area_scr(double deviation, double expansion);
65     int _effect_subsample_step(int scr_len_x, int quality);
66     int _effect_subsample_step_log2(int scr_len_x, int quality);
68     inline int _min(int const a, int const b)
69     {
70         return ((a < b) ? a : b);
71     }
72     inline int _max(int const a, int const b)
73     {
74         return ((a > b) ? a : b);
75     }
76 };
79 } /* namespace NR */
84 #endif /* __NR_FILTER_GAUSSIAN_H__ */
85 /*
86   Local Variables:
87   mode:c++
88   c-file-style:"stroustrup"
89   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
90   indent-tabs-mode:nil
91   fill-column:99
92   End:
93 */
94 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :