Magick++  7.1.0
Montage.cpp
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, 2003
4 //
5 // Copyright @ 2014 ImageMagick Studio LLC, a non-profit organization
6 // dedicated to making software imaging solutions freely available.
7 //
8 // Implementation of Montage
9 //
10 
11 #define MAGICKCORE_IMPLEMENTATION 1
12 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
13 
14 #include "Magick++/Include.h"
15 #include <string>
16 #include <string.h>
17 
18 #include "Magick++/Montage.h"
19 #include "Magick++/Functions.h"
20 
22  : _backgroundColor("#ffffff"),
23  _fileName(),
24  _fill("#000000ff"),
25  _font(),
26  _geometry("120x120+4+3>"),
27  _gravity(CenterGravity),
28  _label(),
29  _pointSize(12),
30  _shadow(false),
31  _stroke(),
32  _texture(),
33  _tile("6x4"),
34  _title(),
35  _transparentColor()
36 {
37 }
38 
40 {
41 }
42 
43 void Magick::Montage::backgroundColor(const Magick::Color &backgroundColor_)
44 {
45  _backgroundColor=backgroundColor_;
46 }
47 
49 {
50  return(_backgroundColor);
51 }
52 
53 void Magick::Montage::fileName(const std::string &fileName_)
54 {
55  _fileName=fileName_;
56 }
57 
58 std::string Magick::Montage::fileName(void) const
59 {
60  return(_fileName);
61 }
62 
64 {
65  _fill=fill_;
66 }
67 
69 {
70  return(_fill);
71 }
72 
73 void Magick::Montage::font(const std::string &font_)
74 {
75  _font=font_;
76 }
77 
78 std::string Magick::Montage::font(void) const
79 {
80  return(_font);
81 }
82 
84 {
85  _geometry=geometry_;
86 }
87 
89 {
90  return(_geometry);
91 }
92 
93 void Magick::Montage::gravity(Magick::GravityType gravity_)
94 {
95  _gravity=gravity_;
96 }
97 
98 Magick::GravityType Magick::Montage::gravity(void) const
99 {
100  return(_gravity);
101 }
102 
103 void Magick::Montage::label(const std::string &label_)
104 {
105  _label=label_;
106 }
107 
108 std::string Magick::Montage::label(void) const
109 {
110  return(_label);
111 }
112 
113 void Magick::Montage::pointSize(size_t pointSize_)
114 {
115  _pointSize=pointSize_;
116 }
117 
118 size_t Magick::Montage::pointSize(void) const
119 {
120  return(_pointSize);
121 }
122 
123 void Magick::Montage::shadow(bool shadow_)
124 {
125  _shadow=shadow_;
126 }
127 
128 bool Magick::Montage::shadow(void) const
129 {
130  return(_shadow);
131 }
132 
134 {
135  _stroke=stroke_;
136 }
137 
139 {
140  return(_stroke);
141 }
142 
143 void Magick::Montage::texture(const std::string &texture_)
144 {
145  _texture=texture_;
146 }
147 
148 std::string Magick::Montage::texture(void) const
149 {
150  return(_texture);
151 }
152 
153 void Magick::Montage::tile(const Geometry &tile_)
154 {
155  _tile=tile_;
156 }
157 
159 {
160  return(_tile);
161 }
162 
163 void Magick::Montage::title(const std::string &title_)
164 {
165  _title=title_;
166 }
167 
168 std::string Magick::Montage::title(void) const
169 {
170  return(_title);
171 }
172 
173 void Magick::Montage::transparentColor(const Magick::Color &transparentColor_)
174 {
175  _transparentColor=transparentColor_;
176 }
177 
179 {
180  return(_transparentColor);
181 }
182 
183 void Magick::Montage::updateMontageInfo(MontageInfo &montageInfo_ ) const
184 {
185  (void) memset(&montageInfo_,0,sizeof(montageInfo_));
186 
187  // matte_color
188  montageInfo_.matte_color=Color();
189  // background_color
190  montageInfo_.background_color=_backgroundColor;
191  // border_color
192  montageInfo_.border_color=Color();
193  // border_width
194  montageInfo_.border_width=0;
195  // filename
196  if (_font.length() != 0)
197  {
198  _fileName.copy(montageInfo_.filename,MagickPathExtent-1);
199  montageInfo_.filename[ _fileName.length() ] = 0; // null terminate
200  }
201  // fill
202  montageInfo_.fill=_fill;
203  // font
204  if (_font.length() != 0)
205  Magick::CloneString(&montageInfo_.font,_font);
206  // geometry
207  if (_geometry.isValid())
208  Magick::CloneString(&montageInfo_.geometry,_geometry);
209  // gravity
210  montageInfo_.gravity=_gravity;
211  // pointsize
212  montageInfo_.pointsize=_pointSize;
213  // shadow
214  montageInfo_.shadow=static_cast<MagickBooleanType>
215  (_shadow ? MagickTrue : MagickFalse);
216  // signature (validity stamp)
217  montageInfo_.signature=MagickCoreSignature;
218  // stroke
219  montageInfo_.stroke=_stroke;
220  // texture
221  if (_texture.length() != 0)
222  Magick::CloneString(&montageInfo_.texture,_texture);
223  // tile
224  if (_tile.isValid())
225  Magick::CloneString(&montageInfo_.tile,_tile);
226  // title
227  if (_title.length() != 0)
228  Magick::CloneString(&montageInfo_.title,_title);
229 }
230 
231 //
232 // Implementation of MontageFramed
233 //
234 
236  : _matteColor("#bdbdbd"),
237  _borderColor("#dfdfdf"),
238  _borderWidth(0),
239  _frame()
240 {
241 }
242 
244 {
245 }
246 
248 {
249  _matteColor=matteColor_;
250 }
251 
253 {
254  return(_matteColor);
255 }
256 
258 {
259  _borderColor=borderColor_;
260 }
261 
263 {
264  return(_borderColor);
265 }
266 
267 void Magick::MontageFramed::borderWidth(size_t borderWidth_)
268 {
269  _borderWidth=borderWidth_;
270 }
271 
273 {
274  return(_borderWidth);
275 }
276 
278 {
279  _frame=frame_;
280 }
281 
283 {
284  return(_frame);
285 }
286 
287 void Magick::MontageFramed::updateMontageInfo(MontageInfo &montageInfo_) const
288 {
289  // Do base updates
290  Montage::updateMontageInfo(montageInfo_);
291 
292  // matte_color
293  montageInfo_.matte_color = _matteColor;
294  // border_color
295  montageInfo_.border_color=_borderColor;
296  // border_width
297  montageInfo_.border_width=_borderWidth;
298  // frame
299  if (_frame.isValid())
300  Magick::CloneString(&montageInfo_.frame,_frame);
301 }
class MagickPPExport Color
Definition: Color.h:18
GravityType gravity(void) const
Definition: Montage.cpp:98
std::string texture(void) const
Definition: Montage.cpp:148
Geometry frameGeometry(void) const
Definition: Montage.cpp:282
size_t borderWidth(void) const
Definition: Montage.cpp:272
Color fillColor(void) const
Definition: Montage.cpp:68
Color matteColor(void) const
Definition: Montage.cpp:252
size_t pointSize(void) const
Definition: Montage.cpp:118
virtual ~Montage(void)
Definition: Montage.cpp:39
Color backgroundColor(void) const
Definition: Montage.cpp:48
std::string font(void) const
Definition: Montage.cpp:78
std::string fileName(void) const
Definition: Montage.cpp:58
Color borderColor(void) const
Definition: Montage.cpp:262
Color transparentColor(void) const
Definition: Montage.cpp:178
Geometry geometry(void) const
Definition: Montage.cpp:88
std::string title(void) const
Definition: Montage.cpp:168
MagickPPExport void CloneString(char **destination_, const std::string &source_)
Definition: Functions.cpp:25
Geometry tile(void) const
Definition: Montage.cpp:158
void updateMontageInfo(MagickCore::MontageInfo &montageInfo_) const
Definition: Montage.cpp:287
virtual void updateMontageInfo(MagickCore::MontageInfo &montageInfo_) const
Definition: Montage.cpp:183
Color strokeColor(void) const
Definition: Montage.cpp:138
bool shadow(void) const
Definition: Montage.cpp:128
std::string label(void) const
Definition: Montage.cpp:108