rmagick 2.12.2 → 2.13.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 +12 -0
- data/Doxyfile +1514 -0
- data/README.html +2 -171
- data/doc/comtasks.html +2 -2
- data/doc/constants.html +2 -2
- data/doc/draw.html +2 -2
- data/doc/ilist.html +2 -2
- data/doc/image1.html +2 -2
- data/doc/image2.html +2 -2
- data/doc/image3.html +2 -2
- data/doc/imageattrs.html +2 -2
- data/doc/imusage.html +2 -2
- data/doc/index.html +3 -3
- data/doc/info.html +2 -2
- data/doc/magick.html +2 -2
- data/doc/optequiv.html +2 -2
- data/doc/rvg.html +2 -2
- data/doc/rvgclip.html +2 -2
- data/doc/rvggroup.html +2 -2
- data/doc/rvgimage.html +2 -2
- data/doc/rvgpattern.html +2 -2
- data/doc/rvgshape.html +2 -2
- data/doc/rvgstyle.html +2 -2
- data/doc/rvgtext.html +2 -2
- data/doc/rvgtspan.html +2 -2
- data/doc/rvgtut.html +2 -2
- data/doc/rvguse.html +2 -2
- data/doc/rvgxform.html +2 -2
- data/doc/struct.html +12 -8
- data/doc/usage.html +2 -2
- data/ext/RMagick/MANIFEST +311 -309
- data/ext/RMagick/extconf.rb +27 -3
- data/ext/RMagick/rmagick.c +151 -69
- data/ext/RMagick/rmagick.h +218 -158
- data/ext/RMagick/rmdraw.c +616 -261
- data/ext/RMagick/rmenum.c +373 -179
- data/ext/RMagick/rmfill.c +166 -71
- data/ext/RMagick/rmilist.c +323 -146
- data/ext/RMagick/rmimage.c +4994 -1756
- data/ext/RMagick/rminfo.c +1004 -366
- data/ext/RMagick/rmmain.c +62 -27
- data/ext/RMagick/rmmontage.c +222 -97
- data/ext/RMagick/rmpixel.c +454 -155
- data/ext/RMagick/rmstruct.c +305 -153
- data/ext/RMagick/rmutil.c +531 -263
- data/lib/rvg/misc.rb +1 -1
- data/rmagick.gemspec +3 -3
- metadata +313 -310
data/ext/RMagick/rmutil.c
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
/**************************************************************************//**
|
2
|
+
* Utility functions for RMagick.
|
3
|
+
*
|
4
|
+
* Copyright © 2002 - 2009 by Timothy P. Hunter
|
5
|
+
*
|
6
|
+
* Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
|
7
|
+
*
|
8
|
+
* @file rmutil.c
|
9
|
+
* @version $Id: rmutil.c,v 1.182 2009/12/21 10:34:58 baror Exp $
|
10
|
+
* @author Tim Hunter
|
11
|
+
******************************************************************************/
|
8
12
|
|
9
13
|
#include "rmagick.h"
|
10
14
|
#include <errno.h>
|
@@ -12,18 +16,22 @@
|
|
12
16
|
static void handle_exception(ExceptionInfo *, Image *, ErrorRetention);
|
13
17
|
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
/**
|
20
|
+
* ImageMagick safe version of malloc.
|
21
|
+
*
|
22
|
+
* No Ruby usage (internal function)
|
23
|
+
*
|
24
|
+
* Notes:
|
25
|
+
* - Use when managing memory that ImageMagick may have allocated or may free.
|
26
|
+
* - If malloc fails, it raises an exception.
|
27
|
+
* - magick_safe_malloc and magick_safe_realloc prevent exceptions caused by
|
28
|
+
* integer overflow. Added in 6.3.5-9 but backwards compatible with prior
|
29
|
+
* releases.
|
30
|
+
*
|
31
|
+
* @param count the number of quantum elements to allocate
|
32
|
+
* @param quantum the number of bytes in each quantum
|
33
|
+
* @return a pointer to a block of memory that is at least count*quantum
|
34
|
+
*/
|
27
35
|
void *
|
28
36
|
magick_safe_malloc(const size_t count, const size_t quantum)
|
29
37
|
{
|
@@ -38,6 +46,14 @@ magick_safe_malloc(const size_t count, const size_t quantum)
|
|
38
46
|
}
|
39
47
|
|
40
48
|
|
49
|
+
/**
|
50
|
+
* ImageMagick version of malloc.
|
51
|
+
*
|
52
|
+
* No Ruby usage (internal function)
|
53
|
+
*
|
54
|
+
* @param size the size of memory to allocate
|
55
|
+
* @return pointer to a block of memory
|
56
|
+
*/
|
41
57
|
void *
|
42
58
|
magick_malloc(const size_t size)
|
43
59
|
{
|
@@ -52,6 +68,13 @@ magick_malloc(const size_t size)
|
|
52
68
|
}
|
53
69
|
|
54
70
|
|
71
|
+
/**
|
72
|
+
* ImageMagick version of free.
|
73
|
+
*
|
74
|
+
* No Ruby usage (internal function)
|
75
|
+
*
|
76
|
+
* @param ptr pointer to the existing block of memory
|
77
|
+
*/
|
55
78
|
void
|
56
79
|
magick_free(void *ptr)
|
57
80
|
{
|
@@ -59,6 +82,23 @@ magick_free(void *ptr)
|
|
59
82
|
}
|
60
83
|
|
61
84
|
|
85
|
+
/**
|
86
|
+
* ImageMagick safe version of realloc.
|
87
|
+
*
|
88
|
+
* No Ruby usage (internal function)
|
89
|
+
*
|
90
|
+
* Notes:
|
91
|
+
* - Use when managing memory that ImageMagick may have allocated or may free.
|
92
|
+
* - If malloc fails, it raises an exception.
|
93
|
+
* - magick_safe_malloc and magick_safe_realloc prevent exceptions caused by
|
94
|
+
* integer overflow. Added in 6.3.5-9 but backwards compatible with prior
|
95
|
+
* releases.
|
96
|
+
*
|
97
|
+
* @param memory the existing block of memory
|
98
|
+
* @param count the number of quantum elements to allocate
|
99
|
+
* @param quantum the number of bytes in each quantum
|
100
|
+
* @return a pointer to a block of memory that is at least count*quantum in size
|
101
|
+
*/
|
62
102
|
void *
|
63
103
|
magick_safe_realloc(void *memory, const size_t count, const size_t quantum)
|
64
104
|
{
|
@@ -72,6 +112,15 @@ magick_safe_realloc(void *memory, const size_t count, const size_t quantum)
|
|
72
112
|
}
|
73
113
|
|
74
114
|
|
115
|
+
/**
|
116
|
+
* ImageMagick version of realloc.
|
117
|
+
*
|
118
|
+
* No Ruby usage (internal function)
|
119
|
+
*
|
120
|
+
* @param ptr pointer to the existing block of memory
|
121
|
+
* @param size the new size of memory to allocate
|
122
|
+
* @return pointer to a block of memory
|
123
|
+
*/
|
75
124
|
void *
|
76
125
|
magick_realloc(void *ptr, const size_t size)
|
77
126
|
{
|
@@ -85,14 +134,18 @@ magick_realloc(void *ptr, const size_t size)
|
|
85
134
|
}
|
86
135
|
|
87
136
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
137
|
+
/**
|
138
|
+
* Make a copy of a string in malloc'd memory.
|
139
|
+
*
|
140
|
+
* No Ruby usage (internal function)
|
141
|
+
*
|
142
|
+
* Notes:
|
143
|
+
* - Any existing string pointed to by *new_str is freed.
|
144
|
+
* - CloneString asserts if no memory. No need to check its return value.
|
145
|
+
*
|
146
|
+
* @param new_str pointer to the new string
|
147
|
+
* @param str the string to copy
|
148
|
+
*/
|
96
149
|
void
|
97
150
|
magick_clone_string(char **new_str, const char *str)
|
98
151
|
{
|
@@ -100,11 +153,15 @@ void
|
|
100
153
|
}
|
101
154
|
|
102
155
|
|
103
|
-
|
104
|
-
*
|
105
|
-
*
|
106
|
-
*
|
107
|
-
|
156
|
+
/**
|
157
|
+
* Compare s1 and s2 ignoring case.
|
158
|
+
*
|
159
|
+
* No Ruby usage (internal function)
|
160
|
+
*
|
161
|
+
* @param s1 the first string
|
162
|
+
* @param s2 the second string
|
163
|
+
* @return same as strcmp(3)
|
164
|
+
*/
|
108
165
|
int
|
109
166
|
rm_strcasecmp(const char *s1, const char *s2)
|
110
167
|
{
|
@@ -121,11 +178,16 @@ rm_strcasecmp(const char *s1, const char *s2)
|
|
121
178
|
}
|
122
179
|
|
123
180
|
|
124
|
-
|
125
|
-
*
|
126
|
-
*
|
127
|
-
*
|
128
|
-
|
181
|
+
/**
|
182
|
+
* Compare s1 and s2 ignoring case.
|
183
|
+
*
|
184
|
+
* No Ruby usage (internal function)
|
185
|
+
*
|
186
|
+
* @param s1 the first string
|
187
|
+
* @param s2 the second string
|
188
|
+
* @param n number of characters to compare
|
189
|
+
* @return same as strcmp(3)
|
190
|
+
*/
|
129
191
|
int
|
130
192
|
rm_strncasecmp(const char *s1, const char *s2, size_t n)
|
131
193
|
{
|
@@ -146,10 +208,15 @@ rm_strncasecmp(const char *s1, const char *s2, size_t n)
|
|
146
208
|
}
|
147
209
|
|
148
210
|
|
149
|
-
|
150
|
-
*
|
151
|
-
*
|
152
|
-
|
211
|
+
/**
|
212
|
+
* Raise exception if array too short.
|
213
|
+
*
|
214
|
+
* No Ruby usage (internal function)
|
215
|
+
*
|
216
|
+
* @param ary the array
|
217
|
+
* @param len the minimum length
|
218
|
+
* @throw IndexError
|
219
|
+
*/
|
153
220
|
void
|
154
221
|
rm_check_ary_len(VALUE ary, long len)
|
155
222
|
{
|
@@ -161,10 +228,15 @@ rm_check_ary_len(VALUE ary, long len)
|
|
161
228
|
}
|
162
229
|
|
163
230
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
231
|
+
/**
|
232
|
+
* Raise an error if the image has been destroyed.
|
233
|
+
*
|
234
|
+
* No Ruby usage (internal function)
|
235
|
+
*
|
236
|
+
* @param obj the image
|
237
|
+
* @return the C image structure for the image
|
238
|
+
* @throw DestroyedImageError
|
239
|
+
*/
|
168
240
|
Image *
|
169
241
|
rm_check_destroyed(VALUE obj)
|
170
242
|
{
|
@@ -180,10 +252,14 @@ rm_check_destroyed(VALUE obj)
|
|
180
252
|
}
|
181
253
|
|
182
254
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
255
|
+
/**
|
256
|
+
* Raise an error if the image has been destroyed or is frozen.
|
257
|
+
*
|
258
|
+
* No Ruby usage (internal function)
|
259
|
+
*
|
260
|
+
* @param obj the image
|
261
|
+
* @return the C image structure for the image
|
262
|
+
*/
|
187
263
|
Image *
|
188
264
|
rm_check_frozen(VALUE obj)
|
189
265
|
{
|
@@ -193,10 +269,15 @@ rm_check_frozen(VALUE obj)
|
|
193
269
|
}
|
194
270
|
|
195
271
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
272
|
+
/**
|
273
|
+
* Overrides freeze in classes that can't be frozen.
|
274
|
+
*
|
275
|
+
* No Ruby usage (internal function)
|
276
|
+
*
|
277
|
+
* @param obj the object of the class to override
|
278
|
+
* @return 0
|
279
|
+
* @throw TypeError
|
280
|
+
*/
|
200
281
|
VALUE
|
201
282
|
rm_no_freeze(VALUE obj)
|
202
283
|
{
|
@@ -205,10 +286,14 @@ rm_no_freeze(VALUE obj)
|
|
205
286
|
}
|
206
287
|
|
207
288
|
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
289
|
+
/**
|
290
|
+
* Return obj.to_s, or obj if obj is already a string.
|
291
|
+
*
|
292
|
+
* No Ruby usage (internal function)
|
293
|
+
*
|
294
|
+
* @param obj a Ruby object
|
295
|
+
* @return a String representation of obj
|
296
|
+
*/
|
212
297
|
VALUE
|
213
298
|
rm_to_s(VALUE obj)
|
214
299
|
{
|
@@ -221,10 +306,15 @@ rm_to_s(VALUE obj)
|
|
221
306
|
}
|
222
307
|
|
223
308
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
309
|
+
/**
|
310
|
+
* Supply our own version of the "obsolete" rb_str2cstr.
|
311
|
+
*
|
312
|
+
* No Ruby usage (internal function)
|
313
|
+
*
|
314
|
+
* @param str the Ruby string
|
315
|
+
* @param len pointer to a long in which to store the number of characters
|
316
|
+
* @return a C string version of str
|
317
|
+
*/
|
228
318
|
char *
|
229
319
|
rm_str2cstr(VALUE str, long *len)
|
230
320
|
{
|
@@ -237,11 +327,14 @@ rm_str2cstr(VALUE str, long *len)
|
|
237
327
|
}
|
238
328
|
|
239
329
|
|
240
|
-
|
241
|
-
*
|
242
|
-
*
|
243
|
-
*
|
244
|
-
|
330
|
+
/**
|
331
|
+
* Try to convert the argument to a double, raise an exception if fail.
|
332
|
+
*
|
333
|
+
* No Ruby usage (internal function)
|
334
|
+
*
|
335
|
+
* @param arg the argument
|
336
|
+
* @return arg
|
337
|
+
*/
|
245
338
|
static VALUE
|
246
339
|
arg_is_number(VALUE arg)
|
247
340
|
{
|
@@ -252,10 +345,15 @@ arg_is_number(VALUE arg)
|
|
252
345
|
}
|
253
346
|
|
254
347
|
|
255
|
-
|
256
|
-
*
|
257
|
-
*
|
258
|
-
|
348
|
+
/**
|
349
|
+
* Called when `rb_str_to_str' raises an exception.
|
350
|
+
*
|
351
|
+
* No Ruby usage (internal function)
|
352
|
+
*
|
353
|
+
* @param arg the argument
|
354
|
+
* @return 0
|
355
|
+
* @throw TypeError
|
356
|
+
*/
|
259
357
|
static VALUE
|
260
358
|
rescue_not_str(VALUE arg)
|
261
359
|
{
|
@@ -265,15 +363,19 @@ rescue_not_str(VALUE arg)
|
|
265
363
|
}
|
266
364
|
|
267
365
|
|
268
|
-
|
269
|
-
*
|
270
|
-
*
|
271
|
-
*
|
272
|
-
*
|
273
|
-
*
|
274
|
-
|
366
|
+
/**
|
367
|
+
* Return a double between 0.0 and max (the second argument), inclusive. If the
|
368
|
+
* argument is a number convert to a Float object, otherwise it's supposed to be
|
369
|
+
* a string in the form * "NN%". Convert to a number and then to a Float.
|
370
|
+
*
|
371
|
+
* No Ruby usage (internal function)
|
372
|
+
*
|
373
|
+
* @param arg the argument
|
374
|
+
* @param max the maximum allowed value
|
375
|
+
* @return a double
|
376
|
+
*/
|
275
377
|
double
|
276
|
-
rm_percentage(VALUE arg)
|
378
|
+
rm_percentage(VALUE arg, double max)
|
277
379
|
{
|
278
380
|
double pct;
|
279
381
|
long pct_long;
|
@@ -300,7 +402,7 @@ rm_percentage(VALUE arg)
|
|
300
402
|
|
301
403
|
if (*end == '%' && pct_long != 0)
|
302
404
|
{
|
303
|
-
pct = ((double)pct_long) / 100.0;
|
405
|
+
pct = (((double)pct_long) / 100.0) * max;
|
304
406
|
}
|
305
407
|
else
|
306
408
|
{
|
@@ -324,9 +426,13 @@ rm_percentage(VALUE arg)
|
|
324
426
|
}
|
325
427
|
|
326
428
|
|
327
|
-
|
328
|
-
|
329
|
-
|
429
|
+
/**
|
430
|
+
* Return 0 if rb_num2dbl doesn't raise an exception.
|
431
|
+
*
|
432
|
+
* No Ruby usage (internal function)
|
433
|
+
*
|
434
|
+
* @param obj the object to convert to a double
|
435
|
+
* @return 0
|
330
436
|
*/
|
331
437
|
static VALUE
|
332
438
|
check_num2dbl(VALUE obj)
|
@@ -336,9 +442,13 @@ check_num2dbl(VALUE obj)
|
|
336
442
|
}
|
337
443
|
|
338
444
|
|
339
|
-
|
340
|
-
|
341
|
-
|
445
|
+
/**
|
446
|
+
* Called if rb_num2dbl raises an exception.
|
447
|
+
*
|
448
|
+
* No Ruby usage (internal function)
|
449
|
+
*
|
450
|
+
* @param ignored a Ruby object (unused)
|
451
|
+
* @return 0
|
342
452
|
*/
|
343
453
|
static VALUE
|
344
454
|
rescue_not_dbl(VALUE ignored)
|
@@ -348,10 +458,14 @@ rescue_not_dbl(VALUE ignored)
|
|
348
458
|
}
|
349
459
|
|
350
460
|
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
461
|
+
/**
|
462
|
+
* Return 1 if the object can be converted to a double, 0 otherwise.
|
463
|
+
*
|
464
|
+
* No Ruby usage (internal function)
|
465
|
+
*
|
466
|
+
* @param obj the object
|
467
|
+
* @return 1 or 0
|
468
|
+
*/
|
355
469
|
int
|
356
470
|
rm_check_num2dbl(VALUE obj)
|
357
471
|
{
|
@@ -359,11 +473,14 @@ rm_check_num2dbl(VALUE obj)
|
|
359
473
|
}
|
360
474
|
|
361
475
|
|
362
|
-
|
363
|
-
*
|
364
|
-
*
|
476
|
+
/**
|
477
|
+
* Given a string in the form NN% return the corresponding double.
|
478
|
+
*
|
479
|
+
* No Ruby usage (internal function)
|
365
480
|
*
|
366
|
-
|
481
|
+
* @param str the string
|
482
|
+
* @return a double
|
483
|
+
*/
|
367
484
|
double
|
368
485
|
rm_str_to_pct(VALUE str)
|
369
486
|
{
|
@@ -392,13 +509,17 @@ rm_str_to_pct(VALUE str)
|
|
392
509
|
}
|
393
510
|
|
394
511
|
|
395
|
-
|
396
|
-
*
|
397
|
-
*
|
398
|
-
*
|
399
|
-
*
|
400
|
-
*
|
401
|
-
|
512
|
+
/**
|
513
|
+
* If the argument is a number, convert it to a double. Otherwise it's supposed
|
514
|
+
* to be a string in the form 'NN%'. Return a percentage of QuantumRange.
|
515
|
+
*
|
516
|
+
* No Ruby usage (internal function)
|
517
|
+
*
|
518
|
+
* @param fuzz_arg the fuzz argument
|
519
|
+
* @return a double
|
520
|
+
* @see Image_fuzz
|
521
|
+
* @see Image_fuzz_eq
|
522
|
+
*/
|
402
523
|
double
|
403
524
|
rm_fuzz_to_dbl(VALUE fuzz_arg)
|
404
525
|
{
|
@@ -446,15 +567,21 @@ rm_fuzz_to_dbl(VALUE fuzz_arg)
|
|
446
567
|
}
|
447
568
|
|
448
569
|
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
570
|
+
/**
|
571
|
+
* Convert a application-supplied number to a Quantum. If the object is a Float,
|
572
|
+
* truncate it before converting.
|
573
|
+
*
|
574
|
+
* No Ruby usage (internal function)
|
575
|
+
*
|
576
|
+
* Notes:
|
577
|
+
* - Ruby says that 2147483647.5 doesn't fit into an unsigned long. If you
|
578
|
+
* truncate it, it works.
|
579
|
+
* - Should use this only when the input value is possibly subject to this
|
580
|
+
* problem.
|
581
|
+
*
|
582
|
+
* @param obj the application-supplied number
|
583
|
+
* @return a Quantum
|
584
|
+
*/
|
458
585
|
Quantum
|
459
586
|
rm_app2quantum(VALUE obj)
|
460
587
|
{
|
@@ -469,14 +596,16 @@ rm_app2quantum(VALUE obj)
|
|
469
596
|
}
|
470
597
|
|
471
598
|
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
599
|
+
/**
|
600
|
+
* Send the "cur_image" method to the object. If 'img' is an ImageList, then
|
601
|
+
* cur_image is self[\@scene]. If 'img' is an image, then cur_image is simply
|
602
|
+
* 'self'.
|
603
|
+
*
|
604
|
+
* No Ruby usage (internal function)
|
605
|
+
*
|
606
|
+
* @param img the object
|
607
|
+
* @return the return value from "cur_image"
|
608
|
+
*/
|
480
609
|
VALUE
|
481
610
|
rm_cur_image(VALUE img)
|
482
611
|
{
|
@@ -484,13 +613,16 @@ rm_cur_image(VALUE img)
|
|
484
613
|
}
|
485
614
|
|
486
615
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
616
|
+
/**
|
617
|
+
* Map the color intensity to a named color.
|
618
|
+
*
|
619
|
+
* No Ruby usage (internal function)
|
620
|
+
*
|
621
|
+
* @param image the image
|
622
|
+
* @param color the color intensity as a PixelPacket
|
623
|
+
* @return the named color as a String
|
624
|
+
* @see rm_pixelpacket_to_color_name_info
|
625
|
+
*/
|
494
626
|
VALUE
|
495
627
|
rm_pixelpacket_to_color_name(Image *image, PixelPacket *color)
|
496
628
|
{
|
@@ -507,18 +639,23 @@ rm_pixelpacket_to_color_name(Image *image, PixelPacket *color)
|
|
507
639
|
}
|
508
640
|
|
509
641
|
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
642
|
+
/**
|
643
|
+
* Map the color intensity to a named color.
|
644
|
+
*
|
645
|
+
* No Ruby usage (internal function)
|
646
|
+
*
|
647
|
+
* Notes:
|
648
|
+
* - Simply create an Image from the Info, call QueryColorname, and then
|
649
|
+
* destroy the Image.
|
650
|
+
* - If the Info structure is NULL, creates a new one.
|
651
|
+
* - The default depth is always used, and the matte value is set to False,
|
652
|
+
* which means "don't use the alpha channel".
|
653
|
+
*
|
654
|
+
* @param info the info
|
655
|
+
* @param color the color intensity as a PixelPacket
|
656
|
+
* @return the named color as a String
|
657
|
+
* @see rm_pixelpacket_to_color_name
|
658
|
+
*/
|
522
659
|
VALUE
|
523
660
|
rm_pixelpacket_to_color_name_info(Info *info, PixelPacket *color)
|
524
661
|
{
|
@@ -541,13 +678,19 @@ rm_pixelpacket_to_color_name_info(Info *info, PixelPacket *color)
|
|
541
678
|
}
|
542
679
|
|
543
680
|
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
681
|
+
/**
|
682
|
+
* Write a temporary copy of the image to the IM registry.
|
683
|
+
*
|
684
|
+
* No Ruby usage (internal function)
|
685
|
+
*
|
686
|
+
* Notes:
|
687
|
+
* - The `temp_name' argument must point to an char array of size
|
688
|
+
* MaxTextExtent.
|
689
|
+
*
|
690
|
+
* @param image the image
|
691
|
+
* @param temp_name the temporary name to use
|
692
|
+
* @return the "filename" of the registered image
|
693
|
+
*/
|
551
694
|
void
|
552
695
|
rm_write_temp_image(Image *image, char *temp_name)
|
553
696
|
{
|
@@ -590,12 +733,13 @@ rm_write_temp_image(Image *image, char *temp_name)
|
|
590
733
|
}
|
591
734
|
|
592
735
|
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
736
|
+
/**
|
737
|
+
* Delete the temporary image from the registry.
|
738
|
+
*
|
739
|
+
* No Ruby usage (internal function)
|
740
|
+
*
|
741
|
+
* @param temp_name the name of temporary image in the registry.
|
742
|
+
*/
|
599
743
|
void
|
600
744
|
rm_delete_temp_image(char *temp_name)
|
601
745
|
{
|
@@ -608,12 +752,17 @@ rm_delete_temp_image(char *temp_name)
|
|
608
752
|
}
|
609
753
|
|
610
754
|
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
755
|
+
/**
|
756
|
+
* Raise NotImplementedError.
|
757
|
+
*
|
758
|
+
* No Ruby usage (internal function)
|
759
|
+
*
|
760
|
+
* Notes:
|
761
|
+
* - Called when a xMagick API is not available.
|
762
|
+
* - Replaces Ruby's rb_notimplement function.
|
763
|
+
*
|
764
|
+
* @throw NotImpError
|
765
|
+
*/
|
617
766
|
void
|
618
767
|
rm_not_implemented(void)
|
619
768
|
{
|
@@ -623,14 +772,20 @@ rm_not_implemented(void)
|
|
623
772
|
}
|
624
773
|
|
625
774
|
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
775
|
+
/**
|
776
|
+
* Create a new ImageMagickError object and raise an exception.
|
777
|
+
*
|
778
|
+
* No Ruby usage (internal function)
|
779
|
+
*
|
780
|
+
* Notes:
|
781
|
+
* - This funky technique allows me to safely add additional information to
|
782
|
+
* the ImageMagickError object in both 1.6.8 and 1.8.0.
|
783
|
+
*
|
784
|
+
* @param msg the error mesage
|
785
|
+
* @param loc the location of the error
|
786
|
+
* @throw ImageMagickError
|
787
|
+
* @see www.ruby_talk.org/36408.
|
788
|
+
*/
|
634
789
|
void
|
635
790
|
rm_magick_error(const char *msg, const char *loc)
|
636
791
|
{
|
@@ -644,11 +799,22 @@ rm_magick_error(const char *msg, const char *loc)
|
|
644
799
|
}
|
645
800
|
|
646
801
|
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
802
|
+
/**
|
803
|
+
* Initialize a new ImageMagickError object - store the "loc" string in the
|
804
|
+
* \@magick_location instance variable.
|
805
|
+
*
|
806
|
+
* Ruby usage:
|
807
|
+
* - @verbatim ImageMagickError#initialize(msg) @endverbatim
|
808
|
+
* - @verbatim ImageMagickError#initialize(msg, loc) @endverbatim
|
809
|
+
*
|
810
|
+
* Notes:
|
811
|
+
* - Default loc is nil
|
812
|
+
*
|
813
|
+
* @param argc number of input arguments
|
814
|
+
* @param argv array of input arguments
|
815
|
+
* @param self this object
|
816
|
+
* @return self
|
817
|
+
*/
|
652
818
|
VALUE
|
653
819
|
ImageMagickError_initialize(int argc, VALUE *argv, VALUE self)
|
654
820
|
{
|
@@ -677,10 +843,15 @@ ImageMagickError_initialize(int argc, VALUE *argv, VALUE self)
|
|
677
843
|
}
|
678
844
|
|
679
845
|
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
846
|
+
/**
|
847
|
+
* Backport GetImageProperty for pre-6.3.1 versions of ImageMagick.
|
848
|
+
*
|
849
|
+
* No Ruby usage (internal function)
|
850
|
+
*
|
851
|
+
* @param img the image
|
852
|
+
* @param property the property name
|
853
|
+
* @return the property value
|
854
|
+
*/
|
684
855
|
const char *
|
685
856
|
rm_get_property(const Image *img, const char *property)
|
686
857
|
{
|
@@ -688,10 +859,16 @@ rm_get_property(const Image *img, const char *property)
|
|
688
859
|
}
|
689
860
|
|
690
861
|
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
862
|
+
/**
|
863
|
+
* Backport SetImageProperty for pre-6.3.1 versions of ImageMagick.
|
864
|
+
*
|
865
|
+
* No Ruby usage (internal function)
|
866
|
+
*
|
867
|
+
* @param image the image
|
868
|
+
* @param property the property name
|
869
|
+
* @param value the property value
|
870
|
+
* @return true if successful, otherwise false
|
871
|
+
*/
|
695
872
|
MagickBooleanType
|
696
873
|
rm_set_property(Image *image, const char *property, const char *value)
|
697
874
|
{
|
@@ -699,11 +876,15 @@ rm_set_property(Image *image, const char *property, const char *value)
|
|
699
876
|
}
|
700
877
|
|
701
878
|
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
879
|
+
/**
|
880
|
+
* If a "user" option is present in the Info, assign its value to a "user"
|
881
|
+
* artifact in each image.
|
882
|
+
*
|
883
|
+
* No Ruby usage (internal function)
|
884
|
+
*
|
885
|
+
* @param images a list of images
|
886
|
+
* @param info the info
|
887
|
+
*/
|
707
888
|
void rm_set_user_artifact(Image *images, Info *info)
|
708
889
|
{
|
709
890
|
#if defined(HAVE_SETIMAGEARTIFACT)
|
@@ -727,12 +908,17 @@ void rm_set_user_artifact(Image *images, Info *info)
|
|
727
908
|
}
|
728
909
|
|
729
910
|
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
911
|
+
/**
|
912
|
+
* Collect optional method arguments via Magick::OptionalMethodArguments.
|
913
|
+
*
|
914
|
+
* No Ruby usage (internal function)
|
915
|
+
*
|
916
|
+
* Notes:
|
917
|
+
* - Creates an instance of Magick::OptionalMethodArguments, then yields to a
|
918
|
+
* block in the context of the instance.
|
919
|
+
*
|
920
|
+
* @param img the image
|
921
|
+
*/
|
736
922
|
void
|
737
923
|
rm_get_optional_arguments(VALUE img)
|
738
924
|
{
|
@@ -754,11 +940,15 @@ rm_get_optional_arguments(VALUE img)
|
|
754
940
|
}
|
755
941
|
|
756
942
|
|
757
|
-
/*
|
758
|
-
Static: copy_options
|
759
|
-
Purpose: copy image options from the Info structure to the Image structure
|
760
|
-
*/
|
761
943
|
#if defined(HAVE_SETIMAGEARTIFACT)
|
944
|
+
/**
|
945
|
+
* Copy image options from the Info structure to the Image structure.
|
946
|
+
*
|
947
|
+
* No Ruby usage (internal function)
|
948
|
+
*
|
949
|
+
* @param image the Image structure to modify
|
950
|
+
* @param info the Info structure
|
951
|
+
*/
|
762
952
|
static void copy_options(Image *image, Info *info)
|
763
953
|
{
|
764
954
|
char property[MaxTextExtent];
|
@@ -779,11 +969,15 @@ static void copy_options(Image *image, Info *info)
|
|
779
969
|
#endif
|
780
970
|
|
781
971
|
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
972
|
+
/**
|
973
|
+
* Propagate ImageInfo values to the Image
|
974
|
+
*
|
975
|
+
* No Ruby usage (internal function)
|
976
|
+
*
|
977
|
+
* @param image the Image structure to modify
|
978
|
+
* @param info the Info structure
|
979
|
+
* @see SyncImageSettings in mogrify.c in ImageMagick
|
980
|
+
*/
|
787
981
|
void rm_sync_image_options(Image *image, Info *info)
|
788
982
|
{
|
789
983
|
MagickStatusType flags;
|
@@ -947,14 +1141,18 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
947
1141
|
}
|
948
1142
|
|
949
1143
|
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
1144
|
+
/**
|
1145
|
+
* Replicate old (ImageMagick < 6.3.2) EXIF:* functionality using
|
1146
|
+
* GetImageProperty by returning the exif entries as a single string, separated
|
1147
|
+
* by \n's. Do this so that RMagick.rb works no matter which version of
|
1148
|
+
* ImageMagick is in use.
|
1149
|
+
*
|
1150
|
+
* No Ruby usage (internal function)
|
1151
|
+
*
|
1152
|
+
* @param image the image
|
1153
|
+
* @return string representation of exif properties
|
1154
|
+
* @see magick/identify.c in ImageMagick
|
1155
|
+
*/
|
958
1156
|
VALUE
|
959
1157
|
rm_exif_by_entry(Image *image)
|
960
1158
|
{
|
@@ -1029,14 +1227,18 @@ rm_exif_by_entry(Image *image)
|
|
1029
1227
|
}
|
1030
1228
|
|
1031
1229
|
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1230
|
+
/**
|
1231
|
+
* Replicate old (ImageMagick < 6.3.2) EXIF:! functionality using
|
1232
|
+
* GetImageProperty by returning the exif entries as a single string, separated
|
1233
|
+
* by \n's. Do this so that RMagick.rb works no matter which version of
|
1234
|
+
* ImageMagick is in use.
|
1235
|
+
*
|
1236
|
+
* No Ruby usage (internal function)
|
1237
|
+
*
|
1238
|
+
* @param image the image
|
1239
|
+
* @return string representation of exif properties
|
1240
|
+
* @see magick/identify.c in ImageMagick
|
1241
|
+
*/
|
1040
1242
|
VALUE
|
1041
1243
|
rm_exif_by_number(Image *image)
|
1042
1244
|
{
|
@@ -1111,11 +1313,21 @@ rm_exif_by_number(Image *image)
|
|
1111
1313
|
}
|
1112
1314
|
|
1113
1315
|
|
1114
|
-
|
1115
|
-
*
|
1116
|
-
*
|
1117
|
-
*
|
1118
|
-
|
1316
|
+
/**
|
1317
|
+
* Get the values from a Geometry object and return them in C variables.
|
1318
|
+
*
|
1319
|
+
* No Ruby usage (internal function)
|
1320
|
+
*
|
1321
|
+
* Notes:
|
1322
|
+
* - No return value: modifies x, y, width, height, and flag
|
1323
|
+
*
|
1324
|
+
* @param geom the Geometry object
|
1325
|
+
* @param x pointer to the x position of the start of the rectangle
|
1326
|
+
* @param y pointer to the y position of the start of the rectangle
|
1327
|
+
* @param width pointer to the width of the rectangle
|
1328
|
+
* @param height pointer to the height of the rectangle
|
1329
|
+
* @param flag pointer to the Geometry's flag
|
1330
|
+
*/
|
1119
1331
|
void
|
1120
1332
|
rm_get_geometry(
|
1121
1333
|
VALUE geom,
|
@@ -1161,11 +1373,17 @@ rm_get_geometry(
|
|
1161
1373
|
}
|
1162
1374
|
|
1163
1375
|
|
1164
|
-
|
1165
|
-
*
|
1166
|
-
*
|
1167
|
-
*
|
1168
|
-
*
|
1376
|
+
/**
|
1377
|
+
* Clone an image, handle errors.
|
1378
|
+
*
|
1379
|
+
* No Ruby usage (internal function)
|
1380
|
+
*
|
1381
|
+
* Notes:
|
1382
|
+
* - Don't trace creation - the clone may not be used as an Image object. Let
|
1383
|
+
* the caller do the trace if desired.
|
1384
|
+
*
|
1385
|
+
* @param image the image to clone
|
1386
|
+
* @return the cloned image
|
1169
1387
|
*/
|
1170
1388
|
Image *
|
1171
1389
|
rm_clone_image(Image *image)
|
@@ -1186,11 +1404,21 @@ rm_clone_image(Image *image)
|
|
1186
1404
|
}
|
1187
1405
|
|
1188
1406
|
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1407
|
+
/**
|
1408
|
+
* SetImage(Info)ProgressMonitor exit.
|
1409
|
+
*
|
1410
|
+
* No Ruby usage (internal function)
|
1411
|
+
*
|
1412
|
+
* Notes:
|
1413
|
+
* - ImageMagick's "tag" argument is unused. We pass along the method name
|
1414
|
+
* instead.
|
1415
|
+
*
|
1416
|
+
* @param tag ImageMagick argument (unused)
|
1417
|
+
* @param of the offset type
|
1418
|
+
* @param sp the size type
|
1419
|
+
* @param client_data pointer to the progress method to call
|
1420
|
+
* @return true if calling client_data returns a non-nil value, otherwise false
|
1421
|
+
*/
|
1194
1422
|
MagickBooleanType
|
1195
1423
|
rm_progress_monitor(
|
1196
1424
|
const char *tag,
|
@@ -1219,12 +1447,16 @@ rm_progress_monitor(
|
|
1219
1447
|
}
|
1220
1448
|
|
1221
1449
|
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1450
|
+
/**
|
1451
|
+
* Remove the ImageMagick links between images in an scene sequence.
|
1452
|
+
*
|
1453
|
+
* No Ruby usage (internal function)
|
1454
|
+
*
|
1455
|
+
* Notes:
|
1456
|
+
* - The images remain grouped via the ImageList
|
1457
|
+
*
|
1458
|
+
* @param image the image
|
1459
|
+
*/
|
1228
1460
|
void
|
1229
1461
|
rm_split(Image *image)
|
1230
1462
|
{
|
@@ -1240,11 +1472,16 @@ rm_split(Image *image)
|
|
1240
1472
|
}
|
1241
1473
|
|
1242
1474
|
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1475
|
+
/**
|
1476
|
+
* If an ExceptionInfo struct in a list of images indicates a warning, issue a
|
1477
|
+
* warning message. If an ExceptionInfo struct indicates an error, raise an
|
1478
|
+
* exception and optionally destroy the images.
|
1479
|
+
*
|
1480
|
+
* No Ruby usage (internal function)
|
1481
|
+
*
|
1482
|
+
* @param imglist the list of images
|
1483
|
+
* @param retention retention strategy in case of an error (either RetainOnError
|
1484
|
+
* or DestroyOnError)
|
1248
1485
|
*/
|
1249
1486
|
void
|
1250
1487
|
rm_check_image_exception(Image *imglist, ErrorRetention retention)
|
@@ -1286,9 +1523,15 @@ rm_check_image_exception(Image *imglist, ErrorRetention retention)
|
|
1286
1523
|
}
|
1287
1524
|
|
1288
1525
|
|
1289
|
-
|
1290
|
-
*
|
1291
|
-
*
|
1526
|
+
/**
|
1527
|
+
* Call handle_exception if there is an exception to handle.
|
1528
|
+
*
|
1529
|
+
* No Ruby usage (internal function)
|
1530
|
+
*
|
1531
|
+
* @param exception information about the exception
|
1532
|
+
* @param imglist the images that caused the exception
|
1533
|
+
* @param retention retention strategy in case of an error (either RetainOnError
|
1534
|
+
* or DestroyOnError)
|
1292
1535
|
*/
|
1293
1536
|
void
|
1294
1537
|
rm_check_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention retention)
|
@@ -1303,10 +1546,15 @@ rm_check_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention rete
|
|
1303
1546
|
|
1304
1547
|
|
1305
1548
|
|
1306
|
-
|
1307
|
-
*
|
1308
|
-
*
|
1309
|
-
|
1549
|
+
/**
|
1550
|
+
* Called from ImageMagick for a warning.
|
1551
|
+
*
|
1552
|
+
* No Ruby usage (internal function)
|
1553
|
+
*
|
1554
|
+
* @param severity information about the severity of the warning (ignored)
|
1555
|
+
* @param reason the reason for the warning
|
1556
|
+
* @param description description of the warning
|
1557
|
+
*/
|
1310
1558
|
void
|
1311
1559
|
rm_warning_handler(const ExceptionType severity, const char *reason, const char *description)
|
1312
1560
|
{
|
@@ -1318,10 +1566,15 @@ rm_warning_handler(const ExceptionType severity, const char *reason, const char
|
|
1318
1566
|
}
|
1319
1567
|
|
1320
1568
|
|
1321
|
-
|
1322
|
-
*
|
1323
|
-
*
|
1324
|
-
|
1569
|
+
/**
|
1570
|
+
* Called from ImageMagick for a error.
|
1571
|
+
*
|
1572
|
+
* No Ruby usage (internal function)
|
1573
|
+
*
|
1574
|
+
* @param severity information about the severity of the error (ignored)
|
1575
|
+
* @param reason the reason for the error
|
1576
|
+
* @param description description of the error
|
1577
|
+
*/
|
1325
1578
|
void
|
1326
1579
|
rm_error_handler(const ExceptionType severity, const char *reason, const char *description)
|
1327
1580
|
{
|
@@ -1343,10 +1596,16 @@ rm_error_handler(const ExceptionType severity, const char *reason, const char *d
|
|
1343
1596
|
}
|
1344
1597
|
|
1345
1598
|
|
1346
|
-
|
1347
|
-
*
|
1348
|
-
*
|
1349
|
-
|
1599
|
+
/**
|
1600
|
+
* Called from ImageMagick for a fatal error.
|
1601
|
+
*
|
1602
|
+
* No Ruby usage (internal function)
|
1603
|
+
*
|
1604
|
+
* @param severity information about the severity of the error
|
1605
|
+
* @param reason the reason for the error
|
1606
|
+
* @param description description of the error (ignored)
|
1607
|
+
* @throw FatalImageMagickError
|
1608
|
+
*/
|
1350
1609
|
void
|
1351
1610
|
rm_fatal_error_handler(const ExceptionType severity, const char *reason, const char *description)
|
1352
1611
|
{
|
@@ -1355,13 +1614,18 @@ rm_fatal_error_handler(const ExceptionType severity, const char *reason, const c
|
|
1355
1614
|
}
|
1356
1615
|
|
1357
1616
|
|
1358
|
-
|
1359
|
-
*
|
1360
|
-
*
|
1361
|
-
*
|
1362
|
-
*
|
1363
|
-
*
|
1364
|
-
|
1617
|
+
/**
|
1618
|
+
* Called when rm_check_exception determines that we need to either issue a
|
1619
|
+
* warning message or raise an exception. This function allocates a bunch of
|
1620
|
+
* stack so we don't call it unless we have to.
|
1621
|
+
*
|
1622
|
+
* No Ruby usage (internal function)
|
1623
|
+
*
|
1624
|
+
* @param exception information about the exception
|
1625
|
+
* @param imglist the images that caused the exception
|
1626
|
+
* @param retention retention strategy in case of an error (either RetainOnError
|
1627
|
+
* or DestroyOnError)
|
1628
|
+
*/
|
1365
1629
|
static void
|
1366
1630
|
handle_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention retention)
|
1367
1631
|
{
|
@@ -1447,9 +1711,13 @@ handle_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention retent
|
|
1447
1711
|
}
|
1448
1712
|
|
1449
1713
|
|
1450
|
-
|
1451
|
-
*
|
1452
|
-
*
|
1714
|
+
/**
|
1715
|
+
* RMagick expected a result. If it got NULL instead raise an exception.
|
1716
|
+
*
|
1717
|
+
* No Ruby usage (internal function)
|
1718
|
+
*
|
1719
|
+
* @param image the expected result
|
1720
|
+
* @throw RuntimeError
|
1453
1721
|
*/
|
1454
1722
|
void
|
1455
1723
|
rm_ensure_result(Image *image)
|