Magick++  7.0.10
Geometry.h
Go to the documentation of this file.
1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002
4 // Copyright Dirk Lemstra 2014
5 //
6 // Geometry Definition
7 //
8 // Representation of an ImageMagick geometry specification
9 // X11 geometry specification plus hints
10 
11 #if !defined (Magick_Geometry_header)
12 #define Magick_Geometry_header
13 
14 #include "Magick++/Include.h"
15 #include <string>
16 
17 namespace Magick
18 {
20 
21  // Compare two Geometry objects regardless of LHS/RHS
22  MagickPPExport int operator ==
23  (const Magick::Geometry& left_,const Magick::Geometry& right_);
24  MagickPPExport int operator !=
25  (const Magick::Geometry& left_,const Magick::Geometry& right_);
26  MagickPPExport int operator >
27  (const Magick::Geometry& left_,const Magick::Geometry& right_);
28  MagickPPExport int operator <
29  (const Magick::Geometry& left_,const Magick::Geometry& right_);
30  MagickPPExport int operator >=
31  (const Magick::Geometry& left_,const Magick::Geometry& right_);
32  MagickPPExport int operator <=
33  (const Magick::Geometry& left_,const Magick::Geometry& right_);
34 
36  {
37  public:
38 
39  // Default constructor
40  Geometry();
41 
42  // Construct Geometry from specified string
43  Geometry(const char *geometry_);
44 
45  // Copy constructor
46  Geometry(const Geometry &geometry_);
47 
48  // Construct Geometry from specified string
49  Geometry(const std::string &geometry_);
50 
51  // Construct Geometry from specified dimensions
52  Geometry(size_t width_,size_t height_,::ssize_t xOff_=0,
53  ::ssize_t yOff_=0);
54 
55  // Destructor
56  ~Geometry(void);
57 
58  // Set via geometry string
59  const Geometry& operator=(const char *geometry_);
60 
61  // Assignment operator
62  Geometry& operator=(const Geometry& Geometry_);
63 
64  // Set via geometry string
65  const Geometry& operator=(const std::string &geometry_);
66 
67  // Return geometry string
68  operator std::string() const;
69 
70  // Resize without preserving aspect ratio (!)
71  void aspect(bool aspect_);
72  bool aspect(void) const;
73 
74  // Resize the image based on the smallest fitting dimension (^)
75  void fillArea(bool fillArea_);
76  bool fillArea(void) const;
77 
78  // Resize if image is greater than size (>)
79  void greater(bool greater_);
80  bool greater(void) const;
81 
82  // Height
83  void height(size_t height_);
84  size_t height(void) const;
85 
86  // Does object contain valid geometry?
87  void isValid(bool isValid_);
88  bool isValid(void) const;
89 
90  // Resize if image is less than size (<)
91  void less(bool less_);
92  bool less(void) const;
93 
94  // Resize using a pixel area count limit (@)
95  void limitPixels(bool limitPixels_);
96  bool limitPixels(void) const;
97 
98  // Width and height are expressed as percentages
99  void percent(bool percent_);
100  bool percent(void) const;
101 
102  // Width
103  void width(size_t width_);
104  size_t width(void) const;
105 
106  // X offset from origin
107  void xOff(::ssize_t xOff_);
108  ::ssize_t xOff(void) const;
109 
110  // Y offset from origin
111  void yOff(::ssize_t yOff_);
112  ::ssize_t yOff(void) const;
113 
114  //
115  // Public methods below this point are for Magick++ use only.
116  //
117 
118  // Construct from RectangleInfo
119  Geometry(const MagickCore::RectangleInfo &rectangle_);
120 
121  // Set via RectangleInfo
122  const Geometry& operator=(const MagickCore::RectangleInfo &rectangle_);
123 
124  // Return an ImageMagick RectangleInfo struct
125  operator MagickCore::RectangleInfo() const;
126 
127  private:
128  size_t _width;
129  size_t _height;
130  ::ssize_t _xOff;
131  ::ssize_t _yOff;
132  bool _isValid;
133  bool _percent; // Interpret width & height as percentages (%)
134  bool _aspect; // Force exact size (!)
135  bool _greater; // Resize only if larger than geometry (>)
136  bool _less; // Resize only if smaller than geometry (<)
137  bool _fillArea; // Resize the image based on the smallest fitting dimension (^)
138  bool _limitPixels; // Resize using a pixel area count limit (@)
139  };
140 
142 
143  // Compare two Offset objects
144  MagickPPExport int operator ==
145  (const Magick::Offset& left_,const Magick::Offset& right_);
146  MagickPPExport int operator !=
147  (const Magick::Offset& left_,const Magick::Offset& right_);
148 
150  {
151  public:
152 
153  // Default constructor
154  Offset();
155 
156  // Construct Offset from specified string
157  Offset(const char *offset_);
158 
159  // Copy constructor
160  Offset(const Offset &offset_);
161 
162  // Construct Offset from specified string
163  Offset(const std::string &offset_);
164 
165  // Construct Offset from specified x and y
166  Offset(ssize_t x_,ssize_t y_);
167 
168  // Destructor
169  ~Offset(void);
170 
171  // Set via offset string
172  const Offset& operator=(const char *offset_);
173 
174  // Assignment operator
175  Offset& operator=(const Offset& offset_);
176 
177  // Set via offset string
178  const Offset& operator=(const std::string &offset_);
179 
180  // X offset from origin
181  ssize_t x(void) const;
182 
183  // Y offset from origin
184  ssize_t y(void) const;
185 
186  //
187  // Public methods below this point are for Magick++ use only.
188  //
189 
190  // Return an ImageMagick OffsetInfo struct
191  operator MagickCore::OffsetInfo() const;
192 
193  private:
194  ssize_t _x;
195  ssize_t _y;
196  };
197 
199 
200  // Compare two Point objects
201  MagickPPExport int operator ==
202  (const Magick::Point& left_,const Magick::Point& right_);
203  MagickPPExport int operator !=
204  (const Magick::Point& left_,const Magick::Point& right_);
205 
207  {
208  public:
209 
210  // Default constructor
211  Point();
212 
213  // Construct Point from specified string
214  Point(const char *point_);
215 
216  // Copy constructor
217  Point(const Point &point_);
218 
219  // Construct Point from specified string
220  Point(const std::string &point_);
221 
222  // Construct Point from specified x and y
223  Point(double x_,double y_);
224 
225  // Construct Point from specified x y
226  Point(double xy_);
227 
228  // Destructor
229  ~Point(void);
230 
231  // Set via point string
232  const Point& operator=(const char *point_);
233 
234  // Set via double value
235  const Point& operator=(double xy_);
236 
237  // Assignment operator
238  Point& operator=(const Point& point_);
239 
240  // Set via point string
241  const Point& operator=(const std::string &point_);
242 
243  // Return point string
244  operator std::string() const;
245 
246  // Does object contain valid point?
247  bool isValid() const;
248 
249  // X offset from origin
250  double x(void) const;
251 
252  // Y offset from origin
253  double y(void) const;
254 
255  private:
256  double _x;
257  double _y;
258  };
259 } // namespace Magick
260 
261 #endif // Magick_Geometry_header
class MagickPPExport Offset
Definition: Geometry.h:141
#define MagickPPExport
Definition: Include.h:281
class MagickPPExport Geometry
Definition: Geometry.h:19
class MagickPPExport Point
Definition: Geometry.h:198
Definition: Blob.h:15