Magick++: Geometry.h Source File

Magick++ 7.1.0

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