1 #ifndef __NR_FILTER_GAUSSIAN_H__
2 #define __NR_FILTER_GAUSSIAN_H__
4 /*
5 * Gaussian blur renderer
6 *
7 * Author:
8 * Niko Kiirala <niko@kiirala.com>
9 *
10 * Copyright (C) 2006 Niko Kiirala
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include "display/nr-filter-primitive.h"
16 #include "libnr/nr-pixblock.h"
17 #include "libnr/nr-matrix.h"
19 namespace NR {
21 class FilterGaussian : public FilterPrimitive {
22 public:
23 FilterGaussian();
24 static FilterPrimitive *create();
26 virtual int render(NRPixBlock **pb, Matrix const &trans);
27 virtual int get_enlarge(Matrix const &m);
29 /**
30 * Set the standard deviation value for gaussian blur. Deviation along
31 * both axis is set to the provided value.
32 * Negative value, NaN and infinity are considered an error and no
33 * changes to filter state are made. If not set, default value of zero
34 * is used, which means the filter results in transparent black image.
35 */
36 void set_deviation(double deviation);
37 /**
38 * Set the standard deviation value for gaussian blur. First parameter
39 * sets the deviation alogn x-axis, second along y-axis.
40 * Negative value, NaN and infinity are considered an error and no
41 * changes to filter state are made. If not set, default value of zero
42 * is used, which means the filter results in transparent black image.
43 */
44 void set_deviation(double x, double y);
46 private:
47 double _deviation_x;
48 double _deviation_y;
50 int _kernel_size(Matrix const &trans);
51 void _make_kernel(double *kernel, double deviation, double expansion);
52 int _effect_area_scr_x(Matrix const &trans);
53 int _effect_area_scr_y(Matrix const &trans);
54 int _effect_subsample_step(int scr_len_x);
55 int _effect_subsample_step_log2(int scr_len_x);
57 inline int _min(int const a, int const b)
58 {
59 return ((a < b) ? a : b);
60 }
61 inline int _max(int const a, int const b)
62 {
63 return ((a > b) ? a : b);
64 }
65 };
68 } /* namespace NR */
73 #endif /* __NR_FILTER_GAUSSIAN_H__ */
74 /*
75 Local Variables:
76 mode:c++
77 c-file-style:"stroustrup"
78 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
79 indent-tabs-mode:nil
80 fill-column:99
81 End:
82 */
83 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :