synfig-core  1.0.3
synfig/blur.h
Go to the documentation of this file.
1 /* === S Y N F I G ========================================================= */
22 /* ========================================================================= */
23 
24 /* === S T A R T =========================================================== */
25 
26 #ifndef __SYNFIG_BLUR_HELPER_H
27 #define __SYNFIG_BLUR_HELPER_H
28 
29 /* === H E A D E R S ======================================================= */
30 #include <synfig/surface.h>
31 #include <synfig/color.h>
32 #include <synfig/vector.h>
33 
34 /* === M A C R O S ========================================================= */
35 
36 /* === T Y P E D E F S ===================================================== */
37 
38 /* === C L A S S E S & S T R U C T S ======================================= */
39 using namespace synfig;
40 using namespace std;
41 using namespace etl;
42 
43 class Blur
44 {
45 public:
46  enum Type
47  {
48  BOX =0,
49  FASTGAUSSIAN =1,
50  CROSS =2,
51  GAUSSIAN =3,
52  DISC =4,
53 
54  FORCE_DWORD = 0x8fffffff
55  };
56 
57 private:
58  Point size;
59  int type;
60 
61  ProgressCallback *cb;
62 
63 public:
64  Point & set_size(const Point &v) { return (size = v); }
65  const Point & get_size() const { return size; }
66  Point & get_size() { return size; }
67 
68  int & set_type(const int &t) { return (type = t); }
69  const int & get_type() const { return type; }
70  int & get_type() { return type; }
71 
72  Blur(): type(), cb() {}
73  Blur(const Point &s, int t, ProgressCallback *callb=0):size(s), type(t), cb(callb) {}
74  Blur(Real sx, Real sy, int t, ProgressCallback *callb = 0): size(sx,sy), type(t), cb(callb) {}
75 
76  //Parametric Blur
77  Point operator()(const Point &p) const;
78  Point operator()(Real x, Real y) const;
79 
80  //Surface based blur
81  // input surface can be the same as output surface,
82  // though both have to be the same size
83  bool operator()(const Surface &surface, const Vector &resolution, Surface &out) const;
84  bool operator()(cairo_surface_t *surface, const Vector &resolution, cairo_surface_t *out) const;
85 
86  bool operator()(const etl::surface<float> &surface, const Vector &resolution, etl::surface<float> &out) const;
87  //bool operator()(const etl::surface<unsigned char> &surface, const Vector &resolution, etl::surface<unsigned char> &out) const;
88 };
89 
90 /* === E N D =============================================================== */
91 
92 #endif