Debian Codegraph @

extern/agg24-svn/include/ctrl/agg_gamma_spline.h

raw
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: [email protected]
12 // [email protected]
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
15 //
16 // class gamma_spline
17 //
18 //----------------------------------------------------------------------------
19
20 #ifndef AGG_GAMMA_SPLINE_INCLUDED
21 #define AGG_GAMMA_SPLINE_INCLUDED
22
23 #include "agg_basics.h"
24 #include "agg_bspline.h"
25
26 namespace agg
27 {
28
29 //------------------------------------------------------------------------
30 // Class-helper for calculation gamma-correction arrays. A gamma-correction
31 // array is an array of 256 unsigned chars that determine the actual values
32 // of Anti-Aliasing for each pixel coverage value from 0 to 255. If all the
33 // values in the array are equal to its index, i.e. 0,1,2,3,... there's
34 // no gamma-correction. Class agg::polyfill allows you to use custom
35 // gamma-correction arrays. You can calculate it using any approach, and
36 // class gamma_spline allows you to calculate almost any reasonable shape
37 // of the gamma-curve with using only 4 values - kx1, ky1, kx2, ky2.
38 //
39 // kx2
40 // +----------------------------------+
41 // | | | . |
42 // | | | . | ky2
43 // | | . ------|
44 // | | . |
45 // | | . |
46 // |----------------.|----------------|
47 // | . | |
48 // | . | |
49 // |-------. | |
50 // ky1 | . | | |
51 // | . | | |
52 // +----------------------------------+
53 // kx1
54 //
55 // Each value can be in range [0...2]. Value 1.0 means one quarter of the
56 // bounding rectangle. Function values() calculates the curve by these
57 // 4 values. After calling it one can get the gamma-array with call gamma().
58 // Class also supports the vertex source interface, i.e rewind() and
59 // vertex(). It's made for convinience and used in class gamma_ctrl.
60 // Before calling rewind/vertex one must set the bounding box
61 // box() using pixel coordinates.
62 //------------------------------------------------------------------------
63
64 class gamma_spline
65 {
66 public:
67 gamma_spline();
68
69 void values(double kx1, double ky1, double kx2, double ky2);
70 const unsigned char* gamma() const { return m_gamma; }
71 double y(double x) const;
72 void values(double* kx1, double* ky1, double* kx2, double* ky2) const;
73 void box(double x1, double y1, double x2, double y2);
74
75 void rewind(unsigned);
76 unsigned vertex(double* x, double* y);
77
78 private:
79 unsigned char m_gamma[256];
80 double m_x[4];
81 double m_y[4];
82 bspline m_spline;
83 double m_x1;
84 double m_y1;
85 double m_x2;
86 double m_y2;
87 double m_cur_x;
88 };
89
90
91
92
93 }
94
95 #endif