rmagick 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- data/ChangeLog +232 -0
- data/Makefile.in +28 -0
- data/README.html +404 -0
- data/README.txt +397 -0
- data/configure +8554 -0
- data/configure.ac +497 -0
- data/doc/comtasks.html +241 -0
- data/doc/constants.html +1195 -0
- data/doc/css/doc.css +299 -0
- data/doc/css/popup.css +34 -0
- data/doc/draw.html +3108 -0
- data/doc/ex/Adispatch.rb +43 -0
- data/doc/ex/Zconstitute.rb +9 -0
- data/doc/ex/adaptive_threshold.rb +19 -0
- data/doc/ex/add_noise.rb +18 -0
- data/doc/ex/affine.rb +48 -0
- data/doc/ex/affine_transform.rb +20 -0
- data/doc/ex/arc.rb +47 -0
- data/doc/ex/arcpath.rb +33 -0
- data/doc/ex/average.rb +15 -0
- data/doc/ex/axes.rb +64 -0
- data/doc/ex/bilevel_channel.rb +20 -0
- data/doc/ex/blur_image.rb +12 -0
- data/doc/ex/border.rb +10 -0
- data/doc/ex/bounding_box.rb +48 -0
- data/doc/ex/cbezier1.rb +40 -0
- data/doc/ex/cbezier2.rb +40 -0
- data/doc/ex/cbezier3.rb +40 -0
- data/doc/ex/cbezier4.rb +41 -0
- data/doc/ex/cbezier5.rb +41 -0
- data/doc/ex/cbezier6.rb +51 -0
- data/doc/ex/channel.rb +26 -0
- data/doc/ex/channel_threshold.rb +48 -0
- data/doc/ex/charcoal.rb +12 -0
- data/doc/ex/chop.rb +29 -0
- data/doc/ex/circle.rb +31 -0
- data/doc/ex/clip_path.rb +56 -0
- data/doc/ex/coalesce.rb +60 -0
- data/doc/ex/color_fill_to_border.rb +29 -0
- data/doc/ex/color_floodfill.rb +28 -0
- data/doc/ex/color_histogram.rb +60 -0
- data/doc/ex/color_reset.rb +11 -0
- data/doc/ex/colorize.rb +16 -0
- data/doc/ex/colors.rb +65 -0
- data/doc/ex/composite.rb +135 -0
- data/doc/ex/contrast.rb +37 -0
- data/doc/ex/crop.rb +31 -0
- data/doc/ex/crop_with_gravity.rb +46 -0
- data/doc/ex/cycle_colormap.rb +21 -0
- data/doc/ex/demo.rb +324 -0
- data/doc/ex/drawcomp.rb +42 -0
- data/doc/ex/drop_shadow.rb +60 -0
- data/doc/ex/edge.rb +11 -0
- data/doc/ex/ellipse.rb +43 -0
- data/doc/ex/emboss.rb +11 -0
- data/doc/ex/enhance.rb +28 -0
- data/doc/ex/equalize.rb +11 -0
- data/doc/ex/flatten_images.rb +38 -0
- data/doc/ex/flip.rb +11 -0
- data/doc/ex/flop.rb +11 -0
- data/doc/ex/fonts.rb +20 -0
- data/doc/ex/frame.rb +12 -0
- data/doc/ex/gaussian_blur.rb +11 -0
- data/doc/ex/get_multiline_type_metrics.rb +53 -0
- data/doc/ex/get_pixels.rb +48 -0
- data/doc/ex/get_type_metrics.rb +140 -0
- data/doc/ex/gradientfill.rb +27 -0
- data/doc/ex/grav.rb +44 -0
- data/doc/ex/gravity.rb +80 -0
- data/doc/ex/hatchfill.rb +27 -0
- data/doc/ex/images/Ballerina.jpg +0 -0
- data/doc/ex/images/Ballerina3.jpg +0 -0
- data/doc/ex/images/Button_0.gif +0 -0
- data/doc/ex/images/Button_1.gif +0 -0
- data/doc/ex/images/Button_2.gif +0 -0
- data/doc/ex/images/Button_3.gif +0 -0
- data/doc/ex/images/Button_4.gif +0 -0
- data/doc/ex/images/Button_5.gif +0 -0
- data/doc/ex/images/Button_6.gif +0 -0
- data/doc/ex/images/Button_7.gif +0 -0
- data/doc/ex/images/Button_8.gif +0 -0
- data/doc/ex/images/Button_9.gif +0 -0
- data/doc/ex/images/Button_A.gif +0 -0
- data/doc/ex/images/Button_B.gif +0 -0
- data/doc/ex/images/Button_C.gif +0 -0
- data/doc/ex/images/Button_D.gif +0 -0
- data/doc/ex/images/Button_E.gif +0 -0
- data/doc/ex/images/Button_F.gif +0 -0
- data/doc/ex/images/Button_G.gif +0 -0
- data/doc/ex/images/Button_H.gif +0 -0
- data/doc/ex/images/Button_I.gif +0 -0
- data/doc/ex/images/Button_J.gif +0 -0
- data/doc/ex/images/Button_K.gif +0 -0
- data/doc/ex/images/Button_L.gif +0 -0
- data/doc/ex/images/Button_M.gif +0 -0
- data/doc/ex/images/Button_N.gif +0 -0
- data/doc/ex/images/Button_O.gif +0 -0
- data/doc/ex/images/Button_P.gif +0 -0
- data/doc/ex/images/Button_Q.gif +0 -0
- data/doc/ex/images/Button_R.gif +0 -0
- data/doc/ex/images/Button_S.gif +0 -0
- data/doc/ex/images/Button_T.gif +0 -0
- data/doc/ex/images/Button_U.gif +0 -0
- data/doc/ex/images/Button_V.gif +0 -0
- data/doc/ex/images/Button_W.gif +0 -0
- data/doc/ex/images/Button_X.gif +0 -0
- data/doc/ex/images/Button_Y.gif +0 -0
- data/doc/ex/images/Button_Z.gif +0 -0
- data/doc/ex/images/Cheetah.jpg +0 -0
- data/doc/ex/images/Coffee.wmf +0 -0
- data/doc/ex/images/Flower_Hat.jpg +0 -0
- data/doc/ex/images/Gold_Statue.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
- data/doc/ex/images/No.wmf +0 -0
- data/doc/ex/images/Polynesia.jpg +0 -0
- data/doc/ex/images/Red_Rocks.jpg +0 -0
- data/doc/ex/images/Shorts.jpg +0 -0
- data/doc/ex/images/Snake.wmf +0 -0
- data/doc/ex/images/Violin.jpg +0 -0
- data/doc/ex/images/graydient230x6.gif +0 -0
- data/doc/ex/images/logo400x83.gif +0 -0
- data/doc/ex/images/model.miff +0 -0
- data/doc/ex/images/notimplemented.gif +0 -0
- data/doc/ex/images/smile.miff +0 -0
- data/doc/ex/images/spin.gif +0 -0
- data/doc/ex/implode.rb +32 -0
- data/doc/ex/level.rb +12 -0
- data/doc/ex/level_channel.rb +33 -0
- data/doc/ex/line.rb +40 -0
- data/doc/ex/map.rb +28 -0
- data/doc/ex/map_f.rb +15 -0
- data/doc/ex/matte_fill_to_border.rb +42 -0
- data/doc/ex/matte_floodfill.rb +35 -0
- data/doc/ex/matte_replace.rb +42 -0
- data/doc/ex/median_filter.rb +28 -0
- data/doc/ex/modulate.rb +11 -0
- data/doc/ex/mono.rb +23 -0
- data/doc/ex/morph.rb +26 -0
- data/doc/ex/mosaic.rb +35 -0
- data/doc/ex/motion_blur.rb +11 -0
- data/doc/ex/negate.rb +11 -0
- data/doc/ex/negate_channel.rb +19 -0
- data/doc/ex/normalize.rb +11 -0
- data/doc/ex/oil_paint.rb +11 -0
- data/doc/ex/opacity.rb +38 -0
- data/doc/ex/opaque.rb +14 -0
- data/doc/ex/ordered_dither.rb +11 -0
- data/doc/ex/path.rb +62 -0
- data/doc/ex/pattern1.rb +25 -0
- data/doc/ex/pattern2.rb +26 -0
- data/doc/ex/polygon.rb +24 -0
- data/doc/ex/polyline.rb +23 -0
- data/doc/ex/posterize.rb +19 -0
- data/doc/ex/preview.rb +16 -0
- data/doc/ex/qbezierpath.rb +49 -0
- data/doc/ex/quantize-m.rb +25 -0
- data/doc/ex/radial_blur.rb +19 -0
- data/doc/ex/raise.rb +11 -0
- data/doc/ex/random_channel_threshold.rb +17 -0
- data/doc/ex/random_threshold_channel.rb +18 -0
- data/doc/ex/rectangle.rb +33 -0
- data/doc/ex/reduce_noise.rb +28 -0
- data/doc/ex/roll.rb +9 -0
- data/doc/ex/rotate.rb +43 -0
- data/doc/ex/rotate_f.rb +14 -0
- data/doc/ex/roundrect.rb +32 -0
- data/doc/ex/rubyname.rb +31 -0
- data/doc/ex/segment.rb +11 -0
- data/doc/ex/shade.rb +11 -0
- data/doc/ex/shave.rb +15 -0
- data/doc/ex/shear.rb +10 -0
- data/doc/ex/skewx.rb +50 -0
- data/doc/ex/skewy.rb +45 -0
- data/doc/ex/smile.rb +124 -0
- data/doc/ex/solarize.rb +11 -0
- data/doc/ex/splice.rb +16 -0
- data/doc/ex/spread.rb +11 -0
- data/doc/ex/stegano.rb +50 -0
- data/doc/ex/stroke_dasharray.rb +41 -0
- data/doc/ex/stroke_linecap.rb +44 -0
- data/doc/ex/stroke_linejoin.rb +48 -0
- data/doc/ex/stroke_width.rb +47 -0
- data/doc/ex/swirl.rb +17 -0
- data/doc/ex/text.rb +32 -0
- data/doc/ex/text_align.rb +36 -0
- data/doc/ex/text_antialias.rb +33 -0
- data/doc/ex/text_undercolor.rb +26 -0
- data/doc/ex/texture_fill_to_border.rb +34 -0
- data/doc/ex/texture_floodfill.rb +31 -0
- data/doc/ex/texturefill.rb +25 -0
- data/doc/ex/threshold.rb +13 -0
- data/doc/ex/to_blob.rb +14 -0
- data/doc/ex/translate.rb +37 -0
- data/doc/ex/transparent.rb +38 -0
- data/doc/ex/trim.rb +25 -0
- data/doc/ex/unsharp_mask.rb +28 -0
- data/doc/ex/viewex.rb +36 -0
- data/doc/ex/wave.rb +9 -0
- data/doc/ilist.html +1592 -0
- data/doc/image1.html +3009 -0
- data/doc/image2.html +2169 -0
- data/doc/image3.html +2815 -0
- data/doc/imageattrs.html +1319 -0
- data/doc/imusage.html +403 -0
- data/doc/index.html +418 -0
- data/doc/info.html +949 -0
- data/doc/magick.html +439 -0
- data/doc/scripts/doc.js +9 -0
- data/doc/struct.html +1334 -0
- data/doc/usage.html +1318 -0
- data/examples/describe.rb +44 -0
- data/examples/histogram.rb +289 -0
- data/examples/image_opacity.rb +29 -0
- data/examples/import_export.rb +31 -0
- data/examples/pattern_fill.rb +38 -0
- data/examples/rotating_text.rb +47 -0
- data/examples/thumbnail.rb +65 -0
- data/examples/vignette.rb +79 -0
- data/ext/RMagick/MANIFEST +239 -0
- data/ext/RMagick/extconf.rb.in +21 -0
- data/ext/RMagick/rmagick.h +938 -0
- data/ext/RMagick/rmagick_config.h.in +170 -0
- data/ext/RMagick/rmdraw.c +1308 -0
- data/ext/RMagick/rmfill.c +609 -0
- data/ext/RMagick/rmilist.c +685 -0
- data/ext/RMagick/rmimage.c +7980 -0
- data/ext/RMagick/rminfo.c +982 -0
- data/ext/RMagick/rmmain.c +1497 -0
- data/ext/RMagick/rmutil.c +2685 -0
- data/install.rb +1015 -0
- data/lib/RMagick.rb +1486 -0
- data/metaconfig.in +6 -0
- data/post-clean.rb +12 -0
- data/post-install.rb +36 -0
- data/post-setup.rb +245 -0
- data/rmagick.gemspec +22 -0
- data/uninstall.rb +71 -0
- metadata +286 -0
@@ -0,0 +1,982 @@
|
|
1
|
+
/* $Id: rminfo.c,v 1.22 2004/08/18 23:22:36 rmagick Exp $ */
|
2
|
+
/*============================================================================\
|
3
|
+
| Copyright (C) 2004 by Timothy P. Hunter
|
4
|
+
| Name: rminfo.c
|
5
|
+
| Author: Tim Hunter
|
6
|
+
| Purpose: Info class method definitions for RMagick.
|
7
|
+
\============================================================================*/
|
8
|
+
|
9
|
+
#include "rmagick.h"
|
10
|
+
|
11
|
+
DEF_ATTR_ACCESSOR(Info, antialias, bool)
|
12
|
+
|
13
|
+
/*
|
14
|
+
Method: Info#background_color
|
15
|
+
Purpose: return the name of the background color as a String
|
16
|
+
Note: Compare with Image#background_color!
|
17
|
+
*/
|
18
|
+
VALUE
|
19
|
+
Info_background_color(VALUE self)
|
20
|
+
{
|
21
|
+
Info *info;
|
22
|
+
|
23
|
+
Data_Get_Struct(self, Info, info);
|
24
|
+
return PixelPacket_to_Color_Name_Info(info, &info->background_color);
|
25
|
+
}
|
26
|
+
|
27
|
+
/*
|
28
|
+
Method: Info#background_color=<aString>
|
29
|
+
Purpose: set the background color
|
30
|
+
Raises: ArgumentError
|
31
|
+
*/
|
32
|
+
VALUE
|
33
|
+
Info_background_color_eq(VALUE self, VALUE bc_arg)
|
34
|
+
{
|
35
|
+
Info *info;
|
36
|
+
|
37
|
+
Data_Get_Struct(self, Info, info);
|
38
|
+
Color_to_PixelPacket(&info->background_color, bc_arg);
|
39
|
+
return self;
|
40
|
+
}
|
41
|
+
|
42
|
+
/*
|
43
|
+
Method: Info#border_color
|
44
|
+
Purpose: return the name of the border color as a String
|
45
|
+
Note: Compare with Image#border_color!
|
46
|
+
*/
|
47
|
+
VALUE
|
48
|
+
Info_border_color(VALUE self)
|
49
|
+
{
|
50
|
+
Info *info;
|
51
|
+
|
52
|
+
Data_Get_Struct(self, Info, info);
|
53
|
+
return PixelPacket_to_Color_Name_Info(info, &info->border_color);
|
54
|
+
}
|
55
|
+
|
56
|
+
/*
|
57
|
+
Method: Info#border_color=<aString>
|
58
|
+
Purpose: set the border color
|
59
|
+
Raises: ArgumentError
|
60
|
+
*/
|
61
|
+
VALUE
|
62
|
+
Info_border_color_eq(VALUE self, VALUE bc_arg)
|
63
|
+
{
|
64
|
+
Info *info;
|
65
|
+
|
66
|
+
Data_Get_Struct(self, Info, info);
|
67
|
+
Color_to_PixelPacket(&info->border_color, bc_arg);
|
68
|
+
return self;
|
69
|
+
}
|
70
|
+
|
71
|
+
/*
|
72
|
+
Method: Info#colorspace
|
73
|
+
Purpose: Get the colorspace type
|
74
|
+
*/
|
75
|
+
VALUE
|
76
|
+
Info_colorspace(VALUE self)
|
77
|
+
{
|
78
|
+
Info *info;
|
79
|
+
|
80
|
+
Data_Get_Struct(self, Info, info);
|
81
|
+
return ColorspaceType_new(info->colorspace);
|
82
|
+
}
|
83
|
+
|
84
|
+
/*
|
85
|
+
Method: Info#colorspace=
|
86
|
+
Purpose: Set the colorspace type
|
87
|
+
Raises: ArgumentError
|
88
|
+
*/
|
89
|
+
VALUE
|
90
|
+
Info_colorspace_eq(VALUE self, VALUE colorspace)
|
91
|
+
{
|
92
|
+
Info *info;
|
93
|
+
|
94
|
+
Data_Get_Struct(self, Info, info);
|
95
|
+
VALUE_TO_ENUM(colorspace, info->colorspace, ColorspaceType);
|
96
|
+
return self;
|
97
|
+
}
|
98
|
+
|
99
|
+
/*
|
100
|
+
Method: Info#compression
|
101
|
+
Purpose: Get the compression type
|
102
|
+
Notes:
|
103
|
+
*/
|
104
|
+
VALUE
|
105
|
+
Info_compression(VALUE self)
|
106
|
+
{
|
107
|
+
Info *info;
|
108
|
+
|
109
|
+
Data_Get_Struct(self, Info, info);
|
110
|
+
return CompressionType_new(info->compression);
|
111
|
+
}
|
112
|
+
|
113
|
+
/*
|
114
|
+
Method: Info#compression=
|
115
|
+
Purpose: Set the compression type
|
116
|
+
Raises: ArgumentError
|
117
|
+
*/
|
118
|
+
VALUE
|
119
|
+
Info_compression_eq(VALUE self, VALUE type)
|
120
|
+
{
|
121
|
+
Info *info;
|
122
|
+
|
123
|
+
Data_Get_Struct(self, Info, info);
|
124
|
+
VALUE_TO_ENUM(type, info->compression, CompressionType);
|
125
|
+
return self;
|
126
|
+
}
|
127
|
+
|
128
|
+
/*
|
129
|
+
Method: Info#define(format, key[, value])
|
130
|
+
Purpose: Call AddDefinitions (GM) or SetImageOption (IM)
|
131
|
+
Note: The only method in Info that is not an
|
132
|
+
attribute accessor.
|
133
|
+
*/
|
134
|
+
VALUE
|
135
|
+
Info_define(int argc, VALUE *argv, VALUE self)
|
136
|
+
{
|
137
|
+
#if defined(HAVE_SETIMAGEOPTION)
|
138
|
+
Info *info;
|
139
|
+
char *format, *key, *value = "";
|
140
|
+
long format_l, key_l;
|
141
|
+
char ckey[100];
|
142
|
+
unsigned int okay;
|
143
|
+
volatile VALUE fmt_arg;
|
144
|
+
|
145
|
+
Data_Get_Struct(self, Info, info);
|
146
|
+
|
147
|
+
switch(argc)
|
148
|
+
{
|
149
|
+
case 3:
|
150
|
+
/* Allow any argument that supports to_s */
|
151
|
+
fmt_arg = rb_funcall(argv[2], ID_to_s, 0);
|
152
|
+
value = STRING_PTR(fmt_arg);
|
153
|
+
case 2:
|
154
|
+
key = STRING_PTR_LEN(argv[1], key_l);
|
155
|
+
format = STRING_PTR_LEN(argv[0], format_l);
|
156
|
+
break;
|
157
|
+
default:
|
158
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
|
159
|
+
}
|
160
|
+
|
161
|
+
if (2 + format_l + key_l > sizeof(ckey))
|
162
|
+
{
|
163
|
+
rb_raise(rb_eArgError, "%.20s:%.20s not defined - format or key too long", format, key);
|
164
|
+
}
|
165
|
+
(void) sprintf(ckey, "%s:%s", format, key);
|
166
|
+
|
167
|
+
okay = SetImageOption(info, ckey, value);
|
168
|
+
if (!okay)
|
169
|
+
{
|
170
|
+
rb_warn("%.20s=\"%.78s\" not defined - SetImageOption failed.", ckey, value);
|
171
|
+
return Qnil;
|
172
|
+
}
|
173
|
+
|
174
|
+
return self;
|
175
|
+
|
176
|
+
#elif defined(HAVE_ADDDEFINITIONS)
|
177
|
+
Info *info;
|
178
|
+
char *format, *key, *value = NULL;
|
179
|
+
long format_l, key_l, value_l = 0;
|
180
|
+
unsigned int okay;
|
181
|
+
volatile VALUE fmt_arg;
|
182
|
+
ExceptionInfo exception;
|
183
|
+
char definitions[200]; /* Make this buffer longer than the buffer used */
|
184
|
+
/* for SetImageOptions since AddDefinitions cats */
|
185
|
+
/* the value onto the format:key pair. */
|
186
|
+
|
187
|
+
Data_Get_Struct(self, Info, info);
|
188
|
+
|
189
|
+
switch(argc)
|
190
|
+
{
|
191
|
+
case 3:
|
192
|
+
/* Allow any argument that supports to_s */
|
193
|
+
fmt_arg = rb_funcall(argv[2], ID_to_s, 0);
|
194
|
+
value = STRING_PTR_LEN(fmt_arg, value_l);
|
195
|
+
/* Fall through */
|
196
|
+
case 2:
|
197
|
+
key = STRING_PTR_LEN(argv[1], key_l);
|
198
|
+
format = STRING_PTR_LEN(argv[0], format_l);
|
199
|
+
break;
|
200
|
+
default:
|
201
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
|
202
|
+
break;
|
203
|
+
}
|
204
|
+
|
205
|
+
|
206
|
+
if ((3 + format_l + key_l + value_l) > sizeof(definitions))
|
207
|
+
{
|
208
|
+
rb_raise(rb_eArgError, "%.20s:%.20s not defined - too long", format, key);
|
209
|
+
}
|
210
|
+
(void)sprintf(definitions, "%s:%s=", format, key);
|
211
|
+
if (value)
|
212
|
+
{
|
213
|
+
strcat(definitions, value);
|
214
|
+
}
|
215
|
+
|
216
|
+
GetExceptionInfo(&exception);
|
217
|
+
okay = AddDefinitions(info, definitions, &exception);
|
218
|
+
HANDLE_ERROR
|
219
|
+
if (!okay)
|
220
|
+
{
|
221
|
+
rb_warn("%.*s not defined - AddDefinitions failed.", sizeof(definitions), definitions);
|
222
|
+
return Qnil;
|
223
|
+
}
|
224
|
+
|
225
|
+
return self;
|
226
|
+
|
227
|
+
#else
|
228
|
+
rm_not_implemented();
|
229
|
+
return (VALUE)0;
|
230
|
+
#endif
|
231
|
+
}
|
232
|
+
|
233
|
+
DEF_ATTR_READER(Info, density, str)
|
234
|
+
|
235
|
+
/*
|
236
|
+
Method: Info#density=<aString>
|
237
|
+
Purpose: Set the text rendering density, e.g. "72x72"
|
238
|
+
Raise: ArgumentError
|
239
|
+
*/
|
240
|
+
VALUE
|
241
|
+
Info_density_eq(VALUE self, VALUE density_arg)
|
242
|
+
{
|
243
|
+
Info *info;
|
244
|
+
volatile VALUE density;
|
245
|
+
char *dens;
|
246
|
+
|
247
|
+
Data_Get_Struct(self, Info, info);
|
248
|
+
|
249
|
+
if(NIL_P(density_arg))
|
250
|
+
{
|
251
|
+
magick_free(info->density);
|
252
|
+
info->density = NULL;
|
253
|
+
return self;
|
254
|
+
}
|
255
|
+
|
256
|
+
density = rb_funcall(density_arg, ID_to_s, 0);
|
257
|
+
dens = STRING_PTR(density);
|
258
|
+
if (!IsGeometry(dens))
|
259
|
+
{
|
260
|
+
rb_raise(rb_eArgError, "invalid density geometry: %s", dens);
|
261
|
+
}
|
262
|
+
|
263
|
+
magick_clone_string(&info->density, dens);
|
264
|
+
|
265
|
+
return self;
|
266
|
+
}
|
267
|
+
|
268
|
+
DEF_ATTR_READER(Info, depth, int)
|
269
|
+
|
270
|
+
/*
|
271
|
+
Method: Info#depth=
|
272
|
+
Purpose: Set the depth (8, 16, 32).
|
273
|
+
Raises: ArgumentError
|
274
|
+
*/
|
275
|
+
VALUE
|
276
|
+
Info_depth_eq(VALUE self, VALUE depth)
|
277
|
+
{
|
278
|
+
Info *info;
|
279
|
+
int d;
|
280
|
+
|
281
|
+
Data_Get_Struct(self, Info, info);
|
282
|
+
d = NUM2INT(depth);
|
283
|
+
switch (d)
|
284
|
+
{
|
285
|
+
case 8: // always okay
|
286
|
+
#if QuantumDepth == 16 || QuantumDepth == 32
|
287
|
+
case 16:
|
288
|
+
#endif
|
289
|
+
#if QuantumDepth == 32
|
290
|
+
case 32:
|
291
|
+
#endif
|
292
|
+
break;
|
293
|
+
default:
|
294
|
+
rb_raise(rb_eArgError, "invalid depth (%d)", d);
|
295
|
+
break;
|
296
|
+
}
|
297
|
+
|
298
|
+
info->depth = d;
|
299
|
+
return self;
|
300
|
+
}
|
301
|
+
|
302
|
+
DEF_ATTR_ACCESSOR(Info, dither, bool)
|
303
|
+
|
304
|
+
#ifdef HAVE_IMAGE_EXTRACT_INFO
|
305
|
+
|
306
|
+
/*
|
307
|
+
Method: aString=Info#extract
|
308
|
+
Info#extract=aString
|
309
|
+
Purpose: Get/set the extract string, e.g. "200x200+100+100"
|
310
|
+
Raise: ArgumentError
|
311
|
+
Notes: defined for IM 5.5.6 and later
|
312
|
+
*/
|
313
|
+
DEF_ATTR_READER(Info, extract, str)
|
314
|
+
|
315
|
+
VALUE
|
316
|
+
Info_extract_eq(VALUE self, VALUE extract_arg)
|
317
|
+
{
|
318
|
+
Info *info;
|
319
|
+
char *extr;
|
320
|
+
volatile VALUE extract;
|
321
|
+
|
322
|
+
Data_Get_Struct(self, Info, info);
|
323
|
+
|
324
|
+
if (NIL_P(extract_arg))
|
325
|
+
{
|
326
|
+
magick_free(info->extract);
|
327
|
+
info->extract = NULL;
|
328
|
+
return self;
|
329
|
+
}
|
330
|
+
|
331
|
+
extract = rb_funcall(extract_arg, ID_to_s, 0);
|
332
|
+
extr = STRING_PTR(extract);
|
333
|
+
if (!IsGeometry(extr))
|
334
|
+
{
|
335
|
+
rb_raise(rb_eArgError, "invalid extract geometry: %s", extr);
|
336
|
+
}
|
337
|
+
|
338
|
+
magick_clone_string(&info->extract, extr);
|
339
|
+
|
340
|
+
return self;
|
341
|
+
}
|
342
|
+
/*
|
343
|
+
Method: aString=Info#tile
|
344
|
+
Info#tile=aString
|
345
|
+
Purpose: Get/set the "tile" string, e.g. "200x200+100+100"
|
346
|
+
Raise: ArgumentError
|
347
|
+
Notes: defined for IM 5.5.6 and later. Actually these are effectively
|
348
|
+
aliases for extract & extract= but with warning messages.
|
349
|
+
*/
|
350
|
+
|
351
|
+
VALUE
|
352
|
+
Info_tile(VALUE self)
|
353
|
+
{
|
354
|
+
rb_warning("RMagick: tile is deprecated in this release of ImageMagick. Use extract instead.");
|
355
|
+
return Info_extract(self);
|
356
|
+
}
|
357
|
+
|
358
|
+
VALUE
|
359
|
+
Info_tile_eq(VALUE self, VALUE tile)
|
360
|
+
{
|
361
|
+
rb_warning("RMagick: tile= is deprecated in this release of ImageMagick. Use extract= instead.");
|
362
|
+
return Info_extract_eq(self, tile);
|
363
|
+
}
|
364
|
+
|
365
|
+
#else
|
366
|
+
|
367
|
+
/*
|
368
|
+
Method: aString=Info#extract
|
369
|
+
Info#extract=aString
|
370
|
+
Purpose: Get/set the extract string, e.g. "200x200+100+100"
|
371
|
+
Raise: ArgumentError
|
372
|
+
Notes: defined for IM 5.5.6 and later
|
373
|
+
*/
|
374
|
+
VALUE
|
375
|
+
Info_extract(VALUE self)
|
376
|
+
{
|
377
|
+
rm_not_implemented();
|
378
|
+
return (VALUE)0;
|
379
|
+
}
|
380
|
+
VALUE
|
381
|
+
Info_extract_eq(VALUE self, VALUE extr)
|
382
|
+
{
|
383
|
+
rm_not_implemented();
|
384
|
+
return (VALUE)0;
|
385
|
+
}
|
386
|
+
|
387
|
+
/*
|
388
|
+
Method: aString = Info#tile
|
389
|
+
Info#tile=aString
|
390
|
+
Purpose: Get/set the tile string, e.g. "200x200+100+100"
|
391
|
+
Raise: ArgumentError
|
392
|
+
Notes: defined for IM 5.5.5 and earlier, before the tile field was
|
393
|
+
deprecated and replaced by extract
|
394
|
+
*/
|
395
|
+
DEF_ATTR_READER(Info, tile, str)
|
396
|
+
|
397
|
+
VALUE
|
398
|
+
Info_tile_eq(VALUE self, VALUE tile_arg)
|
399
|
+
{
|
400
|
+
Info *info;
|
401
|
+
char *til;
|
402
|
+
volatile VALUE tile;
|
403
|
+
|
404
|
+
Data_Get_Struct(self, Info, info);
|
405
|
+
|
406
|
+
if (NIL_P(tile_arg))
|
407
|
+
{
|
408
|
+
magick_free(info->tile);
|
409
|
+
info->tile = NULL;
|
410
|
+
return self;
|
411
|
+
}
|
412
|
+
|
413
|
+
tile = rb_funcall(tile_arg, ID_to_s, 0);
|
414
|
+
til = STRING_PTR(tile);
|
415
|
+
if (!IsGeometry(til))
|
416
|
+
{
|
417
|
+
rb_raise(rb_eArgError, "invalid tile geometry: %s", til);
|
418
|
+
}
|
419
|
+
|
420
|
+
magick_clone_string(&info->tile, til);
|
421
|
+
|
422
|
+
return self;
|
423
|
+
}
|
424
|
+
#endif
|
425
|
+
|
426
|
+
/*
|
427
|
+
Methods: aString=Info#filename
|
428
|
+
Info#filename=aString
|
429
|
+
Purpose: Get/set the "filename"
|
430
|
+
Notes: Only used for Image#capture
|
431
|
+
Returns "" if filename not set
|
432
|
+
*/
|
433
|
+
VALUE
|
434
|
+
Info_filename(VALUE self)
|
435
|
+
{
|
436
|
+
Info *info;
|
437
|
+
|
438
|
+
Data_Get_Struct(self, Info, info);
|
439
|
+
return rb_str_new2(info->filename);
|
440
|
+
}
|
441
|
+
|
442
|
+
VALUE
|
443
|
+
Info_filename_eq(VALUE self, VALUE filename)
|
444
|
+
{
|
445
|
+
Info *info;
|
446
|
+
char *fname;
|
447
|
+
|
448
|
+
Data_Get_Struct(self, Info, info);
|
449
|
+
|
450
|
+
// Allow "nil" - remove current filename
|
451
|
+
if (NIL_P(filename) || STRING_PTR(filename) == NULL)
|
452
|
+
{
|
453
|
+
info->filename[0] = '\0';
|
454
|
+
}
|
455
|
+
else
|
456
|
+
{
|
457
|
+
// Otherwise copy in filename
|
458
|
+
fname = STRING_PTR(filename);
|
459
|
+
strncpy(info->filename, fname, MaxTextExtent);
|
460
|
+
}
|
461
|
+
return self;
|
462
|
+
}
|
463
|
+
|
464
|
+
/*
|
465
|
+
Methods: aString=Info#font
|
466
|
+
Info#font=aString
|
467
|
+
Purpose: Get/set the text font
|
468
|
+
*/
|
469
|
+
DEF_ATTR_READER(Info, font, str)
|
470
|
+
|
471
|
+
VALUE
|
472
|
+
Info_font_eq(VALUE self, VALUE font_arg)
|
473
|
+
{
|
474
|
+
Info *info;
|
475
|
+
char *font;
|
476
|
+
|
477
|
+
Data_Get_Struct(self, Info, info);
|
478
|
+
if (NIL_P(font_arg) || STRING_PTR(font_arg) == NULL)
|
479
|
+
{
|
480
|
+
magick_free(info->font);
|
481
|
+
info->font = NULL;
|
482
|
+
}
|
483
|
+
else
|
484
|
+
{
|
485
|
+
font = STRING_PTR(font_arg);
|
486
|
+
magick_clone_string(&info->font, font);
|
487
|
+
}
|
488
|
+
return self;
|
489
|
+
}
|
490
|
+
|
491
|
+
/*
|
492
|
+
Method: Info#format
|
493
|
+
Purpose: Return the image encoding format
|
494
|
+
*/
|
495
|
+
VALUE Info_format(VALUE self)
|
496
|
+
{
|
497
|
+
Info *info;
|
498
|
+
const MagickInfo *magick_info ;
|
499
|
+
ExceptionInfo exception;
|
500
|
+
|
501
|
+
Data_Get_Struct(self, Info, info);
|
502
|
+
if (*info->magick)
|
503
|
+
{
|
504
|
+
GetExceptionInfo(&exception);
|
505
|
+
magick_info = GetMagickInfo(info->magick, &exception);
|
506
|
+
return magick_info ? rb_str_new2(magick_info->name) : Qnil;
|
507
|
+
}
|
508
|
+
|
509
|
+
return Qnil;
|
510
|
+
}
|
511
|
+
|
512
|
+
/*
|
513
|
+
Method: Info#format=
|
514
|
+
Purpose: Set the image encoding format
|
515
|
+
*/
|
516
|
+
VALUE
|
517
|
+
Info_format_eq(VALUE self, VALUE magick)
|
518
|
+
{
|
519
|
+
Info *info;
|
520
|
+
const MagickInfo *m;
|
521
|
+
char *mgk;
|
522
|
+
ExceptionInfo exception;
|
523
|
+
|
524
|
+
Data_Get_Struct(self, Info, info);
|
525
|
+
|
526
|
+
GetExceptionInfo(&exception);
|
527
|
+
|
528
|
+
mgk = STRING_PTR(magick);
|
529
|
+
m = GetMagickInfo(mgk, &exception);
|
530
|
+
HANDLE_ERROR
|
531
|
+
|
532
|
+
if (!m)
|
533
|
+
{
|
534
|
+
rb_raise(rb_eArgError, "unknown format: %s", mgk);
|
535
|
+
}
|
536
|
+
|
537
|
+
strncpy(info->magick, m->name, MaxTextExtent-1);
|
538
|
+
return self;
|
539
|
+
}
|
540
|
+
|
541
|
+
DEF_ATTR_READER(Info, fuzz, dbl)
|
542
|
+
|
543
|
+
/*
|
544
|
+
Method: Info#fuzz=number
|
545
|
+
Info#fuzz=NN%
|
546
|
+
Notes: See Image#fuzz
|
547
|
+
*/
|
548
|
+
VALUE Info_fuzz_eq(VALUE self, VALUE fuzz)
|
549
|
+
{
|
550
|
+
Info *info;
|
551
|
+
|
552
|
+
Data_Get_Struct(self, Info, info);
|
553
|
+
info->fuzz = rm_fuzz_to_dbl(fuzz);
|
554
|
+
return self;
|
555
|
+
}
|
556
|
+
|
557
|
+
DEF_ATTR_ACCESSOR(Info, group, long)
|
558
|
+
|
559
|
+
/*
|
560
|
+
Method: Info#image_type
|
561
|
+
Purpose: Get the classification type
|
562
|
+
Raises: ArgumentError
|
563
|
+
*/
|
564
|
+
VALUE
|
565
|
+
Info_image_type(VALUE self)
|
566
|
+
{
|
567
|
+
Info *info;
|
568
|
+
|
569
|
+
Data_Get_Struct(self, Info, info);
|
570
|
+
return ImageType_new(info->type);
|
571
|
+
}
|
572
|
+
|
573
|
+
/*
|
574
|
+
Method: Info#image_type=
|
575
|
+
Purpose: Set the classification type
|
576
|
+
Raises: ArgumentError
|
577
|
+
*/
|
578
|
+
VALUE
|
579
|
+
Info_image_type_eq(VALUE self, VALUE type)
|
580
|
+
{
|
581
|
+
Info *info;
|
582
|
+
|
583
|
+
Data_Get_Struct(self, Info, info);
|
584
|
+
VALUE_TO_ENUM(type, info->type, ImageType);
|
585
|
+
return self;
|
586
|
+
}
|
587
|
+
|
588
|
+
/*
|
589
|
+
Method: Info#interlace
|
590
|
+
Purpose: Get the interlace type
|
591
|
+
Notes:
|
592
|
+
*/
|
593
|
+
VALUE
|
594
|
+
Info_interlace(VALUE self)
|
595
|
+
{
|
596
|
+
Info *info;
|
597
|
+
|
598
|
+
Data_Get_Struct(self, Info, info);
|
599
|
+
return InterlaceType_new(info->interlace);
|
600
|
+
}
|
601
|
+
|
602
|
+
/*
|
603
|
+
Method: Info#interlace=
|
604
|
+
Purpose: Set the interlace type
|
605
|
+
Raises: ArgumentError
|
606
|
+
*/
|
607
|
+
VALUE
|
608
|
+
Info_interlace_eq(VALUE self, VALUE inter)
|
609
|
+
{
|
610
|
+
Info *info;
|
611
|
+
|
612
|
+
Data_Get_Struct(self, Info, info);
|
613
|
+
VALUE_TO_ENUM(inter, info->interlace, InterlaceType);
|
614
|
+
return self;
|
615
|
+
}
|
616
|
+
|
617
|
+
/*
|
618
|
+
Method: Info#matte_color
|
619
|
+
Purpose: return the name of the matte color as a String
|
620
|
+
Note: Compare with Image#matte_color!
|
621
|
+
*/
|
622
|
+
VALUE
|
623
|
+
Info_matte_color(VALUE self)
|
624
|
+
{
|
625
|
+
Info *info;
|
626
|
+
|
627
|
+
Data_Get_Struct(self, Info, info);
|
628
|
+
return PixelPacket_to_Color_Name_Info(info, &info->matte_color);
|
629
|
+
}
|
630
|
+
|
631
|
+
/*
|
632
|
+
Method: Info#matte_color=<aString>
|
633
|
+
Purpose: set the matte color
|
634
|
+
Raises: ArgumentError
|
635
|
+
*/
|
636
|
+
VALUE
|
637
|
+
Info_matte_color_eq(VALUE self, VALUE matte_arg)
|
638
|
+
{
|
639
|
+
Info *info;
|
640
|
+
|
641
|
+
Data_Get_Struct(self, Info, info);
|
642
|
+
Color_to_PixelPacket(&info->matte_color, matte_arg);
|
643
|
+
return self;
|
644
|
+
}
|
645
|
+
|
646
|
+
DEF_ATTR_ACCESSOR(Info, monochrome, bool)
|
647
|
+
|
648
|
+
#ifdef HAVE_IMAGEINFO_NUMBER_SCENES
|
649
|
+
DEF_ATTR_ACCESSOR(Info, number_scenes, ulong)
|
650
|
+
#else
|
651
|
+
|
652
|
+
/*
|
653
|
+
Methods: num = Info#number_scenes
|
654
|
+
Info#number_scenes = num
|
655
|
+
Purpose: alias for subrange when IM < 5.5.6
|
656
|
+
*/
|
657
|
+
VALUE
|
658
|
+
Info_number_scenes(VALUE self)
|
659
|
+
{
|
660
|
+
return Info_subrange(self);
|
661
|
+
}
|
662
|
+
|
663
|
+
VALUE
|
664
|
+
Info_number_scenes_eq(VALUE self, VALUE nscenes)
|
665
|
+
{
|
666
|
+
return Info_subrange_eq(self, nscenes);
|
667
|
+
}
|
668
|
+
#endif
|
669
|
+
|
670
|
+
DEF_ATTR_READER(Info, page, str)
|
671
|
+
|
672
|
+
/*
|
673
|
+
Method: Info#page=<aString> or <aGeometry>
|
674
|
+
Purpose: store the Postscript page geometry
|
675
|
+
*/
|
676
|
+
VALUE
|
677
|
+
Info_page_eq(VALUE self, VALUE page_arg)
|
678
|
+
{
|
679
|
+
Info *info;
|
680
|
+
volatile VALUE geom_str;
|
681
|
+
char *geometry;
|
682
|
+
|
683
|
+
Data_Get_Struct(self, Info, info);
|
684
|
+
if (NIL_P(page_arg))
|
685
|
+
{
|
686
|
+
magick_free(info->page);
|
687
|
+
info->page = NULL;
|
688
|
+
return self;
|
689
|
+
}
|
690
|
+
geom_str = rb_funcall(page_arg, ID_to_s, 0);
|
691
|
+
geometry=PostscriptGeometry(STRING_PTR(geom_str));
|
692
|
+
if (*geometry == '\0')
|
693
|
+
{
|
694
|
+
magick_free(info->page);
|
695
|
+
info->page = NULL;
|
696
|
+
return self;
|
697
|
+
}
|
698
|
+
magick_clone_string(&info->page, geometry);
|
699
|
+
|
700
|
+
return self;
|
701
|
+
}
|
702
|
+
|
703
|
+
DEF_ATTR_ACCESSOR(Info, quality, long)
|
704
|
+
|
705
|
+
#ifdef HAVE_IMAGEINFO_NUMBER_SCENES
|
706
|
+
|
707
|
+
// Info#scene, scene= is the IM >= 5.5.6 version of the now-deprecated
|
708
|
+
// subimage accessors.
|
709
|
+
DEF_ATTR_ACCESSOR(Info, scene, ulong)
|
710
|
+
|
711
|
+
/*
|
712
|
+
Methods: num=Info#subimage
|
713
|
+
Info#subimage=num
|
714
|
+
Purpose: Get/set the "subimage" value, for IM >= 5.5.6
|
715
|
+
Raises: ArgumentError
|
716
|
+
Notes: synonyms for Info#scene, Info#scene=
|
717
|
+
*/
|
718
|
+
VALUE
|
719
|
+
Info_subimage(VALUE self)
|
720
|
+
{
|
721
|
+
rb_warning("RMagick: subimage is deprecated in this release of ImageMagick. Use scene instead.");
|
722
|
+
return Info_scene(self);
|
723
|
+
}
|
724
|
+
|
725
|
+
VALUE
|
726
|
+
Info_subimage_eq(VALUE self, VALUE subimage)
|
727
|
+
{
|
728
|
+
rb_warning("RMagick: subimage= is deprecated in this release of ImageMagick. Use scene= instead.");
|
729
|
+
return Info_scene_eq(self, subimage);
|
730
|
+
}
|
731
|
+
|
732
|
+
/*
|
733
|
+
Methods: num=Info#subrange
|
734
|
+
Info#subrange=num
|
735
|
+
Purpose: Get/set the "subrange" value, for IM >= 5.5.6
|
736
|
+
Raises: ArgumentError
|
737
|
+
Notes: synonyms for Info#number_scenes, Info#number_scenes=
|
738
|
+
*/
|
739
|
+
VALUE
|
740
|
+
Info_subrange(VALUE self)
|
741
|
+
{
|
742
|
+
rb_warning("RMagick: subrange is deprecated in this release of ImageMagick. Use number_scenes instead.");
|
743
|
+
return Info_number_scenes(self);
|
744
|
+
}
|
745
|
+
|
746
|
+
VALUE
|
747
|
+
Info_subrange_eq(VALUE self, VALUE subrange)
|
748
|
+
{
|
749
|
+
rb_warning("RMagick: subrange= is deprecated in this release of ImageMagick. Use number_scenes= instead.");
|
750
|
+
return Info_number_scenes_eq(self, subrange);
|
751
|
+
}
|
752
|
+
|
753
|
+
#else
|
754
|
+
|
755
|
+
/*
|
756
|
+
Methods: num=Info#scene
|
757
|
+
Info#scene=num
|
758
|
+
Purpose: Get/set the scene number, for IM < 5.5.6
|
759
|
+
Raises: ArgumentError
|
760
|
+
Notes: synonyms for Info#subimage, Info#subimage=
|
761
|
+
*/
|
762
|
+
VALUE
|
763
|
+
Info_scene(VALUE self)
|
764
|
+
{
|
765
|
+
Info *info;
|
766
|
+
|
767
|
+
Data_Get_Struct(self, Info, info);
|
768
|
+
return UINT2NUM(info->subimage);
|
769
|
+
}
|
770
|
+
|
771
|
+
VALUE
|
772
|
+
Info_scene_eq(VALUE self, VALUE scene)
|
773
|
+
{
|
774
|
+
Info *info;
|
775
|
+
|
776
|
+
Data_Get_Struct(self, Info, info);
|
777
|
+
info->subimage = NUM2ULONG(scene);
|
778
|
+
return self;
|
779
|
+
}
|
780
|
+
|
781
|
+
DEF_ATTR_ACCESSOR(Info, subimage, ulong)
|
782
|
+
DEF_ATTR_ACCESSOR(Info, subrange, ulong)
|
783
|
+
|
784
|
+
#endif
|
785
|
+
|
786
|
+
DEF_ATTR_READER(Info, server_name, str)
|
787
|
+
|
788
|
+
/*
|
789
|
+
Method: Info#server_name=<aString>
|
790
|
+
Purpose: Set the server name
|
791
|
+
*/
|
792
|
+
VALUE
|
793
|
+
Info_server_name_eq(VALUE self, VALUE server_arg)
|
794
|
+
{
|
795
|
+
Info *info;
|
796
|
+
char *server;
|
797
|
+
|
798
|
+
Data_Get_Struct(self, Info, info);
|
799
|
+
if (NIL_P(server_arg) || STRING_PTR(server_arg) == NULL)
|
800
|
+
{
|
801
|
+
magick_free(info->server_name);
|
802
|
+
info->server_name = NULL;
|
803
|
+
}
|
804
|
+
else
|
805
|
+
{
|
806
|
+
server = STRING_PTR(server_arg);
|
807
|
+
magick_clone_string(&info->server_name, server);
|
808
|
+
}
|
809
|
+
return self;
|
810
|
+
}
|
811
|
+
|
812
|
+
DEF_ATTR_READER(Info, size, str)
|
813
|
+
|
814
|
+
/*
|
815
|
+
Method: Info#size=<aString>
|
816
|
+
Info#size=<aGeometry>
|
817
|
+
Purpose: Set the size (a Geometry string, i.e. WxH{+-}x{+-}y)
|
818
|
+
Raises: ArgumentError
|
819
|
+
*/
|
820
|
+
VALUE
|
821
|
+
Info_size_eq(VALUE self, VALUE size_arg)
|
822
|
+
{
|
823
|
+
Info *info;
|
824
|
+
volatile VALUE size;
|
825
|
+
char *sz;
|
826
|
+
|
827
|
+
Data_Get_Struct(self, Info, info);
|
828
|
+
|
829
|
+
if (NIL_P(size_arg))
|
830
|
+
{
|
831
|
+
magick_free(info->size);
|
832
|
+
info->size = NULL;
|
833
|
+
return self;
|
834
|
+
}
|
835
|
+
|
836
|
+
size = rb_funcall(size_arg, ID_to_s, 0);
|
837
|
+
sz = STRING_PTR(size);
|
838
|
+
if (!IsGeometry(sz))
|
839
|
+
{
|
840
|
+
rb_raise(rb_eArgError, "invalid size geometry: %s", sz);
|
841
|
+
}
|
842
|
+
|
843
|
+
magick_clone_string(&info->size, sz);
|
844
|
+
|
845
|
+
return self;
|
846
|
+
}
|
847
|
+
|
848
|
+
/*
|
849
|
+
Method: Info#units
|
850
|
+
Purpose: Get the resolution type
|
851
|
+
*/
|
852
|
+
VALUE
|
853
|
+
Info_units(VALUE self)
|
854
|
+
{
|
855
|
+
Info *info;
|
856
|
+
|
857
|
+
Data_Get_Struct(self, Info, info);
|
858
|
+
return ResolutionType_new(info->units);
|
859
|
+
}
|
860
|
+
|
861
|
+
/*
|
862
|
+
Method: Info#units=
|
863
|
+
Purpose: Set the resolution type
|
864
|
+
Raises: ArgumentError
|
865
|
+
*/
|
866
|
+
VALUE
|
867
|
+
Info_units_eq(VALUE self, VALUE units)
|
868
|
+
{
|
869
|
+
Info *info;
|
870
|
+
|
871
|
+
Data_Get_Struct(self, Info, info);
|
872
|
+
VALUE_TO_ENUM(units, info->units, ResolutionType);
|
873
|
+
return self;
|
874
|
+
}
|
875
|
+
|
876
|
+
DEF_ATTR_READER(Info, view, str)
|
877
|
+
|
878
|
+
/*
|
879
|
+
Method: Info#view=
|
880
|
+
Purpose: Set FlashPix viewing parameters
|
881
|
+
*/
|
882
|
+
VALUE
|
883
|
+
Info_view_eq(VALUE self, VALUE view_arg)
|
884
|
+
{
|
885
|
+
Info *info;
|
886
|
+
char *view;
|
887
|
+
|
888
|
+
Data_Get_Struct(self, Info, info);
|
889
|
+
|
890
|
+
if (NIL_P(view_arg) || STRING_PTR(view_arg) == NULL)
|
891
|
+
{
|
892
|
+
magick_free(info->view);
|
893
|
+
info->view = NULL;
|
894
|
+
}
|
895
|
+
else
|
896
|
+
{
|
897
|
+
view = STRING_PTR(view_arg);
|
898
|
+
magick_clone_string(&info->view, view);
|
899
|
+
}
|
900
|
+
return self;
|
901
|
+
}
|
902
|
+
|
903
|
+
/*
|
904
|
+
Method: Info.new
|
905
|
+
Purpose: Create an Info object by calling CloneInfo
|
906
|
+
*/
|
907
|
+
#if !defined(HAVE_RB_DEFINE_ALLOC_FUNC)
|
908
|
+
VALUE
|
909
|
+
Info_new(VALUE class)
|
910
|
+
{
|
911
|
+
Info *info;
|
912
|
+
volatile VALUE new_obj;
|
913
|
+
|
914
|
+
info = CloneImageInfo(NULL);
|
915
|
+
if (!info)
|
916
|
+
{
|
917
|
+
rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
|
918
|
+
}
|
919
|
+
new_obj = Data_Wrap_Struct(class, NULL, DestroyImageInfo, info);
|
920
|
+
rb_obj_call_init(new_obj, 0, NULL);
|
921
|
+
return new_obj;
|
922
|
+
}
|
923
|
+
|
924
|
+
/*
|
925
|
+
Extern: rm_info_new
|
926
|
+
Purpose: provide a Info.new method for internal use
|
927
|
+
Notes: takes no parameters, but runs the parm block if present
|
928
|
+
*/
|
929
|
+
VALUE
|
930
|
+
rm_info_new()
|
931
|
+
{
|
932
|
+
return Info_new(Class_Info);
|
933
|
+
}
|
934
|
+
#else
|
935
|
+
|
936
|
+
/*
|
937
|
+
Extern: Info_alloc
|
938
|
+
Purpose: Create an ImageInfo object
|
939
|
+
*/
|
940
|
+
VALUE
|
941
|
+
Info_alloc(VALUE class)
|
942
|
+
{
|
943
|
+
Info *info;
|
944
|
+
volatile VALUE info_obj;
|
945
|
+
|
946
|
+
info = CloneImageInfo(NULL);
|
947
|
+
if (!info)
|
948
|
+
{
|
949
|
+
rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
|
950
|
+
}
|
951
|
+
info_obj = Data_Wrap_Struct(class, NULL, DestroyImageInfo, info);
|
952
|
+
return info_obj;
|
953
|
+
}
|
954
|
+
/*
|
955
|
+
Extern: rm_info_new
|
956
|
+
Purpose: provide a Info.new method for internal use
|
957
|
+
Notes: takes no parameters, but runs the parm block if present
|
958
|
+
*/
|
959
|
+
VALUE
|
960
|
+
rm_info_new()
|
961
|
+
{
|
962
|
+
volatile VALUE info_obj;
|
963
|
+
|
964
|
+
info_obj = Info_alloc(Class_Info);
|
965
|
+
return Info_initialize(info_obj);
|
966
|
+
}
|
967
|
+
#endif
|
968
|
+
|
969
|
+
/*
|
970
|
+
Method: Info#initialize
|
971
|
+
Purpose: If an initializer block is present, run it.
|
972
|
+
*/
|
973
|
+
VALUE
|
974
|
+
Info_initialize(VALUE self)
|
975
|
+
{
|
976
|
+
if (rb_block_given_p())
|
977
|
+
{
|
978
|
+
// Run the block in self's context
|
979
|
+
rb_obj_instance_eval(0, NULL, self);
|
980
|
+
}
|
981
|
+
return self;
|
982
|
+
}
|