rmagick 1.15.17 → 2.0.0

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.

Files changed (108) hide show
  1. data/ChangeLog +78 -25
  2. data/README.html +117 -188
  3. data/README.txt +116 -181
  4. data/build_tarball.rake +205 -0
  5. data/doc/comtasks.html +2 -2
  6. data/doc/constants.html +118 -44
  7. data/doc/draw.html +57 -99
  8. data/doc/ex/adaptive_threshold.rb +1 -10
  9. data/doc/ex/add_noise.rb +4 -5
  10. data/doc/ex/axes.rb +1 -1
  11. data/doc/ex/bilevel_channel.rb +2 -13
  12. data/doc/ex/bounding_box.rb +3 -4
  13. data/doc/ex/channel.rb +6 -7
  14. data/doc/ex/clip_path.rb +11 -5
  15. data/doc/ex/color_histogram.rb +8 -20
  16. data/doc/ex/composite_layers.rb +53 -0
  17. data/doc/ex/fill_pattern.rb +26 -0
  18. data/doc/ex/get_multiline_type_metrics.rb +26 -37
  19. data/doc/ex/get_type_metrics.rb +25 -25
  20. data/doc/ex/images/notimplemented.gif +0 -0
  21. data/doc/ex/level.rb +1 -1
  22. data/doc/ex/matte_floodfill.rb +5 -6
  23. data/doc/ex/matte_replace.rb +5 -6
  24. data/doc/ex/negate_channel.rb +0 -10
  25. data/doc/ex/opacity.rb +3 -5
  26. data/doc/ex/polaroid.rb +4 -1
  27. data/doc/ex/posterize.rb +1 -12
  28. data/doc/ex/preview.rb +1 -8
  29. data/doc/ex/radial_blur.rb +1 -11
  30. data/doc/ex/raise.rb +1 -4
  31. data/doc/ex/random_threshold_channel.rb +4 -9
  32. data/doc/ex/sepiatone.rb +2 -9
  33. data/doc/ex/shadow.rb +12 -18
  34. data/doc/ex/sketch.rb +2 -9
  35. data/doc/ex/smile.rb +7 -7
  36. data/doc/ex/splice.rb +3 -10
  37. data/doc/ex/stegano.rb +5 -0
  38. data/doc/ex/threshold.rb +2 -2
  39. data/doc/ex/transpose.rb +1 -8
  40. data/doc/ex/transverse.rb +1 -8
  41. data/doc/ex/trim.rb +1 -2
  42. data/doc/ex/viewex.rb +4 -5
  43. data/doc/ex/vignette.rb +1 -8
  44. data/doc/ex/watermark.rb +1 -0
  45. data/doc/ex/wet_floor.rb +8 -14
  46. data/doc/ilist.html +301 -110
  47. data/doc/image1.html +362 -258
  48. data/doc/image2.html +429 -286
  49. data/doc/image3.html +418 -192
  50. data/doc/imageattrs.html +100 -39
  51. data/doc/imusage.html +26 -21
  52. data/doc/index.html +52 -93
  53. data/doc/info.html +160 -64
  54. data/doc/magick.html +37 -71
  55. data/doc/optequiv.html +155 -61
  56. data/doc/rvg.html +3 -3
  57. data/doc/rvgclip.html +2 -2
  58. data/doc/rvggroup.html +2 -2
  59. data/doc/rvgimage.html +3 -3
  60. data/doc/rvgpattern.html +3 -3
  61. data/doc/rvgshape.html +2 -2
  62. data/doc/rvgstyle.html +2 -2
  63. data/doc/rvgtext.html +2 -2
  64. data/doc/rvgtspan.html +4 -4
  65. data/doc/rvgtut.html +4 -4
  66. data/doc/rvguse.html +3 -3
  67. data/doc/rvgxform.html +2 -2
  68. data/doc/struct.html +26 -29
  69. data/doc/usage.html +99 -48
  70. data/examples/crop_with_gravity.rb +46 -0
  71. data/examples/demo.rb +2 -2
  72. data/examples/histogram.rb +11 -11
  73. data/examples/identify.rb +45 -45
  74. data/examples/spinner.rb +3 -2
  75. data/ext/RMagick/MANIFEST +7 -8
  76. data/ext/RMagick/extconf.rb +242 -0
  77. data/ext/RMagick/rmagick.h +136 -222
  78. data/ext/RMagick/rmdraw.c +226 -229
  79. data/ext/RMagick/rmfill.c +69 -118
  80. data/ext/RMagick/rmilist.c +234 -94
  81. data/ext/RMagick/rmimage.c +1719 -2564
  82. data/ext/RMagick/rminfo.c +433 -619
  83. data/ext/RMagick/rmmain.c +249 -487
  84. data/ext/RMagick/rmutil.c +344 -563
  85. data/lib/RMagick.rb +414 -358
  86. data/lib/rvg/clippath.rb +2 -2
  87. data/lib/rvg/container.rb +2 -2
  88. data/lib/rvg/describable.rb +2 -2
  89. data/lib/rvg/embellishable.rb +2 -2
  90. data/lib/rvg/misc.rb +3 -3
  91. data/lib/rvg/paint.rb +2 -7
  92. data/lib/rvg/pathdata.rb +2 -2
  93. data/lib/rvg/rvg.rb +2 -2
  94. data/lib/rvg/stretchable.rb +2 -14
  95. data/lib/rvg/stylable.rb +2 -2
  96. data/lib/rvg/text.rb +2 -2
  97. data/lib/rvg/transformable.rb +2 -2
  98. data/lib/rvg/units.rb +2 -2
  99. data/{metaconfig.in → metaconfig} +0 -1
  100. data/post-setup.rb +1 -1
  101. data/rmagick.gemspec +6 -9
  102. metadata +41 -49
  103. data/Makefile.in +0 -42
  104. data/configure +0 -12358
  105. data/configure.ac +0 -791
  106. data/ext/RMagick/extconf.rb.in +0 -25
  107. data/ext/RMagick/rmagick_config.h.in +0 -285
  108. data/gem_extconf.rb +0 -42
@@ -1,6 +1,6 @@
1
- /* $Id: rminfo.c,v 1.45.2.2.2.3 2008/09/10 23:22:46 rmagick Exp $ */
1
+ /* $Id: rminfo.c,v 1.67 2007/10/28 23:43:24 rmagick Exp $ */
2
2
  /*============================================================================\
3
- | Copyright (C) 2008 by Timothy P. Hunter
3
+ | Copyright (C) 2007 by Timothy P. Hunter
4
4
  | Name: rminfo.c
5
5
  | Author: Tim Hunter
6
6
  | Purpose: Info class method definitions for RMagick.
@@ -8,153 +8,304 @@
8
8
 
9
9
  #include "rmagick.h"
10
10
 
11
- static VALUE get_option(VALUE, char *);
12
- static VALUE set_option(VALUE, char *, VALUE);
13
11
 
14
12
 
15
- DEF_ATTR_ACCESSOR(Info, antialias, bool)
13
+
16
14
 
17
15
  /*
18
- * Method: value = Info[format, key]
19
- * Purpose: get the value of an option set by Info[]=
16
+ Method: Info#get_option
17
+ Purpose: Return the value of the specified option
20
18
  */
21
- #define MAX_FORMAT_LEN 60
22
-
23
- VALUE
24
- Info_aref(VALUE self, VALUE format, VALUE key)
19
+ static VALUE
20
+ get_option(VALUE self, const char *key)
25
21
  {
26
- #if defined(HAVE_SETIMAGEOPTION)
27
22
  Info *info;
28
- char *format_p, *key_p;
29
- long format_l, key_l;
30
23
  const char *value;
31
- char fkey[MaxTextExtent];
32
24
 
33
- format_p = STRING_PTR_LEN(format, format_l);
34
- key_p = STRING_PTR_LEN(key, key_l);
25
+ Data_Get_Struct(self, Info, info);
35
26
 
36
- if (format_l > MAX_FORMAT_LEN || format_l + key_l > MaxTextExtent-1)
27
+ value = GetImageOption(info, key);
28
+ if (value)
37
29
  {
38
- rb_raise(rb_eArgError, "can't reference %.60s:%.1024s - too long", format_p, key_p);
30
+ return rb_str_new2(value);
39
31
  }
32
+ return Qnil;
33
+ }
40
34
 
41
- sprintf(fkey, "%.60s:%.*s", STRING_PTR(format), (int)(MaxTextExtent-61), STRING_PTR(key));
35
+ /*
36
+ Method: Info#set_option
37
+ Purpose: Set the specified option to this value.
38
+ If the value is nil just unset any current value
39
+ */
40
+ static VALUE
41
+ set_option(VALUE self, const char *key, VALUE string)
42
+ {
43
+ Info *info;
44
+ char *value;
42
45
 
43
46
  Data_Get_Struct(self, Info, info);
44
- value = GetImageOption(info, fkey);
45
- if (!value)
47
+
48
+ if (NIL_P(string))
46
49
  {
47
- return Qnil;
50
+ (void) RemoveImageOption(info, key);
48
51
  }
52
+ else
53
+ {
54
+ value = StringValuePtr(string);
55
+ (void) SetImageOption(info, key, value);
56
+ }
57
+ return self;
58
+ }
49
59
 
50
- return rb_str_new2(value);
51
60
 
52
- #elif defined(HAVE_ADDDEFINITIONS)
61
+ /*
62
+ Static: set_color_option
63
+ Purpose: Set a color name as the value of the specified option
64
+ Note: Call QueryColorDatabase to validate color name
65
+ */
66
+ static VALUE set_color_option(VALUE self, const char *option, VALUE color)
67
+ {
68
+ Info *info;
69
+ char *name;
70
+ PixelPacket pp;
71
+ ExceptionInfo exception;
72
+ MagickBooleanType okay;
73
+
74
+ Data_Get_Struct(self, Info, info);
75
+
76
+ if (NIL_P(color))
77
+ {
78
+ (void) RemoveImageOption(info, option);
79
+ }
80
+ else
81
+ {
82
+ GetExceptionInfo(&exception);
83
+ name = StringValuePtr(color);
84
+ okay = QueryColorDatabase(name, &pp, &exception);
85
+ (void) DestroyExceptionInfo(&exception);
86
+ if (!okay)
87
+ {
88
+ rb_raise(rb_eArgError, "invalid color name `%s'", name);
89
+ }
90
+
91
+ (void) RemoveImageOption(info, option);
92
+ (void) SetImageOption(info, option, name);
93
+ }
94
+
95
+ return self;
96
+ }
97
+
98
+
99
+ /*
100
+ Static: get_dbl_option(obj, option)
101
+ Purpose: Get an Image::Info option floating-point value
102
+ Notes: Convert the string value to a float
103
+ */
104
+ static VALUE get_dbl_option(VALUE self, const char *option)
105
+ {
53
106
  Info *info;
54
107
  const char *value;
108
+ double d;
109
+ long n;
55
110
 
56
111
  Data_Get_Struct(self, Info, info);
57
- value = AccessDefinition(info, STRING_PTR(format), STRING_PTR(key));
58
112
 
113
+ value = GetImageOption(info, option);
59
114
  if (!value)
60
115
  {
61
116
  return Qnil;
62
117
  }
63
118
 
64
- return rb_str_new2(value);
65
- #else
66
- rm_not_implemented();
67
- return (VALUE)0;
68
- #endif
119
+ d = atof(value);
120
+ n = (long) floor(d);
121
+ return d == (double)n ? LONG2NUM(n) : rb_float_new(d);
69
122
  }
70
123
 
71
124
 
72
125
  /*
73
- Method: Info[format, key] = value
74
- Purpose: Call AddDefinitions (GM) or SetImageOption (IM)
75
- Note: Essentially the same function as Info#define but paired
76
- with Info#[]=
126
+ Static: set_dbl_option(obj, option, value)
127
+ Purpose: Set an Image::Info option to a floating-point value
128
+ Notes: SetImageOption expects the value to be a string.
129
+ */
130
+ static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
131
+ {
132
+ Info *info;
133
+ char buff[50];
134
+ double d;
135
+ long n;
136
+ int len;
137
+
138
+ Data_Get_Struct(self, Info, info);
139
+
140
+ if (NIL_P(value))
141
+ {
142
+ (void) RemoveImageOption(info, option);
143
+ }
144
+ else
145
+ {
146
+ d = NUM2DBL(value);
147
+ n = floor(d);
148
+ if (d == n)
149
+ {
150
+ len = sprintf(buff, "%-10ld", n);
151
+ }
152
+ else
153
+ {
154
+ len = sprintf(buff, "%-10.2f", d);
155
+ }
156
+ memset(buff+len, '\0', sizeof(buff)-len);
157
+ (void) RemoveImageOption(info, option);
158
+ (void) SetImageOption(info, option, buff);
159
+ }
160
+
161
+ return self;
162
+ }
163
+
164
+
165
+ DEF_ATTR_ACCESSOR(Info, antialias, bool)
166
+
167
+ /*
168
+ Method: value = Info[format, key]
169
+ value = Info[key]
170
+ Purpose: get the value of an option set by Info[]=
171
+ The 2 argument form is the original form. Added support for a
172
+ single argument after ImageMagick started using Set/GetImageOption
173
+ for options that aren't represented by fields in the ImageInfo
174
+ structure.
77
175
  */
176
+ #define MAX_FORMAT_LEN 60
177
+
78
178
  VALUE
79
- Info_aset(VALUE self, VALUE format, VALUE key, VALUE value)
179
+ Info_aref(int argc, VALUE *argv, VALUE self)
80
180
  {
81
- #if defined(HAVE_SETIMAGEOPTION)
82
181
  Info *info;
83
- char *format_p, *key_p, *value_p = "";
182
+ char *format_p, *key_p;
84
183
  long format_l, key_l;
85
- char ckey[MaxTextExtent];
86
- unsigned int okay;
184
+ const char *value;
185
+ char fkey[MaxTextExtent];
87
186
 
187
+ switch (argc)
188
+ {
189
+ case 2:
190
+ format_p = rb_str2cstr(argv[0], &format_l);
191
+ key_p = rb_str2cstr(argv[1], &key_l);
192
+ if (format_l > MAX_FORMAT_LEN || format_l + key_l > MaxTextExtent-1)
193
+ {
194
+ rb_raise(rb_eArgError, "can't reference %.60s:%.1024s - too long", format_p, key_p);
195
+ }
88
196
 
89
- Data_Get_Struct(self, Info, info);
197
+ sprintf(fkey, "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
198
+ break;
90
199
 
91
- format_p = STRING_PTR_LEN(format, format_l);
92
- key_p = STRING_PTR_LEN(key, key_l);
200
+ case 1:
201
+ strncpy(fkey, StringValuePtr(argv[0]), sizeof(fkey)-1);
202
+ fkey[sizeof(fkey)-1] = '\0';
203
+ break;
93
204
 
94
- /* Allow any argument that supports to_s */
95
- value = rb_funcall(value, rm_ID_to_s, 0);
96
- value_p = STRING_PTR(value);
205
+ default:
206
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
207
+ break;
97
208
 
98
- if (format_l > MAX_FORMAT_LEN || format_l+key_l > MaxTextExtent-1)
99
- {
100
- rb_raise(rb_eArgError, "%.60s:%.1024s not defined - too long", format_p, key_p);
101
209
  }
102
210
 
103
- (void) sprintf(ckey, "%.60s:%.*s", format_p, (int)(sizeof(ckey)-MAX_FORMAT_LEN), key_p);
104
-
105
- okay = SetImageOption(info, ckey, value_p);
106
- if (!okay)
211
+ Data_Get_Struct(self, Info, info);
212
+ value = GetImageOption(info, fkey);
213
+ if (!value)
107
214
  {
108
- rb_warn("%.60s:%.1024s not defined - SetImageOption failed.", format_p, key_p);
109
215
  return Qnil;
110
216
  }
111
217
 
112
- return self;
218
+ return rb_str_new2(value);
219
+ }
220
+
221
+
222
+ /*
223
+ Method: Info[format, key] = value
224
+ Purpose: Call SetImageOption
225
+ Note: Essentially the same function as Info#define but paired with Info#[]=
226
+ If the value is nil it is equivalent to #undefine.
113
227
 
114
- #elif defined(HAVE_ADDDEFINITIONS)
228
+ The 2 argument form is the original form. Added support for a
229
+ single argument after ImageMagick started using Set/GetImageOption
230
+ for options that aren't represented by fields in the ImageInfo
231
+ structure.
232
+ */
233
+ VALUE
234
+ Info_aset(int argc, VALUE *argv, VALUE self)
235
+ {
115
236
  Info *info;
116
- char *format_p, *key_p, *value_p = NULL;
117
- long format_l, key_l, value_l = 0;
237
+ volatile VALUE value;
238
+ char *format_p, *key_p, *value_p = "";
239
+ long format_l, key_l;
240
+ char ckey[MaxTextExtent];
118
241
  unsigned int okay;
119
- ExceptionInfo exception;
120
- char definitions[MaxTextExtent*2];/* Make this buffer longer than the buffer used */
121
- /* for SetImageOptions since AddDefinitions cats */
122
- /* the value onto the format:key pair. */
123
242
 
124
- Data_Get_Struct(self, Info, info);
125
243
 
126
- format_p = STRING_PTR_LEN(format, format_l);
127
- key_p = STRING_PTR_LEN(key, key_l);
128
- value = rb_funcall(value, rm_ID_to_s, 0);
129
- value_p = STRING_PTR_LEN(value, value_l);
244
+ Data_Get_Struct(self, Info, info);
130
245
 
131
- if ((3 + format_l + key_l + value_l) > sizeof(definitions))
246
+ switch (argc)
132
247
  {
133
- rb_raise(rb_eArgError, "%.60s:%.1024s not defined - too long", format_p, key_p);
248
+ case 3:
249
+ format_p = rb_str2cstr(argv[0], &format_l);
250
+ key_p = rb_str2cstr(argv[1], &key_l);
251
+
252
+ if (format_l > MAX_FORMAT_LEN || format_l+key_l > MaxTextExtent-1)
253
+ {
254
+ rb_raise(rb_eArgError, "%.60s:%.1024s not defined - too long", format_p, key_p);
255
+ }
256
+
257
+ (void) sprintf(ckey, "%.60s:%.*s", format_p, (int)(sizeof(ckey)-MAX_FORMAT_LEN), key_p);
258
+
259
+ value = argv[2];
260
+ break;
261
+
262
+ case 2:
263
+ strncpy(ckey, StringValuePtr(argv[0]), sizeof(ckey)-1);
264
+ ckey[sizeof(ckey)-1] = '\0';
265
+
266
+ value = argv[1];
267
+ break;
268
+
269
+ default:
270
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
271
+ break;
134
272
  }
135
- (void)sprintf(definitions, "%s:%s=", format_p, key_p);
136
- if (value_l > 0)
273
+
274
+ if (NIL_P(value))
137
275
  {
138
- strcat(definitions, value_p);
276
+ (void) RemoveImageOption(info, ckey);
139
277
  }
140
-
141
- GetExceptionInfo(&exception);
142
- okay = AddDefinitions(info, definitions, &exception);
143
- CHECK_EXCEPTION()
144
- (void) DestroyExceptionInfo(&exception);
145
-
146
- if (!okay)
278
+ else
147
279
  {
148
- rb_warn("%.60s:%.1024s not defined - AddDefinitions failed.", format_p, key_p);
149
- return Qnil;
280
+ /* Allow any argument that supports to_s */
281
+ value = rb_funcall(value, rm_ID_to_s, 0);
282
+ value_p = StringValuePtr(value);
283
+
284
+ (void) RemoveImageOption(info, ckey);
285
+ okay = SetImageOption(info, ckey, value_p);
286
+ if (!okay)
287
+ {
288
+ rb_warn("`%s' not defined - SetImageOption failed.", ckey);
289
+ return Qnil;
290
+ }
150
291
  }
151
292
 
293
+
152
294
  return self;
295
+ }
153
296
 
154
- #else
155
- rm_not_implemented();
156
- return (VALUE)0;
157
- #endif
297
+
298
+ VALUE
299
+ Info_attenuate(VALUE self)
300
+ {
301
+ return get_dbl_option(self, "attenuate");
302
+ }
303
+
304
+
305
+ VALUE
306
+ Info_attenuate_eq(VALUE self, VALUE value)
307
+ {
308
+ return set_dbl_option(self, "attenuate", value);
158
309
  }
159
310
 
160
311
 
@@ -186,7 +337,7 @@ Info_authenticate_eq(VALUE self, VALUE passwd)
186
337
 
187
338
  if (!NIL_P(passwd))
188
339
  {
189
- passwd_p = STRING_PTR_LEN(passwd, passwd_len);
340
+ passwd_p = rb_str2cstr(passwd, &passwd_len);
190
341
  }
191
342
 
192
343
  if (info->authenticate)
@@ -271,7 +422,6 @@ Info_border_color_eq(VALUE self, VALUE bc_arg)
271
422
  VALUE
272
423
  Info_channel(int argc, VALUE *argv, VALUE self)
273
424
  {
274
- #if defined(HAVE_IMAGEINFO_CHANNEL)
275
425
  Info *info;
276
426
  ChannelType channels;
277
427
 
@@ -287,10 +437,6 @@ Info_channel(int argc, VALUE *argv, VALUE self)
287
437
 
288
438
  info->channel = channels;
289
439
  return self;
290
- #else
291
- rm_not_implemented();
292
- return (VALUE)0;
293
- #endif
294
440
  }
295
441
 
296
442
 
@@ -355,14 +501,13 @@ Info_compression_eq(VALUE self, VALUE type)
355
501
 
356
502
  /*
357
503
  Method: Info#define(format, key[, value])
358
- Purpose: Call AddDefinitions (GM) or SetImageOption (IM)
504
+ Purpose: Call SetImageOption
359
505
  Note: The only method in Info that is not an
360
506
  attribute accessor.
361
507
  */
362
508
  VALUE
363
509
  Info_define(int argc, VALUE *argv, VALUE self)
364
510
  {
365
- #if defined(HAVE_SETIMAGEOPTION)
366
511
  Info *info;
367
512
  char *format, *key, *value = "";
368
513
  long format_l, key_l;
@@ -372,26 +517,27 @@ Info_define(int argc, VALUE *argv, VALUE self)
372
517
 
373
518
  Data_Get_Struct(self, Info, info);
374
519
 
375
- switch(argc)
520
+ switch (argc)
376
521
  {
377
522
  case 3:
378
523
  /* Allow any argument that supports to_s */
379
524
  fmt_arg = rb_funcall(argv[2], rm_ID_to_s, 0);
380
- value = STRING_PTR(fmt_arg);
525
+ value = StringValuePtr(fmt_arg);
381
526
  case 2:
382
- key = STRING_PTR_LEN(argv[1], key_l);
383
- format = STRING_PTR_LEN(argv[0], format_l);
527
+ key = rb_str2cstr(argv[1], &key_l);
528
+ format = rb_str2cstr(argv[0], &format_l);
384
529
  break;
385
530
  default:
386
531
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
387
532
  }
388
533
 
389
- if (2 + format_l + key_l > (int)sizeof(ckey))
534
+ if (2 + format_l + key_l > (long)sizeof(ckey))
390
535
  {
391
536
  rb_raise(rb_eArgError, "%.20s:%.20s not defined - format or key too long", format, key);
392
537
  }
393
538
  (void) sprintf(ckey, "%s:%s", format, key);
394
539
 
540
+ (void) RemoveImageOption(info, ckey);
395
541
  okay = SetImageOption(info, ckey, value);
396
542
  if (!okay)
397
543
  {
@@ -400,64 +546,6 @@ Info_define(int argc, VALUE *argv, VALUE self)
400
546
  }
401
547
 
402
548
  return self;
403
-
404
- #elif defined(HAVE_ADDDEFINITIONS)
405
- Info *info;
406
- char *format, *key, *value = NULL;
407
- long format_l, key_l, value_l = 0;
408
- unsigned int okay;
409
- volatile VALUE fmt_arg;
410
- ExceptionInfo exception;
411
- char definitions[200]; /* Make this buffer longer than the buffer used */
412
- /* for SetImageOptions since AddDefinitions cats */
413
- /* the value onto the format:key pair. */
414
-
415
- Data_Get_Struct(self, Info, info);
416
-
417
- switch(argc)
418
- {
419
- case 3:
420
- /* Allow any argument that supports to_s */
421
- fmt_arg = rb_funcall(argv[2], rm_ID_to_s, 0);
422
- value = STRING_PTR_LEN(fmt_arg, value_l);
423
- /* Fall through */
424
- case 2:
425
- key = STRING_PTR_LEN(argv[1], key_l);
426
- format = STRING_PTR_LEN(argv[0], format_l);
427
- break;
428
- default:
429
- rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or 3)", argc);
430
- break;
431
- }
432
-
433
-
434
- if ((3 + format_l + key_l + value_l) > sizeof(definitions))
435
- {
436
- rb_raise(rb_eArgError, "%.20s:%.20s not defined - too long", format, key);
437
- }
438
- (void)sprintf(definitions, "%s:%s=", format, key);
439
- if (value)
440
- {
441
- strcat(definitions, value);
442
- }
443
-
444
- GetExceptionInfo(&exception);
445
- okay = AddDefinitions(info, definitions, &exception);
446
- CHECK_EXCEPTION()
447
- (void) DestroyExceptionInfo(&exception);
448
-
449
- if (!okay)
450
- {
451
- rb_warn("%.*s not defined - AddDefinitions failed.", sizeof(definitions), definitions);
452
- return Qnil;
453
- }
454
-
455
- return self;
456
-
457
- #else
458
- rm_not_implemented();
459
- return (VALUE)0;
460
- #endif
461
549
  }
462
550
 
463
551
  /*
@@ -468,7 +556,6 @@ Info_define(int argc, VALUE *argv, VALUE self)
468
556
  VALUE
469
557
  Info_delay(VALUE self)
470
558
  {
471
- #if defined(HAVE_SETIMAGEOPTION)
472
559
  Info *info;
473
560
  const char *delay;
474
561
  char *p;
@@ -487,16 +574,11 @@ Info_delay(VALUE self)
487
574
  return LONG2NUM(d);
488
575
  }
489
576
  return Qnil;
490
- #else
491
- rm_not_implemented();
492
- return (VALUE)0;
493
- #endif
494
577
  }
495
578
 
496
579
  /*
497
580
  * Will raise an exception if `arg' can't be converted to an int.
498
581
  */
499
- #if defined(HAVE_SETIMAGEOPTION)
500
582
  static VALUE
501
583
  arg_is_integer(VALUE arg)
502
584
  {
@@ -504,7 +586,6 @@ arg_is_integer(VALUE arg)
504
586
  d = d; // satisfy icc
505
587
  return arg;
506
588
  }
507
- #endif
508
589
 
509
590
  /*
510
591
  Method: Info#delay=
@@ -514,7 +595,6 @@ arg_is_integer(VALUE arg)
514
595
  VALUE
515
596
  Info_delay_eq(VALUE self, VALUE string)
516
597
  {
517
- #if defined(HAVE_SETIMAGEOPTION)
518
598
  Info *info;
519
599
  int delay;
520
600
  int not_num;
@@ -536,13 +616,10 @@ Info_delay_eq(VALUE self, VALUE string)
536
616
  }
537
617
  delay = NUM2INT(string);
538
618
  sprintf(dstr, "%d", delay);
619
+ (void) RemoveImageOption(info, "delay");
539
620
  (void) SetImageOption(info, "delay", dstr);
540
621
  }
541
622
  return self;
542
- #else
543
- rm_not_implemented();
544
- return (VALUE)0;
545
- #endif
546
623
  }
547
624
 
548
625
  DEF_ATTR_READER(Info, density, str)
@@ -561,7 +638,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
561
638
 
562
639
  Data_Get_Struct(self, Info, info);
563
640
 
564
- if(NIL_P(density_arg))
641
+ if (NIL_P(density_arg))
565
642
  {
566
643
  magick_free(info->density);
567
644
  info->density = NULL;
@@ -569,7 +646,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
569
646
  }
570
647
 
571
648
  density = rb_funcall(density_arg, rm_ID_to_s, 0);
572
- dens = STRING_PTR(density);
649
+ dens = StringValuePtr(density);
573
650
  if (!IsGeometry(dens))
574
651
  {
575
652
  rb_raise(rb_eArgError, "invalid density geometry: %s", dens);
@@ -598,11 +675,14 @@ Info_depth_eq(VALUE self, VALUE depth)
598
675
  switch (d)
599
676
  {
600
677
  case 8: // always okay
601
- #if QuantumDepth == 16 || QuantumDepth == 32
678
+ #if QuantumDepth == 16 || QuantumDepth == 32 || QuantumDepth == 64
602
679
  case 16:
603
- #endif
604
- #if QuantumDepth == 32
680
+ #if QuantumDepth == 32 || QuantumDepth == 64
605
681
  case 32:
682
+ #if QuantumDepth == 64
683
+ case 64:
684
+ #endif
685
+ #endif
606
686
  #endif
607
687
  break;
608
688
  default:
@@ -619,31 +699,28 @@ Info_depth_eq(VALUE self, VALUE depth)
619
699
  Purpose: Retrieve a dispose option string and convert it to
620
700
  a DisposeType enumerator
621
701
  */
622
- #if defined(HAVE_SETIMAGEOPTION)
623
702
  static struct
624
703
  {
625
704
  char *string;
626
705
  char *enum_name;
627
706
  DisposeType enumerator;
628
707
  } Dispose_Option[] = {
629
- { "Background", "BackgroundDispose", BackgroundDispose },
630
- { "None", "NoneDispose", NoneDispose },
631
- { "Previous", "PreviousDispose", PreviousDispose },
632
- { "Undefined", "UndefinedDispose", UndefinedDispose },
633
- { "0", "UndefinedDispose", UndefinedDispose },
634
- { "1", "NoneDispose", NoneDispose },
635
- { "2", "BackgroundDispose", BackgroundDispose },
636
- { "3", "PreviousDispose", PreviousDispose },
637
- };
638
- #define N_DISPOSE_OPTIONS (sizeof(Dispose_Option)/sizeof(Dispose_Option[0]))
639
- #endif
708
+ { "Background", "BackgroundDispose", BackgroundDispose},
709
+ { "None", "NoneDispose", NoneDispose},
710
+ { "Previous", "PreviousDispose", PreviousDispose},
711
+ { "Undefined", "UndefinedDispose", UndefinedDispose},
712
+ { "0", "UndefinedDispose", UndefinedDispose},
713
+ { "1", "NoneDispose", NoneDispose},
714
+ { "2", "BackgroundDispose", BackgroundDispose},
715
+ { "3", "PreviousDispose", PreviousDispose},
716
+ };
717
+ #define N_DISPOSE_OPTIONS (int)(sizeof(Dispose_Option)/sizeof(Dispose_Option[0]))
640
718
 
641
719
  VALUE
642
720
  Info_dispose(VALUE self)
643
721
  {
644
- #if defined(HAVE_SETIMAGEOPTION)
645
722
  Info *info;
646
- unsigned int x;
723
+ int x;
647
724
  ID dispose_id;
648
725
  const char *dispose;
649
726
 
@@ -666,10 +743,6 @@ Info_dispose(VALUE self)
666
743
  }
667
744
 
668
745
  return rb_const_get(Module_Magick, dispose_id);
669
- #else
670
- rm_not_implemented();
671
- return (VALUE)0;
672
- #endif
673
746
  }
674
747
 
675
748
  /*
@@ -680,11 +753,10 @@ Info_dispose(VALUE self)
680
753
  VALUE
681
754
  Info_dispose_eq(VALUE self, VALUE disp)
682
755
  {
683
- #if defined(HAVE_SETIMAGEOPTION)
684
756
  Info *info;
685
757
  DisposeType dispose;
686
758
  char *option;
687
- unsigned int x;
759
+ int x;
688
760
 
689
761
  Data_Get_Struct(self, Info, info);
690
762
 
@@ -697,7 +769,7 @@ Info_dispose_eq(VALUE self, VALUE disp)
697
769
  VALUE_TO_ENUM(disp, dispose, DisposeType);
698
770
  option = "Undefined";
699
771
 
700
- for(x = 0; x < N_DISPOSE_OPTIONS; x++)
772
+ for (x = 0; x < N_DISPOSE_OPTIONS; x++)
701
773
  {
702
774
  if (dispose == Dispose_Option[x].enumerator)
703
775
  {
@@ -708,16 +780,10 @@ Info_dispose_eq(VALUE self, VALUE disp)
708
780
 
709
781
  (void) SetImageOption(info, "dispose", option);
710
782
  return self;
711
-
712
- #else
713
- rm_not_implemented();
714
- return (VALUE)0;
715
- #endif
716
783
  }
717
784
 
718
785
  DEF_ATTR_ACCESSOR(Info, dither, bool)
719
786
 
720
- #ifdef HAVE_IMAGE_EXTRACT_INFO
721
787
 
722
788
  /*
723
789
  Method: aString=Info#extract
@@ -733,111 +799,29 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
733
799
  {
734
800
  Info *info;
735
801
  char *extr;
736
- volatile VALUE extract;
737
-
738
- Data_Get_Struct(self, Info, info);
739
-
740
- if (NIL_P(extract_arg))
741
- {
742
- magick_free(info->extract);
743
- info->extract = NULL;
744
- return self;
745
- }
746
-
747
- extract = rb_funcall(extract_arg, rm_ID_to_s, 0);
748
- extr = STRING_PTR(extract);
749
- if (!IsGeometry(extr))
750
- {
751
- rb_raise(rb_eArgError, "invalid extract geometry: %s", extr);
752
- }
753
-
754
- magick_clone_string(&info->extract, extr);
755
-
756
- return self;
757
- }
758
- /*
759
- Method: aString=Info#tile
760
- Info#tile=aString
761
- Purpose: Get/set the "tile" string, e.g. "200x200+100+100"
762
- Raise: ArgumentError
763
- Notes: defined for IM 5.5.6 and later. Actually these are effectively
764
- aliases for extract & extract= but with warning messages.
765
- */
766
-
767
- VALUE
768
- Info_tile(VALUE self)
769
- {
770
- rb_warning("RMagick: tile is deprecated in this release of ImageMagick. Use extract instead.");
771
- return Info_extract(self);
772
- }
773
-
774
- VALUE
775
- Info_tile_eq(VALUE self, VALUE tile)
776
- {
777
- rb_warning("RMagick: tile= is deprecated in this release of ImageMagick. Use extract= instead.");
778
- return Info_extract_eq(self, tile);
779
- }
780
-
781
- #else
782
-
783
- /*
784
- Method: aString=Info#extract
785
- Info#extract=aString
786
- Purpose: Get/set the extract string, e.g. "200x200+100+100"
787
- Raise: ArgumentError
788
- Notes: defined for IM 5.5.6 and later
789
- */
790
- VALUE
791
- Info_extract(VALUE self)
792
- {
793
- rm_not_implemented();
794
- return (VALUE)0;
795
- }
796
- VALUE
797
- Info_extract_eq(VALUE self, VALUE extr)
798
- {
799
- rm_not_implemented();
800
- return (VALUE)0;
801
- }
802
-
803
- /*
804
- Method: aString = Info#tile
805
- Info#tile=aString
806
- Purpose: Get/set the tile string, e.g. "200x200+100+100"
807
- Raise: ArgumentError
808
- Notes: defined for IM 5.5.5 and earlier, before the tile field was
809
- deprecated and replaced by extract
810
- */
811
- DEF_ATTR_READER(Info, tile, str)
812
-
813
- VALUE
814
- Info_tile_eq(VALUE self, VALUE tile_arg)
815
- {
816
- Info *info;
817
- char *til;
818
- volatile VALUE tile;
802
+ volatile VALUE extract;
819
803
 
820
804
  Data_Get_Struct(self, Info, info);
821
805
 
822
- if (NIL_P(tile_arg))
806
+ if (NIL_P(extract_arg))
823
807
  {
824
- magick_free(info->tile);
825
- info->tile = NULL;
808
+ magick_free(info->extract);
809
+ info->extract = NULL;
826
810
  return self;
827
811
  }
828
812
 
829
- tile = rb_funcall(tile_arg, rm_ID_to_s, 0);
830
- til = STRING_PTR(tile);
831
- if (!IsGeometry(til))
813
+ extract = rb_funcall(extract_arg, rm_ID_to_s, 0);
814
+ extr = StringValuePtr(extract);
815
+ if (!IsGeometry(extr))
832
816
  {
833
- rb_raise(rb_eArgError, "invalid tile geometry: %s", til);
817
+ rb_raise(rb_eArgError, "invalid extract geometry: %s", extr);
834
818
  }
835
819
 
836
- magick_clone_string(&info->tile, til);
820
+ magick_clone_string(&info->extract, extr);
837
821
 
838
822
  return self;
839
823
  }
840
- #endif
824
+
841
825
 
842
826
  /*
843
827
  Methods: aString=Info#filename
@@ -864,14 +848,14 @@ Info_filename_eq(VALUE self, VALUE filename)
864
848
  Data_Get_Struct(self, Info, info);
865
849
 
866
850
  // Allow "nil" - remove current filename
867
- if (NIL_P(filename) || STRING_PTR(filename) == NULL)
851
+ if (NIL_P(filename) || StringValuePtr(filename) == NULL)
868
852
  {
869
853
  info->filename[0] = '\0';
870
854
  }
871
855
  else
872
856
  {
873
857
  // Otherwise copy in filename
874
- fname = STRING_PTR(filename);
858
+ fname = StringValuePtr(filename);
875
859
  strncpy(info->filename, fname, MaxTextExtent);
876
860
  }
877
861
  return self;
@@ -880,47 +864,23 @@ Info_filename_eq(VALUE self, VALUE filename)
880
864
 
881
865
  /*
882
866
  Method: Info#fill
883
- Purpose: return the fill (a.k.a pen) color as a String
884
- Note: Compare with Image#fill!
867
+ Purpose: return the fill color as a String
885
868
  */
886
869
  VALUE
887
870
  Info_fill(VALUE self)
888
871
  {
889
- #if defined(HAVE_SETIMAGEOPTION)
890
- Info *info;
891
- const char *fill;
892
-
893
- Data_Get_Struct(self, Info, info);
894
- fill = GetImageOption(info, "fill");
895
- return fill ? rb_str_new2(fill) : Qnil;
896
- #else
897
- Info *info;
898
-
899
- Data_Get_Struct(self, Info, info);
900
- return PixelPacket_to_Color_Name_Info(info, &info->pen);
901
- #endif
872
+ return get_option(self, "fill");
902
873
  }
903
874
 
904
875
  /*
905
876
  Method: Info#fill=<aString>
906
- Purpose: set the fill (a.k.a. pen) color
877
+ Purpose: set the fill color
907
878
  Raises: ArgumentError
908
879
  */
909
880
  VALUE
910
881
  Info_fill_eq(VALUE self, VALUE color)
911
882
  {
912
- Info *info;
913
-
914
- Data_Get_Struct(self, Info, info);
915
- Color_to_PixelPacket(&info->pen, color);
916
-
917
- #if defined(HAVE_SETIMAGEOPTION)
918
- // Color_to_PixelPacket will raise an exception if `color' isn't a real color.
919
- (void) RemoveImageOption(info, "fill");
920
- (void) SetImageOption(info, "fill", STRING_PTR(color));
921
- #endif
922
-
923
- return self;
883
+ return set_color_option(self, "fill", color);
924
884
  }
925
885
 
926
886
 
@@ -938,14 +898,14 @@ Info_font_eq(VALUE self, VALUE font_arg)
938
898
  char *font;
939
899
 
940
900
  Data_Get_Struct(self, Info, info);
941
- if (NIL_P(font_arg) || STRING_PTR(font_arg) == NULL)
901
+ if (NIL_P(font_arg) || StringValuePtr(font_arg) == NULL)
942
902
  {
943
903
  magick_free(info->font);
944
904
  info->font = NULL;
945
905
  }
946
906
  else
947
907
  {
948
- font = STRING_PTR(font_arg);
908
+ font = StringValuePtr(font_arg);
949
909
  magick_clone_string(&info->font, font);
950
910
  }
951
911
  return self;
@@ -990,7 +950,7 @@ Info_format_eq(VALUE self, VALUE magick)
990
950
 
991
951
  GetExceptionInfo(&exception);
992
952
 
993
- mgk = STRING_PTR(magick);
953
+ mgk = StringValuePtr(magick);
994
954
  m = GetMagickInfo(mgk, &exception);
995
955
  CHECK_EXCEPTION()
996
956
  (void) DestroyExceptionInfo(&exception);
@@ -1025,33 +985,30 @@ VALUE Info_fuzz_eq(VALUE self, VALUE fuzz)
1025
985
  Purpose: Return the value of the gravity option as a GravityType enumerator
1026
986
  */
1027
987
 
1028
- #if defined(HAVE_SETIMAGEOPTION)
1029
988
  static struct
1030
989
  {
1031
990
  char *string;
1032
991
  char *enum_name;
1033
992
  GravityType enumerator;
1034
993
  } Gravity_Option[] = {
1035
- { "Undefined", "UndefinedGravity", UndefinedGravity },
1036
- { "None", "UndefinedGravity", UndefinedGravity },
1037
- { "Center", "CenterGravity", CenterGravity },
994
+ { "Undefined", "UndefinedGravity", UndefinedGravity},
995
+ { "None", "UndefinedGravity", UndefinedGravity},
996
+ { "Center", "CenterGravity", CenterGravity},
1038
997
  { "East", "EastGravity", EastGravity},
1039
- { "Forget", "ForgetGravity", ForgetGravity },
1040
- { "NorthEast", "NorthEastGravity", NorthEastGravity },
1041
- { "North", "NorthGravity", NorthGravity },
1042
- { "NorthWest", "NorthWestGravity", NorthWestGravity },
1043
- { "SouthEast", "SouthEastGravity", SouthEastGravity },
1044
- { "South", "SouthGravity", SouthGravity },
1045
- { "SouthWest", "SouthWestGravity", SouthWestGravity },
1046
- { "West", "WestGravity", WestGravity },
1047
- { "Static", "StaticGravity", StaticGravity }
1048
- };
1049
- #define N_GRAVITY_OPTIONS (sizeof(Gravity_Option)/sizeof(Gravity_Option[0]))
1050
- #endif
998
+ { "Forget", "ForgetGravity", ForgetGravity},
999
+ { "NorthEast", "NorthEastGravity", NorthEastGravity},
1000
+ { "North", "NorthGravity", NorthGravity},
1001
+ { "NorthWest", "NorthWestGravity", NorthWestGravity},
1002
+ { "SouthEast", "SouthEastGravity", SouthEastGravity},
1003
+ { "South", "SouthGravity", SouthGravity},
1004
+ { "SouthWest", "SouthWestGravity", SouthWestGravity},
1005
+ { "West", "WestGravity", WestGravity},
1006
+ { "Static", "StaticGravity", StaticGravity}
1007
+ };
1008
+ #define N_GRAVITY_OPTIONS (int)(sizeof(Gravity_Option)/sizeof(Gravity_Option[0]))
1051
1009
 
1052
1010
  VALUE Info_gravity(VALUE self)
1053
1011
  {
1054
- #if defined(HAVE_SETIMAGEOPTION)
1055
1012
  Info *info;
1056
1013
  const char *gravity;
1057
1014
  int x;
@@ -1076,11 +1033,6 @@ VALUE Info_gravity(VALUE self)
1076
1033
  }
1077
1034
 
1078
1035
  return rb_const_get(Module_Magick, gravity_id);
1079
-
1080
- #else
1081
- rm_not_implemented();
1082
- return (VALUE)0;
1083
- #endif
1084
1036
  }
1085
1037
 
1086
1038
  /*
@@ -1091,7 +1043,6 @@ VALUE Info_gravity(VALUE self)
1091
1043
  VALUE
1092
1044
  Info_gravity_eq(VALUE self, VALUE grav)
1093
1045
  {
1094
- #if defined(HAVE_SETIMAGEOPTION)
1095
1046
  Info *info;
1096
1047
  GravityType gravity;
1097
1048
  char *option;
@@ -1108,7 +1059,7 @@ Info_gravity_eq(VALUE self, VALUE grav)
1108
1059
  VALUE_TO_ENUM(grav, gravity, GravityType);
1109
1060
  option = "Undefined";
1110
1061
 
1111
- for(x = 0; x < N_GRAVITY_OPTIONS; x++)
1062
+ for (x = 0; x < N_GRAVITY_OPTIONS; x++)
1112
1063
  {
1113
1064
  if (gravity == Gravity_Option[x].enumerator)
1114
1065
  {
@@ -1119,11 +1070,6 @@ Info_gravity_eq(VALUE self, VALUE grav)
1119
1070
 
1120
1071
  (void) SetImageOption(info, "gravity", option);
1121
1072
  return self;
1122
-
1123
- #else
1124
- rm_not_implemented();
1125
- return (VALUE)0;
1126
- #endif
1127
1073
  }
1128
1074
 
1129
1075
 
@@ -1226,7 +1172,6 @@ Info_matte_color_eq(VALUE self, VALUE matte_arg)
1226
1172
  VALUE
1227
1173
  Info_monitor_eq(VALUE self, VALUE monitor)
1228
1174
  {
1229
- #if defined(HAVE_SETIMAGEPROGRESSMONITOR)
1230
1175
  Info *info;
1231
1176
 
1232
1177
  Data_Get_Struct(self, Info, info);
@@ -1242,10 +1187,6 @@ Info_monitor_eq(VALUE self, VALUE monitor)
1242
1187
 
1243
1188
 
1244
1189
  return self;
1245
- #else
1246
- rm_not_implemented();
1247
- return (VALUE)0;
1248
- #endif
1249
1190
  }
1250
1191
 
1251
1192
 
@@ -1253,27 +1194,7 @@ Info_monitor_eq(VALUE self, VALUE monitor)
1253
1194
 
1254
1195
  DEF_ATTR_ACCESSOR(Info, monochrome, bool)
1255
1196
 
1256
- #ifdef HAVE_IMAGEINFO_NUMBER_SCENES
1257
1197
  DEF_ATTR_ACCESSOR(Info, number_scenes, ulong)
1258
- #else
1259
-
1260
- /*
1261
- Methods: num = Info#number_scenes
1262
- Info#number_scenes = num
1263
- Purpose: alias for subrange when IM < 5.5.6
1264
- */
1265
- VALUE
1266
- Info_number_scenes(VALUE self)
1267
- {
1268
- return Info_subrange(self);
1269
- }
1270
-
1271
- VALUE
1272
- Info_number_scenes_eq(VALUE self, VALUE nscenes)
1273
- {
1274
- return Info_subrange_eq(self, nscenes);
1275
- }
1276
- #endif
1277
1198
 
1278
1199
  /*
1279
1200
  Method: Info#orientation
@@ -1282,15 +1203,10 @@ Info_number_scenes_eq(VALUE self, VALUE nscenes)
1282
1203
  VALUE
1283
1204
  Info_orientation(VALUE self)
1284
1205
  {
1285
- #if defined(HAVE_IMAGEINFO_ORIENTATION)
1286
1206
  Info *info;
1287
1207
 
1288
1208
  Data_Get_Struct(self, Info, info);
1289
1209
  return OrientationType_new(info->orientation);
1290
- #else
1291
- rm_not_implemented();
1292
- return (VALUE)0;
1293
- #endif
1294
1210
  }
1295
1211
 
1296
1212
 
@@ -1302,16 +1218,11 @@ Info_orientation(VALUE self)
1302
1218
  VALUE
1303
1219
  Info_orientation_eq(VALUE self, VALUE inter)
1304
1220
  {
1305
- #if defined(HAVE_IMAGEINFO_ORIENTATION)
1306
1221
  Info *info;
1307
1222
 
1308
1223
  Data_Get_Struct(self, Info, info);
1309
1224
  VALUE_TO_ENUM(inter, info->orientation, OrientationType);
1310
1225
  return self;
1311
- #else
1312
- rm_not_implemented();
1313
- return (VALUE)0;
1314
- #endif
1315
1226
  }
1316
1227
 
1317
1228
 
@@ -1322,7 +1233,6 @@ Info_orientation_eq(VALUE self, VALUE inter)
1322
1233
  VALUE
1323
1234
  Info_origin(VALUE self)
1324
1235
  {
1325
- #if defined(HAVE_SETIMAGEOPTION)
1326
1236
  Info *info;
1327
1237
  const char *origin;
1328
1238
 
@@ -1330,11 +1240,6 @@ Info_origin(VALUE self)
1330
1240
 
1331
1241
  origin = GetImageOption(info, "origin");
1332
1242
  return origin ? rb_str_new2(origin) : Qnil;
1333
-
1334
- #else
1335
- rm_not_implemented();
1336
- return (VALUE)0;
1337
- #endif
1338
1243
  }
1339
1244
 
1340
1245
 
@@ -1346,7 +1251,6 @@ Info_origin(VALUE self)
1346
1251
  VALUE
1347
1252
  Info_origin_eq(VALUE self, VALUE origin_arg)
1348
1253
  {
1349
- #if defined(HAVE_SETIMAGEOPTION)
1350
1254
  Info *info;
1351
1255
  volatile VALUE origin_str;
1352
1256
  char *origin;
@@ -1360,7 +1264,7 @@ Info_origin_eq(VALUE self, VALUE origin_arg)
1360
1264
  }
1361
1265
 
1362
1266
  origin_str = rb_funcall(origin_arg, rm_ID_to_s, 0);
1363
- origin = GetPageGeometry(STRING_PTR(origin_str));
1267
+ origin = GetPageGeometry(StringValuePtr(origin_str));
1364
1268
 
1365
1269
  if (IsGeometry(origin) == MagickFalse)
1366
1270
  {
@@ -1369,11 +1273,6 @@ Info_origin_eq(VALUE self, VALUE origin_arg)
1369
1273
 
1370
1274
  (void) SetImageOption(info, "origin", origin);
1371
1275
  return self;
1372
-
1373
- #else
1374
- rm_not_implemented();
1375
- return (VALUE)0;
1376
- #endif
1377
1276
  }
1378
1277
 
1379
1278
 
@@ -1384,11 +1283,7 @@ Info_page(VALUE self)
1384
1283
  const char *page;
1385
1284
 
1386
1285
  Data_Get_Struct(self, Info, info);
1387
- #if defined(HAVE_SETIMAGEOPTION)
1388
1286
  page = GetImageOption(info, "page");
1389
- #else
1390
- page = (const char *)info->page;
1391
- #endif
1392
1287
  return page ? rb_str_new2(page) : Qnil;
1393
1288
 
1394
1289
  }
@@ -1412,7 +1307,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
1412
1307
  return self;
1413
1308
  }
1414
1309
  geom_str = rb_funcall(page_arg, rm_ID_to_s, 0);
1415
- geometry=GetPageGeometry(STRING_PTR(geom_str));
1310
+ geometry=GetPageGeometry(StringValuePtr(geom_str));
1416
1311
  if (*geometry == '\0')
1417
1312
  {
1418
1313
  magick_free(info->page);
@@ -1420,9 +1315,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
1420
1315
  return self;
1421
1316
  }
1422
1317
  magick_clone_string(&info->page, geometry);
1423
- #if defined(HAVE_SETIMAGEOPTION)
1424
- (void) SetImageOption(info, "page", STRING_PTR(geom_str));
1425
- #endif
1318
+ (void) SetImageOption(info, "page", StringValuePtr(geom_str));
1426
1319
 
1427
1320
  return self;
1428
1321
  }
@@ -1462,7 +1355,7 @@ Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
1462
1355
 
1463
1356
  if (!NIL_P(sampling_factor))
1464
1357
  {
1465
- sampling_factor_p = STRING_PTR_LEN(sampling_factor, sampling_factor_len);
1358
+ sampling_factor_p = rb_str2cstr(sampling_factor, &sampling_factor_len);
1466
1359
  }
1467
1360
 
1468
1361
  if (info->sampling_factor)
@@ -1478,87 +1371,7 @@ Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
1478
1371
  return self;
1479
1372
  }
1480
1373
 
1481
- #ifdef HAVE_IMAGEINFO_NUMBER_SCENES
1482
-
1483
- // Info#scene, scene= is the IM >= 5.5.6 version of the now-deprecated
1484
- // subimage accessors.
1485
1374
  DEF_ATTR_ACCESSOR(Info, scene, ulong)
1486
-
1487
- /*
1488
- Methods: num=Info#subimage
1489
- Info#subimage=num
1490
- Purpose: Get/set the "subimage" value, for IM >= 5.5.6
1491
- Raises: ArgumentError
1492
- Notes: synonyms for Info#scene, Info#scene=
1493
- */
1494
- VALUE
1495
- Info_subimage(VALUE self)
1496
- {
1497
- rb_warning("RMagick: subimage is deprecated in this release of ImageMagick. Use scene instead.");
1498
- return Info_scene(self);
1499
- }
1500
-
1501
- VALUE
1502
- Info_subimage_eq(VALUE self, VALUE subimage)
1503
- {
1504
- rb_warning("RMagick: subimage= is deprecated in this release of ImageMagick. Use scene= instead.");
1505
- return Info_scene_eq(self, subimage);
1506
- }
1507
-
1508
- /*
1509
- Methods: num=Info#subrange
1510
- Info#subrange=num
1511
- Purpose: Get/set the "subrange" value, for IM >= 5.5.6
1512
- Raises: ArgumentError
1513
- Notes: synonyms for Info#number_scenes, Info#number_scenes=
1514
- */
1515
- VALUE
1516
- Info_subrange(VALUE self)
1517
- {
1518
- rb_warning("RMagick: subrange is deprecated in this release of ImageMagick. Use number_scenes instead.");
1519
- return Info_number_scenes(self);
1520
- }
1521
-
1522
- VALUE
1523
- Info_subrange_eq(VALUE self, VALUE subrange)
1524
- {
1525
- rb_warning("RMagick: subrange= is deprecated in this release of ImageMagick. Use number_scenes= instead.");
1526
- return Info_number_scenes_eq(self, subrange);
1527
- }
1528
-
1529
- #else
1530
-
1531
- /*
1532
- Methods: num=Info#scene
1533
- Info#scene=num
1534
- Purpose: Get/set the scene number, for IM < 5.5.6
1535
- Raises: ArgumentError
1536
- Notes: synonyms for Info#subimage, Info#subimage=
1537
- */
1538
- VALUE
1539
- Info_scene(VALUE self)
1540
- {
1541
- Info *info;
1542
-
1543
- Data_Get_Struct(self, Info, info);
1544
- return UINT2NUM(info->subimage);
1545
- }
1546
-
1547
- VALUE
1548
- Info_scene_eq(VALUE self, VALUE scene)
1549
- {
1550
- Info *info;
1551
-
1552
- Data_Get_Struct(self, Info, info);
1553
- info->subimage = NUM2ULONG(scene);
1554
- return self;
1555
- }
1556
-
1557
- DEF_ATTR_ACCESSOR(Info, subimage, ulong)
1558
- DEF_ATTR_ACCESSOR(Info, subrange, ulong)
1559
-
1560
- #endif
1561
-
1562
1375
  DEF_ATTR_READER(Info, server_name, str)
1563
1376
 
1564
1377
  /*
@@ -1572,14 +1385,14 @@ Info_server_name_eq(VALUE self, VALUE server_arg)
1572
1385
  char *server;
1573
1386
 
1574
1387
  Data_Get_Struct(self, Info, info);
1575
- if (NIL_P(server_arg) || STRING_PTR(server_arg) == NULL)
1388
+ if (NIL_P(server_arg) || StringValuePtr(server_arg) == NULL)
1576
1389
  {
1577
1390
  magick_free(info->server_name);
1578
1391
  info->server_name = NULL;
1579
1392
  }
1580
1393
  else
1581
1394
  {
1582
- server = STRING_PTR(server_arg);
1395
+ server = StringValuePtr(server_arg);
1583
1396
  magick_clone_string(&info->server_name, server);
1584
1397
  }
1585
1398
  return self;
@@ -1610,7 +1423,7 @@ Info_size_eq(VALUE self, VALUE size_arg)
1610
1423
  }
1611
1424
 
1612
1425
  size = rb_funcall(size_arg, rm_ID_to_s, 0);
1613
- sz = STRING_PTR(size);
1426
+ sz = StringValuePtr(size);
1614
1427
  if (!IsGeometry(sz))
1615
1428
  {
1616
1429
  rb_raise(rb_eArgError, "invalid size geometry: %s", sz);
@@ -1622,6 +1435,52 @@ Info_size_eq(VALUE self, VALUE size_arg)
1622
1435
  }
1623
1436
 
1624
1437
 
1438
+ /*
1439
+ Method: Info#stroke
1440
+ Purpose: return the stroke color as a String
1441
+ */
1442
+ VALUE
1443
+ Info_stroke(VALUE self)
1444
+ {
1445
+ return get_option(self, "stroke");
1446
+ }
1447
+
1448
+ /*
1449
+ Method: Info#stroke=<aString>
1450
+ Purpose: set the stroke color
1451
+ Raises: ArgumentError
1452
+ */
1453
+ VALUE
1454
+ Info_stroke_eq(VALUE self, VALUE color)
1455
+ {
1456
+ return set_color_option(self, "stroke", color);
1457
+ }
1458
+
1459
+
1460
+ /*
1461
+ Method: Info#stroke_width
1462
+ Purpose: Support for caption: format
1463
+ Notes: Supported >= 6.3.2-6
1464
+ */
1465
+ VALUE
1466
+ Info_stroke_width(VALUE self)
1467
+ {
1468
+ return get_dbl_option(self, "strokewidth");
1469
+ }
1470
+
1471
+
1472
+ /*
1473
+ Method: Info#stroke_width=
1474
+ Purpose: Support for caption: format
1475
+ Notes: Supported >= 6.3.2-6
1476
+ */
1477
+ VALUE
1478
+ Info_stroke_width_eq(VALUE self, VALUE stroke_width)
1479
+ {
1480
+ return set_dbl_option(self, "strokewidth", stroke_width);
1481
+ }
1482
+
1483
+
1625
1484
  /*
1626
1485
  Method: Image::Info#texture=texture_image
1627
1486
  Purpose: Set name of texture to tile onto the image background
@@ -1650,7 +1509,7 @@ Info_texture_eq(VALUE self, VALUE texture)
1650
1509
  }
1651
1510
 
1652
1511
  // Create a temp copy of the texture and store its name in the texture field
1653
- Data_Get_Struct(texture, Image, image);
1512
+ image = rm_check_destroyed(texture);
1654
1513
  rm_write_temp_image(image, name);
1655
1514
 
1656
1515
  magick_clone_string(&info->texture, name);
@@ -1659,6 +1518,55 @@ Info_texture_eq(VALUE self, VALUE texture)
1659
1518
  }
1660
1519
 
1661
1520
 
1521
+ /*
1522
+ Method: Image::Info#tile_offset= geometry
1523
+ Purpose: info.tile_offset = [+/-]x[+/-]y
1524
+ */
1525
+ VALUE
1526
+ Info_tile_offset_eq(VALUE self, VALUE offset)
1527
+ {
1528
+ Info *info;
1529
+ volatile VALUE offset_str;
1530
+ char *tile_offset;
1531
+
1532
+ offset_str = rb_funcall(offset, rm_ID_to_s, 0);
1533
+ tile_offset = StringValuePtr(offset_str);
1534
+ if (!IsGeometry(tile_offset))
1535
+ {
1536
+ rb_raise(rb_eArgError, "invalid tile offset geometry: %s", tile_offset);
1537
+ }
1538
+
1539
+ Data_Get_Struct(self, Info, info);
1540
+
1541
+ (void) DeleteImageOption(info, "tile-offset");
1542
+ (void) SetImageOption(info, "tile-offset", tile_offset);
1543
+ return self;
1544
+ }
1545
+
1546
+
1547
+ /*
1548
+ Method: Image::Info#tile_offset
1549
+ Purpose: returns tile_offset attribute values
1550
+ */
1551
+ VALUE
1552
+ Info_tile_offset(VALUE self)
1553
+ {
1554
+ Info *info;
1555
+ const char *tile_offset;
1556
+
1557
+ Data_Get_Struct(self, Info, info);
1558
+
1559
+ tile_offset = GetImageOption(info, "tile-offset");
1560
+
1561
+ if (!tile_offset)
1562
+ {
1563
+ return Qnil;
1564
+ }
1565
+
1566
+ return rb_str_new2(tile_offset);
1567
+ }
1568
+
1569
+
1662
1570
  /*
1663
1571
  Method: Info#undefine
1664
1572
  Purpose: Undefine image option
@@ -1667,14 +1575,13 @@ Info_texture_eq(VALUE self, VALUE texture)
1667
1575
  VALUE
1668
1576
  Info_undefine(VALUE self, VALUE format, VALUE key)
1669
1577
  {
1670
- #if defined(HAVE_SETIMAGEOPTION)
1671
1578
  Info *info;
1672
1579
  char *format_p, *key_p;
1673
1580
  long format_l, key_l;
1674
1581
  char fkey[MaxTextExtent];
1675
1582
 
1676
- format_p = STRING_PTR_LEN(format, format_l);
1677
- key_p = STRING_PTR_LEN(key, key_l);
1583
+ format_p = rb_str2cstr(format, &format_l);
1584
+ key_p = rb_str2cstr(key, &key_l);
1678
1585
 
1679
1586
  if (format_l > MAX_FORMAT_LEN || format_l + key_l > MaxTextExtent)
1680
1587
  {
@@ -1687,37 +1594,30 @@ Info_undefine(VALUE self, VALUE format, VALUE key)
1687
1594
  /* Depending on the IM version, RemoveImageOption returns either */
1688
1595
  /* char * or MagickBooleanType. Ignore the return value. */
1689
1596
  (void) RemoveImageOption(info, fkey);
1690
- return self;
1691
-
1692
- #elif defined(HAVE_ADDDEFINITIONS)
1693
- Info *info;
1694
- unsigned int okay;
1695
- char *format_p, *key_p;
1696
- long format_l, key_l;
1697
- char fkey[MaxTextExtent];
1698
-
1699
- format_p = STRING_PTR_LEN(format, format_l);
1700
- key_p = STRING_PTR_LEN(key, key_l);
1701
1597
 
1702
- if (format_l > MAX_FORMAT_LEN || format_l + key_l > MaxTextExtent)
1703
- {
1704
- rb_raise(rb_eArgError, "can't undefine %.60s:%.1024s - too long", format_p, key_p);
1705
- }
1598
+ return self;
1599
+ }
1706
1600
 
1707
- sprintf(fkey, "%.60s:%.*s", format_p, MaxTextExtent-61, key_p);
1708
1601
 
1709
- Data_Get_Struct(self, Info, info);
1710
- okay = RemoveDefinitions(info, fkey);
1711
- if (!okay)
1712
- {
1713
- rb_raise(rb_eArgError, "no such key: `%s'", fkey);
1714
- }
1715
- return self;
1602
+ /*
1603
+ Method: Info#undercolor
1604
+ Purpose: return the undercolor color as a String
1605
+ */
1606
+ VALUE
1607
+ Info_undercolor(VALUE self)
1608
+ {
1609
+ return get_option(self, "undercolor");
1610
+ }
1716
1611
 
1717
- #else
1718
- rm_not_implemented();
1719
- return (VALUE)0;
1720
- #endif
1612
+ /*
1613
+ Method: Info#undercolor=<aString>
1614
+ Purpose: set the undercolor color
1615
+ Raises: ArgumentError
1616
+ */
1617
+ VALUE
1618
+ Info_undercolor_eq(VALUE self, VALUE color)
1619
+ {
1620
+ return set_color_option(self, "undercolor", color);
1721
1621
  }
1722
1622
 
1723
1623
  /*
@@ -1762,14 +1662,14 @@ Info_view_eq(VALUE self, VALUE view_arg)
1762
1662
 
1763
1663
  Data_Get_Struct(self, Info, info);
1764
1664
 
1765
- if (NIL_P(view_arg) || STRING_PTR(view_arg) == NULL)
1665
+ if (NIL_P(view_arg) || StringValuePtr(view_arg) == NULL)
1766
1666
  {
1767
- magick_free(info->view);
1768
- info->view = NULL;
1667
+ magick_free(info->view);
1668
+ info->view = NULL;
1769
1669
  }
1770
1670
  else
1771
1671
  {
1772
- view = STRING_PTR(view_arg);
1672
+ view = StringValuePtr(view_arg);
1773
1673
  magick_clone_string(&info->view, view);
1774
1674
  }
1775
1675
  return self;
@@ -1796,38 +1696,6 @@ destroy_Info(void *infoptr)
1796
1696
  (void) DestroyImageInfo(info);
1797
1697
  }
1798
1698
 
1799
- /*
1800
- Method: Info.new
1801
- Purpose: Create an Info object by calling CloneInfo
1802
- */
1803
- #if !defined(HAVE_RB_DEFINE_ALLOC_FUNC)
1804
- VALUE
1805
- Info_new(VALUE class)
1806
- {
1807
- Info *info;
1808
- volatile VALUE new_obj;
1809
-
1810
- info = CloneImageInfo(NULL);
1811
- if (!info)
1812
- {
1813
- rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
1814
- }
1815
- new_obj = Data_Wrap_Struct(class, NULL, destroy_Info, info);
1816
- rb_obj_call_init(new_obj, 0, NULL);
1817
- return new_obj;
1818
- }
1819
-
1820
- /*
1821
- Extern: rm_info_new
1822
- Purpose: provide a Info.new method for internal use
1823
- Notes: takes no parameters, but runs the parm block if present
1824
- */
1825
- VALUE
1826
- rm_info_new()
1827
- {
1828
- return Info_new(Class_Info);
1829
- }
1830
- #else
1831
1699
 
1832
1700
  /*
1833
1701
  Extern: Info_alloc
@@ -1847,20 +1715,22 @@ Info_alloc(VALUE class)
1847
1715
  info_obj = Data_Wrap_Struct(class, NULL, destroy_Info, info);
1848
1716
  return info_obj;
1849
1717
  }
1718
+
1719
+
1850
1720
  /*
1851
1721
  Extern: rm_info_new
1852
1722
  Purpose: provide a Info.new method for internal use
1853
1723
  Notes: takes no parameters, but runs the parm block if present
1854
1724
  */
1855
1725
  VALUE
1856
- rm_info_new(void)
1726
+ rm_info_new()
1857
1727
  {
1858
1728
  volatile VALUE info_obj;
1859
1729
 
1860
1730
  info_obj = Info_alloc(Class_Info);
1861
1731
  return Info_initialize(info_obj);
1862
1732
  }
1863
- #endif
1733
+
1864
1734
 
1865
1735
  /*
1866
1736
  Method: Info#initialize
@@ -1877,59 +1747,3 @@ Info_initialize(VALUE self)
1877
1747
  return self;
1878
1748
  }
1879
1749
 
1880
-
1881
- /*
1882
- Method: Info#get_option
1883
- Purpose: Return the value of the specified option
1884
- */
1885
- static VALUE
1886
- get_option(VALUE self, char *key)
1887
- {
1888
- #if defined(HAVE_SETIMAGEOPTION)
1889
- Info *info;
1890
- const char *value;
1891
-
1892
- Data_Get_Struct(self, Info, info);
1893
-
1894
- value = GetImageOption(info, key);
1895
- if (value)
1896
- {
1897
- return rb_str_new2(value);
1898
- }
1899
- return Qnil;
1900
- #else
1901
- rm_not_implemented();
1902
- return (VALUE)0;
1903
- #endif
1904
- }
1905
-
1906
- /*
1907
- Method: Info#set_option
1908
- Purpose: Set the specified option to this value.
1909
- If the value is nil just unset any current value
1910
- */
1911
- static VALUE
1912
- set_option(VALUE self, char *key, VALUE string)
1913
- {
1914
- #if defined(HAVE_SETIMAGEOPTION)
1915
- Info *info;
1916
- char *value;
1917
-
1918
- Data_Get_Struct(self, Info, info);
1919
-
1920
- if (NIL_P(string))
1921
- {
1922
- (void) RemoveImageOption(info, key);
1923
- }
1924
- else
1925
- {
1926
- value = STRING_PTR(string);
1927
- (void) SetImageOption(info, key, value);
1928
- }
1929
- return self;
1930
- #else
1931
- rm_not_implemented();
1932
- return (VALUE)0;
1933
- #endif
1934
- }
1935
-