1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
/**
* Copyright: Mike Wey 2011
* License: zlib (See accompanying LICENSE file)
* Authors: Mike Wey
*
* A montage is a single image which is composed of thumbnail images
* composed in a uniform grid. The size of the montage image is determined
* by the size of the individual thumbnails and the number of rows and
* columns in the grid.
*/
module dmagick.Montage;
import std.conv;
import dmagick.Color;
import dmagick.Geometry;
import dmagick.Utils;
import dmagick.c.geometry;
import dmagick.c.memory;
import dmagick.c.montage;
/**
* Montage is used to provide montage options and provides methods
* to set all options required to render simple (unframed) montages.
*/
class Montage
{
alias RefCounted!( DestroyMontageInfo, MontageInfo ) MontageInfoRef;
MontageInfoRef montageInfoRef;
/** */
this()
{
montageInfoRef = MontageInfoRef(cast(MontageInfo*)AcquireMagickMemory(MontageInfo.sizeof));
}
/**
* Specifies the background color that thumbnails are imaged upon.
*/
void backgroundColor(Color color)
{
montageInfoRef.background_color = color.pixelPacket;
}
///ditto
Color backgroundColor()
{
return new Color(montageInfoRef.background_color);
}
/**
* Specifies the maximum number of columns in the montage.
*/
void columns(size_t columns)
{
Geometry size;
if ( montageInfoRef.tile !is null )
size = Geometry( to!(string)(montageInfoRef.tile) );
size.width = columns;
}
///ditto
size_t columns()
{
Geometry size;
if ( montageInfoRef.tile !is null )
size = Geometry( to!(string)(montageInfoRef.tile) );
return size.width;
}
/**
* Specifies the fill color to use for the label text.
*/
void fillColor(Color color)
{
montageInfoRef.fill = color.pixelPacket;
}
///ditto
Color fillColor()
{
return new Color(montageInfoRef.fill);
}
/**
* Specifies the thumbnail label font.
*/
void font(string font)
{
copyString(montageInfoRef.font, font);
}
///ditto
string font()
{
return to!(string)(montageInfoRef.font);
}
/**
* Specifies the size of the generated thumbnail.
*/
void geometry(Geometry geometry)
{
copyString(montageInfoRef.geometry, geometry.toString());
}
///ditto
Geometry geometry()
{
return Geometry( to!(string)(montageInfoRef.geometry) );
}
/**
* Specifies the thumbnail positioning within the specified geometry
* area. If the thumbnail is smaller in any dimension than the geometry,
* then it is placed according to this specification.
*/
void gravity(GravityType gravity)
{
montageInfoRef.gravity = gravity;
}
///ditto
GravityType gravity()
{
return montageInfoRef.gravity;
}
/**
* Specifies the format used for the image label. Special format
* characters may be embedded in the format string to include
* information about the image.
*
* See_Also: dmagick.Image.Image.annotate for the format characters.
*/
void label(string label)
{
copyString(montageInfoRef.title, label);
}
///ditto
string label()
{
return to!(string)(montageInfoRef.title);
}
/**
* Specifies the thumbnail label font size.
*/
void pointSize(double size)
{
montageInfoRef.pointsize = size;
}
///ditto
double pointSize()
{
return montageInfoRef.pointsize;
}
/**
* Specifies the maximum number of rows in the montage.
*/
void rows(size_t rows)
{
Geometry size;
if ( montageInfoRef.tile !is null )
size = Geometry( to!(string)(montageInfoRef.tile) );
size.height = rows;
}
///ditto
size_t rows()
{
Geometry size;
if ( montageInfoRef.tile !is null )
size = Geometry( to!(string)(montageInfoRef.tile) );
return size.height;
}
/**
* Enable/disable drop-shadow on thumbnails.
*/
void shadow(bool shadow)
{
montageInfoRef.shadow = shadow;
}
///ditto
bool shadow()
{
return montageInfoRef.shadow == 1;
}
/**
* Specifies the stroke color to use for the label text.
*/
void strokeColor(Color color)
{
montageInfoRef.stroke = color.pixelPacket;
}
///ditto
Color strokeColor()
{
return new Color(montageInfoRef.stroke);
}
/**
* Specifies a texture image to use as montage background. The built-in
* textures "$(D granite:)" and "$(D plasma:)" are available. A texture
* is the same as a background image.
*/
void texture(string texture)
{
copyString(montageInfoRef.texture, texture);
}
///ditto
string texture()
{
return to!(string)(montageInfoRef.texture);
}
}
/**
* MontageFramed provides the means to specify montage options when it is
* desired to have decorative frames around the image thumbnails.
*/
class MontageFramed : Montage
{
/**
* Construct the info to use for a framed montage.
*
* Params:
* frameGeometry = The size portion indicates the width and height
* of the frame. If no offsets are given then the border
* added is a solid color. Offsets x and y, if present,
* specify that the width and height of the border is
* partitioned to form an outer bevel of thickness x
* pixels and an inner bevel of thickness y pixels.
* Negative offsets make no sense as frame arguments.
*/
this(Geometry frameGeometry)
{
super();
this.frameGeometry = frameGeometry;
}
/**
* Specifies the background color within the thumbnail frame.
*/
void borderColor(Color color)
{
montageInfoRef.background_color = color.pixelPacket;
}
///ditto
Color borderColor()
{
return new Color(montageInfoRef.background_color);
}
/**
* Specifies the border to place between a thumbnail and its surrounding
* frame. This option only takes effect if geometry specification
* doesn't also specify the thumbnail border width.
*/
void borderWidth(size_t width)
{
montageInfoRef.border_width = width;
}
///ditto
size_t borderWidth()
{
return montageInfoRef.border_width;
}
/**
* Specifies the geometry specification for frame to place around
* thumbnail. If this parameter is not specified, then the montage is
* unframed.
*
* Params:
* geometry = The size portion indicates the width and height of
* the frame. If no offsets are given then the border
* added is a solid color. Offsets x and y, if present,
* specify that the width and height of the border is
* partitioned to form an outer bevel of thickness x
* pixels and an inner bevel of thickness y pixels.
* Negative offsets make no sense as frame arguments.
*/
void frameGeometry(Geometry geometry)
{
copyString(montageInfoRef.frame, geometry.toString());
}
///ditto
Geometry frameGeometry()
{
return Geometry( to!(string)(montageInfoRef.frame));
}
void matteColor(Color color)
{
montageInfoRef.matte_color = color.pixelPacket;
}
///ditto
Color matteColor()
{
return new Color(montageInfoRef.matte_color);
}
}
|