1 // This may look like C code, but it is really -*- C++ -*-
2 //
3 // Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
4 //
5 // Implementation of Montage
6 //
7
8 #define MAGICKCORE_IMPLEMENTATION 1
9 #define MAGICK_PLUSPLUS_IMPLEMENTATION 1
10
11 #include "Magick++/Include.h"
12 #include <string>
13 #include <string.h>
14
15 #include "Magick++/Montage.h"
16 #include "Magick++/Functions.h"
17
Montage(void)18 Magick::Montage::Montage(void)
19 : _backgroundColor("#ffffff"),
20 _fileName(),
21 _fill("#000000ff"),
22 _font(),
23 _geometry("120x120+4+3>"),
24 _gravity(CenterGravity),
25 _label(),
26 _pointSize(12),
27 _shadow(false),
28 _stroke(),
29 _texture(),
30 _tile("6x4"),
31 _title(),
32 _transparentColor()
33 {
34 }
35
~Montage(void)36 Magick::Montage::~Montage(void)
37 {
38 }
39
backgroundColor(const Magick::Color & backgroundColor_)40 void Magick::Montage::backgroundColor(const Magick::Color &backgroundColor_)
41 {
42 _backgroundColor=backgroundColor_;
43 }
44
backgroundColor(void) const45 Magick::Color Magick::Montage::backgroundColor(void) const
46 {
47 return(_backgroundColor);
48 }
49
fileName(const std::string & fileName_)50 void Magick::Montage::fileName(const std::string &fileName_)
51 {
52 _fileName=fileName_;
53 }
54
fileName(void) const55 std::string Magick::Montage::fileName(void) const
56 {
57 return(_fileName);
58 }
59
fillColor(const Color & fill_)60 void Magick::Montage::fillColor(const Color &fill_)
61 {
62 _fill=fill_;
63 }
64
fillColor(void) const65 Magick::Color Magick::Montage::fillColor(void) const
66 {
67 return(_fill);
68 }
69
font(const std::string & font_)70 void Magick::Montage::font(const std::string &font_)
71 {
72 _font=font_;
73 }
74
font(void) const75 std::string Magick::Montage::font(void) const
76 {
77 return(_font);
78 }
79
geometry(const Magick::Geometry & geometry_)80 void Magick::Montage::geometry(const Magick::Geometry &geometry_)
81 {
82 _geometry=geometry_;
83 }
84
geometry(void) const85 Magick::Geometry Magick::Montage::geometry(void) const
86 {
87 return(_geometry);
88 }
89
gravity(Magick::GravityType gravity_)90 void Magick::Montage::gravity(Magick::GravityType gravity_)
91 {
92 _gravity=gravity_;
93 }
94
gravity(void) const95 Magick::GravityType Magick::Montage::gravity(void) const
96 {
97 return(_gravity);
98 }
99
label(const std::string & label_)100 void Magick::Montage::label(const std::string &label_)
101 {
102 _label=label_;
103 }
104
label(void) const105 std::string Magick::Montage::label(void) const
106 {
107 return(_label);
108 }
109
pointSize(size_t pointSize_)110 void Magick::Montage::pointSize(size_t pointSize_)
111 {
112 _pointSize=pointSize_;
113 }
114
pointSize(void) const115 size_t Magick::Montage::pointSize(void) const
116 {
117 return(_pointSize);
118 }
119
shadow(bool shadow_)120 void Magick::Montage::shadow(bool shadow_)
121 {
122 _shadow=shadow_;
123 }
124
shadow(void) const125 bool Magick::Montage::shadow(void) const
126 {
127 return(_shadow);
128 }
129
strokeColor(const Color & stroke_)130 void Magick::Montage::strokeColor(const Color &stroke_)
131 {
132 _stroke=stroke_;
133 }
134
strokeColor(void) const135 Magick::Color Magick::Montage::strokeColor(void) const
136 {
137 return(_stroke);
138 }
139
texture(const std::string & texture_)140 void Magick::Montage::texture(const std::string &texture_)
141 {
142 _texture=texture_;
143 }
144
texture(void) const145 std::string Magick::Montage::texture(void) const
146 {
147 return(_texture);
148 }
149
tile(const Geometry & tile_)150 void Magick::Montage::tile(const Geometry &tile_)
151 {
152 _tile=tile_;
153 }
154
tile(void) const155 Magick::Geometry Magick::Montage::tile(void) const
156 {
157 return(_tile);
158 }
159
title(const std::string & title_)160 void Magick::Montage::title(const std::string &title_)
161 {
162 _title=title_;
163 }
164
title(void) const165 std::string Magick::Montage::title(void) const
166 {
167 return(_title);
168 }
169
transparentColor(const Magick::Color & transparentColor_)170 void Magick::Montage::transparentColor(const Magick::Color &transparentColor_)
171 {
172 _transparentColor=transparentColor_;
173 }
174
transparentColor(void) const175 Magick::Color Magick::Montage::transparentColor(void) const
176 {
177 return(_transparentColor);
178 }
179
updateMontageInfo(MontageInfo & montageInfo_) const180 void Magick::Montage::updateMontageInfo(MontageInfo &montageInfo_ ) const
181 {
182 (void) MagickCore::ResetMagickMemory(&montageInfo_,0,sizeof(montageInfo_));
183
184 // alpha_color
185 montageInfo_.alpha_color=Color();
186 // background_color
187 montageInfo_.background_color=_backgroundColor;
188 // border_color
189 montageInfo_.border_color=Color();
190 // border_width
191 montageInfo_.border_width=0;
192 // filename
193 if (_font.length() != 0)
194 {
195 _fileName.copy(montageInfo_.filename,MagickPathExtent-1);
196 montageInfo_.filename[ _fileName.length() ] = 0; // null terminate
197 }
198 // fill
199 montageInfo_.fill=_fill;
200 // font
201 if (_font.length() != 0)
202 Magick::CloneString(&montageInfo_.font,_font);
203 // geometry
204 if (_geometry.isValid())
205 Magick::CloneString(&montageInfo_.geometry,_geometry);
206 // gravity
207 montageInfo_.gravity=_gravity;
208 // pointsize
209 montageInfo_.pointsize=_pointSize;
210 // shadow
211 montageInfo_.shadow=static_cast<MagickBooleanType>
212 (_shadow ? MagickTrue : MagickFalse);
213 // signature (validity stamp)
214 montageInfo_.signature=MagickCoreSignature;
215 // stroke
216 montageInfo_.stroke=_stroke;
217 // texture
218 if (_texture.length() != 0)
219 Magick::CloneString(&montageInfo_.texture,_texture);
220 // tile
221 if (_tile.isValid())
222 Magick::CloneString(&montageInfo_.tile,_tile);
223 // title
224 if (_title.length() != 0)
225 Magick::CloneString(&montageInfo_.title,_title);
226 }
227
228 //
229 // Implementation of MontageFramed
230 //
231
MontageFramed(void)232 Magick::MontageFramed::MontageFramed(void)
233 : _alphaColor("#bdbdbd"),
234 _borderColor("#dfdfdf"),
235 _borderWidth(0),
236 _frame()
237 {
238 }
239
~MontageFramed(void)240 Magick::MontageFramed::~MontageFramed(void)
241 {
242 }
243
alphaColor(const Magick::Color & alphaColor_)244 void Magick::MontageFramed::alphaColor(const Magick::Color &alphaColor_)
245 {
246 _alphaColor=alphaColor_;
247 }
248
alphaColor(void) const249 Magick::Color Magick::MontageFramed::alphaColor(void) const
250 {
251 return(_alphaColor);
252 }
253
borderColor(const Magick::Color & borderColor_)254 void Magick::MontageFramed::borderColor(const Magick::Color &borderColor_)
255 {
256 _borderColor=borderColor_;
257 }
258
borderColor(void) const259 Magick::Color Magick::MontageFramed::borderColor(void) const
260 {
261 return(_borderColor);
262 }
263
borderWidth(size_t borderWidth_)264 void Magick::MontageFramed::borderWidth(size_t borderWidth_)
265 {
266 _borderWidth=borderWidth_;
267 }
268
borderWidth(void) const269 size_t Magick::MontageFramed::borderWidth(void) const
270 {
271 return(_borderWidth);
272 }
273
frameGeometry(const Magick::Geometry & frame_)274 void Magick::MontageFramed::frameGeometry(const Magick::Geometry &frame_)
275 {
276 _frame=frame_;
277 }
278
frameGeometry(void) const279 Magick::Geometry Magick::MontageFramed::frameGeometry(void) const
280 {
281 return(_frame);
282 }
283
updateMontageInfo(MontageInfo & montageInfo_) const284 void Magick::MontageFramed::updateMontageInfo(MontageInfo &montageInfo_) const
285 {
286 // Do base updates
287 Montage::updateMontageInfo(montageInfo_);
288
289 // alpha_color
290 montageInfo_.alpha_color = _alphaColor;
291 // border_color
292 montageInfo_.border_color=_borderColor;
293 // border_width
294 montageInfo_.border_width=_borderWidth;
295 // frame
296 if (_frame.isValid())
297 Magick::CloneString(&montageInfo_.frame,_frame);
298 }
299