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
18Magick::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
36Magick::Montage::~Montage(void)
37{
38}
39
40void Magick::Montage::backgroundColor(const Magick::Color &backgroundColor_)
41{
42  _backgroundColor=backgroundColor_;
43}
44
45Magick::Color Magick::Montage::backgroundColor(void) const
46{
47  return(_backgroundColor);
48}
49
50void Magick::Montage::fileName(const std::string &fileName_)
51{
52  _fileName=fileName_;
53}
54
55std::string Magick::Montage::fileName(void) const
56{
57  return(_fileName);
58}
59
60void Magick::Montage::fillColor(const Color &fill_)
61{
62  _fill=fill_;
63}
64
65Magick::Color Magick::Montage::fillColor(void) const
66{
67  return(_fill);
68}
69
70void Magick::Montage::font(const std::string &font_)
71{
72  _font=font_;
73}
74
75std::string Magick::Montage::font(void) const
76{
77  return(_font);
78}
79
80void Magick::Montage::geometry(const Magick::Geometry &geometry_)
81{
82  _geometry=geometry_;
83}
84
85Magick::Geometry Magick::Montage::geometry(void) const
86{
87  return(_geometry);
88}
89
90void Magick::Montage::gravity(Magick::GravityType gravity_)
91{
92  _gravity=gravity_;
93}
94
95Magick::GravityType Magick::Montage::gravity(void) const
96{
97  return(_gravity);
98}
99
100void Magick::Montage::label(const std::string &label_)
101{
102  _label=label_;
103}
104
105std::string Magick::Montage::label(void) const
106{
107  return(_label);
108}
109
110void Magick::Montage::pointSize(size_t pointSize_)
111{
112  _pointSize=pointSize_;
113}
114
115size_t Magick::Montage::pointSize(void) const
116{
117  return(_pointSize);
118}
119
120void Magick::Montage::shadow(bool shadow_)
121{
122  _shadow=shadow_;
123}
124
125bool Magick::Montage::shadow(void) const
126{
127  return(_shadow);
128}
129
130void Magick::Montage::strokeColor(const Color &stroke_)
131{
132  _stroke=stroke_;
133}
134
135Magick::Color Magick::Montage::strokeColor(void) const
136{
137  return(_stroke);
138}
139
140void Magick::Montage::texture(const std::string &texture_)
141{
142  _texture=texture_;
143}
144
145std::string Magick::Montage::texture(void) const
146{
147  return(_texture);
148}
149
150void Magick::Montage::tile(const Geometry &tile_)
151{
152  _tile=tile_;
153}
154
155Magick::Geometry Magick::Montage::tile(void) const
156{
157  return(_tile);
158}
159
160void Magick::Montage::title(const std::string &title_)
161{
162  _title=title_;
163}
164
165std::string Magick::Montage::title(void) const
166{
167  return(_title);
168}
169
170void Magick::Montage::transparentColor(const Magick::Color &transparentColor_)
171{
172  _transparentColor=transparentColor_;
173}
174
175Magick::Color Magick::Montage::transparentColor(void) const
176{
177  return(_transparentColor);
178}
179
180void 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
232Magick::MontageFramed::MontageFramed(void)
233  : _alphaColor("#bdbdbd"),
234    _borderColor("#dfdfdf"),
235    _borderWidth(0),
236    _frame()
237{
238}
239
240Magick::MontageFramed::~MontageFramed(void)
241{
242}
243
244void Magick::MontageFramed::alphaColor(const Magick::Color &alphaColor_)
245{
246  _alphaColor=alphaColor_;
247}
248
249Magick::Color Magick::MontageFramed::alphaColor(void) const
250{
251  return(_alphaColor);
252}
253
254void Magick::MontageFramed::borderColor(const Magick::Color &borderColor_)
255{
256  _borderColor=borderColor_;
257}
258
259Magick::Color Magick::MontageFramed::borderColor(void) const
260{
261  return(_borderColor);
262}
263
264void Magick::MontageFramed::borderWidth(size_t borderWidth_)
265{
266  _borderWidth=borderWidth_;
267}
268
269size_t Magick::MontageFramed::borderWidth(void) const
270{
271  return(_borderWidth);
272}
273
274void Magick::MontageFramed::frameGeometry(const Magick::Geometry &frame_)
275{
276  _frame=frame_;
277}
278
279Magick::Geometry Magick::MontageFramed::frameGeometry(void) const
280{
281  return(_frame);
282}
283
284void 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