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.

@@ -1,10 +1,14 @@
1
- /* $Id: rmutil.c,v 1.180 2009/09/26 22:28:59 rmagick Exp $ */
2
- /*============================================================================\
3
- | Copyright (C) 2009 by Timothy P. Hunter
4
- | Name: rmutil.c
5
- | Author: Tim Hunter
6
- | Purpose: Utility functions for RMagick
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
- Extern: magick_safe_malloc, magick_malloc, magick_free, magick_realloc
17
- Purpose: ImageMagick versions of standard memory routines.
18
- Notes: use when managing memory that ImageMagick may have
19
- allocated or may free.
20
-
21
- If malloc fails, it raises an exception.
22
-
23
- magick_safe_malloc and magick_safe_realloc prevent exceptions
24
- caused by integer overflow. Added in 6.3.5-9 but backwards
25
- compatible with prior releases.
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
- Extern: magick_clone_string
90
- Purpose: make a copy of a string in malloc'd memory
91
- Notes: Any existing string pointed to by *new_str is freed.
92
- CloneString asserts if no memory. No need to check
93
- its return value.
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
- * Extern: rm_strcasecmp(s1, s2)
105
- * Purpose: compare s1 and s2 ignoring case
106
- * Returns: same as strcmp(3)
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
- * Extern: rm_strncasecmp(s1, s2, n)
126
- * Purpose: compare s1 and s2 ignoring case
127
- * Returns: same as strcmp(3)
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
- * Extern: rm_check_ary_len(ary, len)
151
- * Purpose: raise exception if array too short
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
- Extern: rm_check_destroyed
166
- Purpose: raise an error if the image has been destroyed
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
- Extern: rm_check_frozen
185
- Purpose: raise an error if the image has been destroyed or is frozen
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
- Extern: rm_no_freeze(obj)
198
- Purpose: overrides freeze in classes that can't be frozen.
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
- Extern: rm_to_s
210
- Purpose: return obj.to_s, or obj if obj is already a string.
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
- Extern: rm_str2cstr(str, &len);
226
- Purpose: Supply our own version of the "obsolete" rb_str2cstr.
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
- * Static: arg_is_number
242
- * Purpose: Try to convert the argument to a double,
243
- * raise an exception if fail.
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
- * Static: rescue_not_str
257
- * Purpose: called when `rb_str_to_str' raised an exception below
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
- * Extern: rm_percentage(obj)
270
- * Purpose: Return a double between 0.0 and 1.0, inclusive.
271
- * If the argument is a number convert to a Float object,
272
- * otherwise it's supposed to be a string in the form "NN%".
273
- * Convert to a number and then to a Float.
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
- Static: check_num2dbl
329
- Purpose: return 0 if rb_num2dbl doesn't raise an exception
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
- Static: rescue_not_dbl
341
- Purpose: called if rb_num2dbl raises an exception
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
- Extern: rm_check_num2dbl
353
- Purpose: Return 1 if the object can be converted to a double, 0 otherwise.
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
- * Extern: rm_str_to_pct
364
- * Purpose: Given a string in the form NN% return the corresponding double.
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
- * Extern: rm_fuzz_to_dbl(obj)
397
- * Purpose: If the argument is a number, convert it to a double.
398
- * Otherwise it's supposed to be a string in the form 'NN%'.
399
- * Return a percentage of QuantumRange.
400
- * Notes: Called from Image#fuzz= and Info#fuzz=
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
- Extern: rm_app2quantum
451
- Purpose: Convert a application-supplied number to a Quantum. If the object
452
- is a Float, truncate it before converting.
453
- Notes: Ruby says that 2147483647.5 doesn't fit into an unsigned long.
454
- If you truncate it, it works.
455
- Should use this only when the input value is possibly subject
456
- to this problem.
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
- Extern: rm_cur_image
474
- Purpose: Sends the "cur_image" method to the object. If 'img'
475
- is an ImageList, then cur_image is self[@scene].
476
- If 'img' is an image, then cur_image is simply
477
- 'self'.
478
- Returns: the return value from "cur_image"
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
- Extern: rm_pixelpacket_to_color_name
489
- Purpose: Map the color intensity to a named color
490
- Returns: the named color as a String
491
- Notes: See below for the equivalent function that accepts an Info
492
- structure instead of an Image.
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
- Extern: rm_pixelpacket_to_color_name_info
512
- Purpose: Map the color intensity to a named color
513
- Returns: the named color as a String
514
- Notes: Accepts an Info structure instead of an Image (see above).
515
- Simply create an Image from the Info, call QueryColorname,
516
- and then destroy the Image.
517
- If the Info structure is NULL, creates a new one.
518
-
519
- Note that the default depth is always used, and the matte
520
- value is set to False, which means "don't use the alpha channel".
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
- External: write_temp_image
546
- Purpose: Write a temporary copy of the image to the IM registry
547
- Returns: the "filename" of the registered image
548
- Notes: The `temp_name' argument must point to an char array
549
- of size MaxTextExtent.
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
- External: delete_temp_image
595
- Purpose: Delete the temporary image from the registry
596
- Returns: void
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
- External: rm_not_implemented
613
- Purpose: raise NotImplementedError
614
- Notes: Called when a xMagick API is not available.
615
- Replaces Ruby's rb_notimplement function.
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
- Static: rm_magick_error(msg, loc)
628
- Purpose: create a new ImageMagickError object and raise an exception
629
- Notes: does not return
630
- This funky technique allows me to safely add additional
631
- information to the ImageMagickError object in both 1.6.8 and
632
- 1.8.0. See www.ruby_talk.org/36408.
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
- Method: ImageMagickError#initialize(msg, loc)
649
- Purpose: initialize a new ImageMagickError object - store
650
- the "loc" string in the @magick_location instance variable
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
- Function: rm_get_property
682
- Purpose: Backport GetImageProperty for pre-6.3.1 versions of ImageMagick
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
- Function: rm_set_property
693
- Purpose: Backport SetImageProperty for pre-6.3.1 versions of ImageMagick
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
- Function: rm_set_user_artifact
704
- Purpose: If a "user" option is present in the Info, assign its value to
705
- a "user" artifact in each image.
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
- Function: rm_get_optional_arguments
732
- Purpose: Collect optional method arguments via Magick::OptionalMethodArguments
733
- Notes: Creates an instance of Magick::OptionalMethodArguments, then yields
734
- to a block in the context of the instance.
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
- Extern: rm_sync_image_options
784
- Purpose: Propagate ImageInfo values to the Image
785
- Ref: SyncImageSettings (in mogrify.c)
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
- Function: rm_exif_by_entry
952
- Purpose: replicate old (< 6.3.2) EXIF:* functionality using GetImageProperty
953
- by returning the exif entries as a single string, separated by \n's.
954
- Do this so that RMagick.rb works no matter which version of
955
- ImageMagick is in use.
956
- Notes: see magick/identify.c
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
- Function: rm_exif_by_number
1034
- Purpose: replicate old (< 6.3.2) EXIF:! functionality using GetImageProperty
1035
- by returning the exif entries as a single string, separated by \n's.
1036
- Do this so that RMagick.rb works no matter which version of
1037
- ImageMagick is in use.
1038
- Notes: see magick/identify.c
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
- * Extern: rm_get_geometry
1116
- * Purpose: Get the values from a Geometry object and return
1117
- * them in C variables.
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
- * Extern: rm_clone_image
1166
- * Purpose: clone an image, handle errors
1167
- * Notes: don't trace creation - the clone may not be used as an Image
1168
- * object. Let the caller do the trace if desired.
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
- Extern: rm_progress_monitor
1191
- Purpose: SetImage(Info)ProgressMonitor exit
1192
- Notes: ImageMagick's "tag" argument is unused. We pass along the method name instead.
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
- Extern: rm_split
1224
- Purpose: Remove the ImageMagick links between images in an scene
1225
- sequence.
1226
- Notes: The images remain grouped via the ImageList
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
- Extern: rm_check_image_exception
1245
- Purpose: If an ExceptionInfo struct in a list of images indicates a warning,
1246
- issue a warning message. If an ExceptionInfo struct indicates an
1247
- error, raise an exception and optionally destroy the images.
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
- * Extern: rm_check_exception
1291
- * Purpose: Call handle_exception if there is an exception to handle.
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
- * Extern: rm_warning_handler
1308
- * Purpose: called from ImageMagick for a warning
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
- * Extern: rm_error_handler
1323
- * Purpose: called from ImageMagick for a error
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
- * Extern: rm_fatal_error_handler
1348
- * Purpose: called from ImageMagick for a fatal error
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
- * Static: handle_exception
1360
- * Purpose: called when rm_check_exception determines that we need
1361
- * to either issue a warning message or raise an exception.
1362
- * This function allocates a bunch of stack so we don't call
1363
- * it unless we have to.
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
- * Extern: rm_ensure_result
1452
- * Purpose: RMagick expected a result. If it got NULL instead raise an exception.
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)