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: rmpixel.c,v 1.5 2009/06/03 23:08:31 rmagick Exp $ */
2
- /*============================================================================\
3
- | Copyright (C) 2009 by Timothy P. Hunter
4
- | Name: rmpixel.c
5
- | Author: Tim Hunter
6
- | Purpose: Contains Pixel class methods.
7
- \============================================================================*/
1
+ /**************************************************************************//**
2
+ * Contains Pixel class methods.
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 rmpixel.c
9
+ * @version $Id: rmpixel.c,v 1.7 2009/12/21 10:34:58 baror Exp $
10
+ * @author Tim Hunter
11
+ ******************************************************************************/
8
12
 
9
13
  #include "rmagick.h"
10
14
 
@@ -16,10 +20,13 @@ static void Color_Name_to_PixelPacket(PixelPacket *, VALUE);
16
20
 
17
21
 
18
22
 
19
- /*
20
- Extern: destroy_Pixel
21
- Purpose: Free the storage associated with a Pixel object
22
- */
23
+ /**
24
+ * Free the storage associated with a Pixel object.
25
+ *
26
+ * No Ruby usage (internal function)
27
+ *
28
+ * @param pixel the Pixel object to destroy
29
+ */
23
30
  void
24
31
  destroy_Pixel(Pixel *pixel)
25
32
  {
@@ -27,41 +34,138 @@ destroy_Pixel(Pixel *pixel)
27
34
  }
28
35
 
29
36
 
30
- /*
31
- Methods: Pixel RGBA attribute accessors
32
- Purpose: Get/set Pixel attributes
33
- Note: Pixel is Observable. Setters call changed, notify_observers
34
- Note: Setters return their argument values for backward compatibility
35
- to when Pixel was a Struct class.
36
- */
37
+ /**
38
+ * Get Pixel red attribute.
39
+ *
40
+ * Ruby usage:
41
+ * - @verbatim Pixel#red @endverbatim
42
+ *
43
+ * @param self this object
44
+ * @return the red value
45
+ */
37
46
  DEF_ATTR_READER(Pixel, red, int)
47
+
48
+ /**
49
+ * Get Pixel green attribute.
50
+ *
51
+ * Ruby usage:
52
+ * - @verbatim Pixel#green @endverbatim
53
+ *
54
+ * @param self this object
55
+ * @return the green value
56
+ */
38
57
  DEF_ATTR_READER(Pixel, green, int)
58
+
59
+ /**
60
+ * Get Pixel blue attribute.
61
+ *
62
+ * Ruby usage:
63
+ * - @verbatim Pixel#blue @endverbatim
64
+ *
65
+ * @param self this object
66
+ * @return the blue value
67
+ */
39
68
  DEF_ATTR_READER(Pixel, blue, int)
69
+
70
+ /**
71
+ * Get Pixel opacity attribute.
72
+ *
73
+ * Ruby usage:
74
+ * - @verbatim Pixel#opacity @endverbatim
75
+ *
76
+ * @param self this object
77
+ * @return the opacity value
78
+ */
40
79
  DEF_ATTR_READER(Pixel, opacity, int)
80
+
81
+ /**
82
+ * Set Pixel red attribute.
83
+ *
84
+ * Ruby usage:
85
+ * - @verbatim Pixel#red= @endverbatim
86
+ *
87
+ * Notes:
88
+ * - Pixel is Observable. Setters call changed, notify_observers
89
+ * - Setters return their argument values for backward compatibility to when
90
+ * Pixel was a Struct class.
91
+ *
92
+ * @param self this object
93
+ * @param v the red value
94
+ * @return self
95
+ */
41
96
  DEF_PIXEL_CHANNEL_WRITER(red)
97
+
98
+ /**
99
+ * Set Pixel green attribute.
100
+ *
101
+ * Ruby usage:
102
+ * - @verbatim Pixel#green= @endverbatim
103
+ *
104
+ * Notes:
105
+ * - Pixel is Observable. Setters call changed, notify_observers
106
+ * - Setters return their argument values for backward compatibility to when
107
+ * Pixel was a Struct class.
108
+ *
109
+ * @param self this object
110
+ * @param v the green value
111
+ * @return self
112
+ */
42
113
  DEF_PIXEL_CHANNEL_WRITER(green)
114
+
115
+ /**
116
+ * Set Pixel blue attribute.
117
+ *
118
+ * Ruby usage:
119
+ * - @verbatim Pixel#blue= @endverbatim
120
+ *
121
+ * Notes:
122
+ * - Pixel is Observable. Setters call changed, notify_observers
123
+ * - Setters return their argument values for backward compatibility to when
124
+ * Pixel was a Struct class.
125
+ *
126
+ * @param self this object
127
+ * @param v the blue value
128
+ * @return self
129
+ */
43
130
  DEF_PIXEL_CHANNEL_WRITER(blue)
131
+
132
+ /**
133
+ * Set Pixel opacity attribute.
134
+ *
135
+ * Ruby usage:
136
+ * - @verbatim Pixel#opacity= @endverbatim
137
+ *
138
+ * Notes:
139
+ * - Pixel is Observable. Setters call changed, notify_observers
140
+ * - Setters return their argument values for backward compatibility to when
141
+ * Pixel was a Struct class.
142
+ *
143
+ * @param self this object
144
+ * @param v the opacity value
145
+ * @return self
146
+ */
44
147
  DEF_PIXEL_CHANNEL_WRITER(opacity)
45
148
 
46
149
 
47
150
  /*
48
- Methods: Pixel CMYK attribute accessors
49
- Purpose: Get/set Pixel attributes
50
- Note: Pixel is Observable. Setters call changed, notify_observers
51
- Note: Setters return their argument values for backward compatibility
52
- to when Pixel was a Struct class.
53
- */
151
+ * Get/set Pixel CMYK attributes.
152
+ */
54
153
  DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(cyan, red)
55
154
  DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(magenta, green)
56
155
  DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(yellow, blue)
57
156
  DEF_PIXEL_CMYK_CHANNEL_ACCESSOR(black, opacity)
58
157
 
59
158
 
60
- /*
61
- * Static: color_arg_rescue
62
- * Purpose: raise ArgumentError if the color name cannot be converted
63
- * to a string via rb_str_to_str.
64
- */
159
+ /**
160
+ * Raise ArgumentError if the color name cannot be converted to a string via
161
+ * rb_str_to_str.
162
+ *
163
+ * No Ruby usage (internal function)
164
+ *
165
+ * @param arg the argument to convert
166
+ * @return 0
167
+ * @throw ArgumentError
168
+ */
65
169
  static VALUE
66
170
  color_arg_rescue(VALUE arg)
67
171
  {
@@ -71,11 +175,14 @@ color_arg_rescue(VALUE arg)
71
175
  }
72
176
 
73
177
 
74
- /*
75
- Extern: Color_to_PixelPacket
76
- Purpose: Convert either a String color name or
77
- a Magick::Pixel to a PixelPacket
78
- */
178
+ /**
179
+ * Convert either a String color name or a Magick::Pixel to a PixelPacket.
180
+ *
181
+ * No Ruby usage (internal function)
182
+ *
183
+ * @param pp the PixelPacket to modify
184
+ * @param color the color name or Magick::Pixel
185
+ */
79
186
  void
80
187
  Color_to_PixelPacket(PixelPacket *pp, VALUE color)
81
188
  {
@@ -96,11 +203,15 @@ Color_to_PixelPacket(PixelPacket *pp, VALUE color)
96
203
  }
97
204
 
98
205
 
99
- /*
100
- Static: Color_Name_to_PixelPacket
101
- Purpose: Convert a color name to a PixelPacket
102
- Raises: ArgumentError
103
- */
206
+ /**
207
+ * Convert a color name to a PixelPacket
208
+ *
209
+ * No Ruby usage (internal function)
210
+ *
211
+ * @param color the PixelPacket to modify
212
+ * @param name_arg the coor name
213
+ * @throw ArgumentError
214
+ */
104
215
  static void
105
216
  Color_Name_to_PixelPacket(PixelPacket *color, VALUE name_arg)
106
217
  {
@@ -120,10 +231,14 @@ Color_Name_to_PixelPacket(PixelPacket *color, VALUE name_arg)
120
231
 
121
232
 
122
233
 
123
- /*
124
- Extern: Pixel_alloc
125
- Purpose: Allocate a Pixel object
126
- */
234
+ /**
235
+ * Allocate a Pixel object.
236
+ *
237
+ * No Ruby usage (internal function)
238
+ *
239
+ * @param class the Ruby class to use
240
+ * @return a new Magick::Pixel object
241
+ */
127
242
  VALUE
128
243
  Pixel_alloc(VALUE class)
129
244
  {
@@ -135,10 +250,16 @@ Pixel_alloc(VALUE class)
135
250
  }
136
251
 
137
252
 
138
- /*
139
- Method: Pixel#===
140
- Purpose: "Case equal" operator for Pixel
141
- */
253
+ /**
254
+ * "Case equal" operator for Pixel.
255
+ *
256
+ * Ruby usage:
257
+ * - @verbatim Pixel#=== @endverbatim
258
+ *
259
+ * @param self this object
260
+ * @param other the other object
261
+ * @return true or false
262
+ */
142
263
 
143
264
  VALUE
144
265
  Pixel_case_eq(VALUE self, VALUE other)
@@ -159,10 +280,17 @@ Pixel_case_eq(VALUE self, VALUE other)
159
280
  }
160
281
 
161
282
 
162
- /*
163
- Method: Pixel#clone
164
- Notes: see dup, init_copy
165
- */
283
+ /**
284
+ * Clone a Pixel.
285
+ *
286
+ * Ruby usage:
287
+ * - @verbatim Pixel#clone @endverbatim
288
+ *
289
+ * @param self this object
290
+ * @return a clone
291
+ * @see Pixel_dup
292
+ * @see Pixel_init_copy
293
+ */
166
294
  VALUE
167
295
  Pixel_clone(VALUE self)
168
296
  {
@@ -178,6 +306,17 @@ Pixel_clone(VALUE self)
178
306
  }
179
307
 
180
308
 
309
+ /**
310
+ * Duplicate a Pixel.
311
+ *
312
+ * Ruby usage:
313
+ * - @verbatim Pixel#dup @endverbatim
314
+ *
315
+ * @param self this object
316
+ * @return a clone
317
+ * @see Pixel_clone
318
+ * @see Pixel_init_copy
319
+ */
181
320
  VALUE
182
321
  Pixel_dup(VALUE self)
183
322
  {
@@ -195,10 +334,16 @@ Pixel_dup(VALUE self)
195
334
  }
196
335
 
197
336
 
198
- /*
199
- Method: Pixel#eql?
200
- Purpose: For use with Hash
201
- */
337
+ /**
338
+ * For use with Hash.
339
+ *
340
+ * Ruby usage:
341
+ * - @verbatim Pixel#eql? @endverbatim
342
+ *
343
+ * @param self this object
344
+ * @param other the other object
345
+ * @return true if hash to the same value, otherwise false
346
+ */
202
347
  VALUE
203
348
  Pixel_eql_q(VALUE self, VALUE other)
204
349
  {
@@ -206,10 +351,21 @@ Pixel_eql_q(VALUE self, VALUE other)
206
351
  }
207
352
 
208
353
 
209
- /*
210
- Method: Pixel#fcmp(other[, fuzz[, colorspace]])
211
- Purpose: Compare pixel values for equality
212
- */
354
+ /**
355
+ * Compare pixel values for equality.
356
+ *
357
+ * Ruby usage:
358
+ * - @verbatim Pixel#fcmp(other, fuzz, colorspace) @endverbatim
359
+ *
360
+ * Notes:
361
+ * - Default fuzz is 0.0
362
+ * - Default colorspace is RGBColorspace
363
+ *
364
+ * @param argc number of input arguments
365
+ * @param argv array of input arguments
366
+ * @param self this object
367
+ * @return true if equal, otherwise false
368
+ */
213
369
  VALUE
214
370
  Pixel_fcmp(int argc, VALUE *argv, VALUE self)
215
371
  {
@@ -267,15 +423,23 @@ Pixel_fcmp(int argc, VALUE *argv, VALUE self)
267
423
  }
268
424
 
269
425
 
270
- /*
271
- Method: Magick::Pixel.from_color(string)
272
- Purpose: Construct an Magick::Pixel corresponding to the given color name.
273
- Notes: the "inverse" is Image *#to_color, b/c the conversion of a pixel
274
- to a color name requires both a color depth and if the opacity
275
- value has meaning (i.e. whether image->matte == True or not).
276
-
277
- Also see Magick::Pixel#to_color, below.
278
- */
426
+ /**
427
+ * Construct an Magick::Pixel corresponding to the given color name.
428
+ *
429
+ * Ruby usage:
430
+ * - @verbatim Magick::Pixel.from_color(string) @endverbatim
431
+ *
432
+ * Notes:
433
+ * - The "inverse" is Image_to_color, b/c the conversion of a pixel to a
434
+ * color name requires both a color depth and if the opacity value has
435
+ * meaning (i.e. whether image->matte == True or not).
436
+ *
437
+ * @param class the Ruby class to use
438
+ * @param name the color name
439
+ * @return a new Magic::Pixel object
440
+ * @see Image_to_color
441
+ * @see Pixel_to_color
442
+ */
279
443
  VALUE
280
444
  Pixel_from_color(VALUE class, VALUE name)
281
445
  {
@@ -299,12 +463,26 @@ Pixel_from_color(VALUE class, VALUE name)
299
463
  }
300
464
 
301
465
 
302
- /*
303
- Method: Pixel#from_hsla(hue, saturation, lightness, alpha=1)
304
- Purpose: Replace brain-dead from_HSL, above.
305
- Notes: 0 <= hue < 360, 0 <= saturation <= 1, 0 <= lightness <= 1
306
- 0 <= alpha <= 1 (0 is transparent, 1 is opaque)
307
- */
466
+ /**
467
+ * Construct an RGB pixel.
468
+ *
469
+ * Ruby usage:
470
+ * - @verbatim Pixel#from_hsla(hue, saturation, lightness) @endverbatim
471
+ * - @verbatim Pixel#from_hsla(hue, saturation, lightness, alpha) @endverbatim
472
+ *
473
+ * Notes:
474
+ * - Default alpha is 1.0
475
+ * - 0 <= hue < 360 OR "0%" <= hue < "100%"
476
+ * - 0 <= saturation <= 255 OR "0%" <= saturation <= "100%"
477
+ * - 0 <= lightness <= 255 OR "0%" <= lightness <= "100%"
478
+ * - 0 <= alpha <= 1 (0 is transparent, 1 is opaque) OR "0%" <= alpha <= "100%"
479
+ * - Replaces brain-dead Pixel_from_HSL.
480
+ *
481
+ * @param argc number of input arguments
482
+ * @param argv array of input arguments
483
+ * @param class the Ruby class to use
484
+ * @return a new Magick::Pixel object
485
+ */
308
486
  VALUE
309
487
  Pixel_from_hsla(int argc, VALUE *argv, VALUE class)
310
488
  {
@@ -319,12 +497,14 @@ Pixel_from_hsla(int argc, VALUE *argv, VALUE class)
319
497
  switch (argc)
320
498
  {
321
499
  case 4:
322
- a = NUM2DBL(argv[3]);
500
+ a = rm_percentage(argv[3],1.0);
323
501
  alpha = MagickTrue;
324
502
  case 3:
325
- l = NUM2DBL(argv[2]);
326
- s = NUM2DBL(argv[1]);
327
- h = NUM2DBL(argv[0]);
503
+ // saturation and lightness are out of 255 in new ImageMagicks and
504
+ // out of 100 in old ImageMagicks. Compromise: always use %.
505
+ l = rm_percentage(argv[2],255.0);
506
+ s = rm_percentage(argv[1],255.0);
507
+ h = rm_percentage(argv[0],360.0);
328
508
  break;
329
509
  default:
330
510
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 3 or 4)", argc);
@@ -335,19 +515,28 @@ Pixel_from_hsla(int argc, VALUE *argv, VALUE class)
335
515
  {
336
516
  rb_raise(rb_eRangeError, "alpha %g out of range [0.0, 1.0]", a);
337
517
  }
338
- if (l < 0.0 || l > 100.0)
518
+ if (l < 0.0 || l > 255.0)
339
519
  {
340
- rb_raise(rb_eRangeError, "lightness %g out of range [0.0, 100.0]", l);
520
+ rb_raise(rb_eRangeError, "lightness %g out of range [0.0, 255.0]", l);
341
521
  }
342
- if (s < 0.0 || s > 100.0)
522
+ if (s < 0.0 || s > 255.0)
343
523
  {
344
- rb_raise(rb_eRangeError, "saturation %g out of range [0.0, 100.0]", s);
524
+ rb_raise(rb_eRangeError, "saturation %g out of range [0.0, 255.0]", s);
345
525
  }
346
526
  if (h < 0.0 || h >= 360.0)
347
527
  {
348
528
  rb_raise(rb_eRangeError, "hue %g out of range [0.0, 360.0)", h);
349
529
  }
350
530
 
531
+ // Ugly way of checking for change in ImageMagick 6.5.6-5 to see whether
532
+ // saturation/lightness should be out of 255 or out of 100.
533
+ if(MagickLibVersion < 0x656 ||
534
+ (MagickLibVersion == 0x656 && strcmp(MagickLibSubversion,"-5") <= 0) )
535
+ {
536
+ s = s/2.55;
537
+ l = l/2.55;
538
+ }
539
+
351
540
  memset(name, 0, sizeof(name));
352
541
  if (alpha)
353
542
  {
@@ -369,11 +558,17 @@ Pixel_from_hsla(int argc, VALUE *argv, VALUE class)
369
558
  }
370
559
 
371
560
 
372
- /*
373
- Method: Pixel.from_HSL *** DEPRECATED ***
374
- Purpose: Constructs an RGB pixel from the array
375
- [hue, saturation, luminosity].
376
- */
561
+ /**
562
+ * Construct an RGB pixel from the array [hue, saturation, luminosity].
563
+ *
564
+ * Ruby usage:
565
+ * - @verbatim Pixel.from_HSL @endverbatim
566
+ *
567
+ * @param class the Ruby class to use
568
+ * @param hsl the array
569
+ * @return a new Magick::Pixel object
570
+ * @deprecated This method has been deprecated. Please use Pixel_from_hsla.
571
+ */
377
572
  VALUE
378
573
  Pixel_from_HSL(VALUE class, VALUE hsl)
379
574
  {
@@ -400,11 +595,17 @@ Pixel_from_HSL(VALUE class, VALUE hsl)
400
595
  }
401
596
 
402
597
 
403
- /*
404
- Static: Pixel_from_MagickPixelPacket
405
- Purpose: Create a Magick::Pixel object from a MagickPixelPacket structure.
406
- Notes: bypasses normal Pixel.new, Pixel#initialize methods
407
- */
598
+ /**
599
+ * Create a Magick::Pixel object from a MagickPixelPacket structure.
600
+ *
601
+ * No Ruby usage (internal function)
602
+ *
603
+ * Notes:
604
+ * - Bypasses normal Pixel.new, Pixel#initialize methods
605
+ *
606
+ * @param pp the MagickPixelPacket
607
+ * @return a new Magick::Pixel object
608
+ */
408
609
  VALUE
409
610
  Pixel_from_MagickPixelPacket(const MagickPixelPacket *pp)
410
611
  {
@@ -420,11 +621,17 @@ Pixel_from_MagickPixelPacket(const MagickPixelPacket *pp)
420
621
  }
421
622
 
422
623
 
423
- /*
424
- Extern: Pixel_from_PixelPacket
425
- Purpose: Create a Magick::Pixel object from a PixelPacket structure.
426
- Notes: bypasses normal Pixel.new, Pixel#initialize methods
427
- */
624
+ /**
625
+ * Create a Magick::Pixel object from a PixelPacket structure.
626
+ *
627
+ * No Ruby usage (internal function)
628
+ *
629
+ * Notes:
630
+ * - Bypasses normal Pixel.new, Pixel#initialize methods
631
+ *
632
+ * @param pp the PixelPacket
633
+ * @return a new Magick::Pixel object
634
+ */
428
635
  VALUE
429
636
  Pixel_from_PixelPacket(const PixelPacket *pp)
430
637
  {
@@ -436,11 +643,17 @@ Pixel_from_PixelPacket(const PixelPacket *pp)
436
643
  }
437
644
 
438
645
 
439
- /*
440
- Method: Pixel#hash
441
- Notes: INT2FIX left-shifts 1 bit. Sacrifice 1 bit
442
- from the opacity attribute to the FIXNUM_FLAG.
443
- */
646
+ /**
647
+ * Ruby usage:
648
+ * - @verbatim Pixel#hash @endverbatim
649
+ *
650
+ * Notes:
651
+ * - INT2FIX left-shifts 1 bit. Sacrifice 1 bit from the opacity attribute to
652
+ * the FIXNUM_FLAG.
653
+ *
654
+ * @param self this object
655
+ * @return the hash of self
656
+ */
444
657
  VALUE
445
658
  Pixel_hash(VALUE self)
446
659
  {
@@ -460,10 +673,18 @@ Pixel_hash(VALUE self)
460
673
  }
461
674
 
462
675
 
463
- /*
464
- Method: Pixel#initialize_copy
465
- Purpose: initialize clone, dup methods
466
- */
676
+ /**
677
+ * Initialize clone, dup methods.
678
+ *
679
+ * Ruby usage:
680
+ * - @verbatim Pixel#initialize_copy @endverbatim
681
+ *
682
+ * @param self this object
683
+ * @param orig the original Pixel
684
+ * @return self
685
+ * @see Pixel_clone
686
+ * @see Pixel_dup
687
+ */
467
688
  VALUE
468
689
  Pixel_init_copy(VALUE self, VALUE orig)
469
690
  {
@@ -478,10 +699,26 @@ Pixel_init_copy(VALUE self, VALUE orig)
478
699
  }
479
700
 
480
701
 
481
- /*
482
- Method: Pixel#initialize(red=0,green=0,blue=0,opacity=0)
483
- Notes: For backward compatibility, arguments may be nil.
484
- */
702
+ /**
703
+ * Ruby usage:
704
+ * - @verbatim Pixel#initialize @endverbatim
705
+ * - @verbatim Pixel#initialize(red) @endverbatim
706
+ * - @verbatim Pixel#initialize(red,green) @endverbatim
707
+ * - @verbatim Pixel#initialize(red,green,blue) @endverbatim
708
+ * - @verbatim Pixel#initialize(red,green,blue,opacity) @endverbatim
709
+ *
710
+ * Notes:
711
+ * - Default red is 0.0
712
+ * - Default green is 0.0
713
+ * - Default blue is 0.0
714
+ * - Default opacity is 0.0
715
+ * - For backward compatibility, arguments may be nil.
716
+ *
717
+ * @param argc number of input arguments
718
+ * @param argv array of input arguments
719
+ * @param self this object
720
+ * @return self
721
+ */
485
722
  VALUE
486
723
  Pixel_initialize(int argc, VALUE *argv, VALUE self)
487
724
  {
@@ -521,10 +758,15 @@ Pixel_initialize(int argc, VALUE *argv, VALUE self)
521
758
  }
522
759
 
523
760
 
524
- /*
525
- Method: Pixel#intensity
526
- Purpose: Return the "intensity" of a pixel
527
- */
761
+ /**
762
+ * Return the "intensity" of a pixel.
763
+ *
764
+ * Ruby usage:
765
+ * - @verbatim Pixel#intensity @endverbatim
766
+ *
767
+ * @param self this object
768
+ * @return the intensity
769
+ */
528
770
  VALUE
529
771
  Pixel_intensity(VALUE self)
530
772
  {
@@ -541,10 +783,15 @@ Pixel_intensity(VALUE self)
541
783
  }
542
784
 
543
785
 
544
- /*
545
- Method: Pixel#marshal_dump
546
- Purpose: Support Marshal.dump
547
- */
786
+ /**
787
+ * Support Marshal.dump.
788
+ *
789
+ * Ruby usage:
790
+ * - @verbatim Pixel#marshal_dump @endverbatim
791
+ *
792
+ * @param self this object
793
+ * @return a string representing the dumped pixel
794
+ */
548
795
  VALUE
549
796
  Pixel_marshal_dump(VALUE self)
550
797
  {
@@ -561,10 +808,16 @@ Pixel_marshal_dump(VALUE self)
561
808
  }
562
809
 
563
810
 
564
- /*
565
- Method: Pixel#marshal_load
566
- Purpose: Support Marshal.load
567
- */
811
+ /**
812
+ * Support Marshal.load.
813
+ *
814
+ * Ruby usage:
815
+ * - @verbatim Pixel#marshal_load @endverbatim
816
+ *
817
+ * @param self this object
818
+ * @param dpixel the dumped pixel
819
+ * @return self
820
+ */
568
821
  VALUE
569
822
  Pixel_marshal_load(VALUE self, VALUE dpixel)
570
823
  {
@@ -579,10 +832,16 @@ Pixel_marshal_load(VALUE self, VALUE dpixel)
579
832
  }
580
833
 
581
834
 
582
- /*
583
- Method: Pixel#<=>
584
- Purpose: Support Comparable mixin
585
- */
835
+ /**
836
+ * Support Comparable mixin.
837
+ *
838
+ * Ruby usage:
839
+ * - @verbatim Pixel#<=> @endverbatim
840
+ *
841
+ * @param self this object
842
+ * @param other the other Pixel
843
+ * @return -1, 0, 1
844
+ */
586
845
  VALUE
587
846
  Pixel_spaceship(VALUE self, VALUE other)
588
847
  {
@@ -615,11 +874,21 @@ Pixel_spaceship(VALUE self, VALUE other)
615
874
  }
616
875
 
617
876
 
618
- /*
619
- Method: Pixel#to_hsla()
620
- Purpose: Replace brain-dead to_HSL, above.
621
- Notes: Returns [hue, saturation, lightness, alpha] in the same ranges as from_hsla()
622
- */
877
+ /**
878
+ * Return [hue, saturation, lightness, alpha] in the same ranges as
879
+ * Pixel_from_hsla.
880
+ *
881
+ *
882
+ * Ruby usage:
883
+ * - @verbatim Pixel#to_hsla @endverbatim
884
+ *
885
+ * Notes:
886
+ * - Replace brain-dead Pixel_to_HSL.
887
+ *
888
+ * @param self this object
889
+ * @return an array with hsla data
890
+ * @see Pixel_from_hsla
891
+ */
623
892
  VALUE
624
893
  Pixel_to_hsla(VALUE self)
625
894
  {
@@ -631,8 +900,8 @@ Pixel_to_hsla(VALUE self)
631
900
 
632
901
  ConvertRGBToHSL(pixel->red, pixel->green, pixel->blue, &hue, &sat, &lum);
633
902
  hue *= 360.0;
634
- sat *= 100.0;
635
- lum *= 100.0;
903
+ sat *= 255.0;
904
+ lum *= 255.0;
636
905
 
637
906
  if (pixel->opacity == OpaqueOpacity)
638
907
  {
@@ -651,11 +920,16 @@ Pixel_to_hsla(VALUE self)
651
920
  return hsla;
652
921
  }
653
922
 
654
- /*
655
- Method: Pixel#to_HSL *** DEPRECATED ***
656
- Purpose: Converts an RGB pixel to the array
657
- [hue, saturation, luminosity].
658
- */
923
+ /**
924
+ * Convert an RGB pixel to the array [hue, saturation, luminosity].
925
+ *
926
+ * Ruby usage:
927
+ * - @verbatim Pixel#to_HSL @endverbatim
928
+ *
929
+ * @param self this object
930
+ * @return an array with hsl data
931
+ * @deprecated This method has been deprecated. Please use Pixel_to_hsla.
932
+ */
659
933
  VALUE
660
934
  Pixel_to_HSL(VALUE self)
661
935
  {
@@ -675,13 +949,28 @@ Pixel_to_HSL(VALUE self)
675
949
  }
676
950
 
677
951
 
678
- /*
679
- Method: Magick::Pixel#to_color(compliance=AllCompliance, matte=false,
680
- depth=QuantumDepth, hex=false)
681
- Purpose: return the color name corresponding to the pixel values
682
- Notes: the conversion respects the value of the 'opacity' field
683
- in the Pixel.
684
- */
952
+ /**
953
+ * Return the color name corresponding to the pixel values.
954
+ *
955
+ * Ruby usage:
956
+ * - @verbatim Magick::Pixel#to_color @endverbatim
957
+ * - @verbatim Magick::Pixel#to_color(compliance) @endverbatim
958
+ * - @verbatim Magick::Pixel#to_color(compliance, matte) @endverbatim
959
+ * - @verbatim Magick::Pixel#to_color(compliance, matte, depth) @endverbatim
960
+ * - @verbatim Magick::Pixel#to_color(compliance, matte, depth, hex) @endverbatim
961
+ *
962
+ * Notes:
963
+ * - Default compliance is AllCompliance
964
+ * - Default matte is false
965
+ * - Default depth is QuantumDepth
966
+ * - Default hex is false
967
+ * - The conversion respects the value of the 'opacity' field in the Pixel
968
+ *
969
+ * @param argc number of input arguments
970
+ * @param argv array of input arguments
971
+ * @param self this object
972
+ * @return the color name as a String
973
+ */
685
974
  VALUE
686
975
  Pixel_to_color(int argc, VALUE *argv, VALUE self)
687
976
  {
@@ -769,10 +1058,15 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
769
1058
  }
770
1059
 
771
1060
 
772
- /*
773
- Method: Magick::Pixel#to_s
774
- Purpose: Create a string representation of a Magick::Pixel
775
- */
1061
+ /**
1062
+ * Create a string representation of a Magick::Pixel.
1063
+ *
1064
+ * Ruby usage:
1065
+ * - @verbatim Magick::Pixel#to_s @endverbatim
1066
+ *
1067
+ * @param self this object
1068
+ * @return the string
1069
+ */
776
1070
  VALUE
777
1071
  Pixel_to_s(VALUE self)
778
1072
  {
@@ -786,12 +1080,17 @@ Pixel_to_s(VALUE self)
786
1080
  }
787
1081
 
788
1082
 
789
- /*
790
- Static: rm_set_magick_pixel_packet
791
- Purpose: Convert a PixelPacket to a MagickPixelPacket
792
- Notes: Same code as the private function SetMagickPixelPacket
793
- in ImageMagick.
794
- */
1083
+ /**
1084
+ * Convert a PixelPacket to a MagickPixelPacket.
1085
+ *
1086
+ * No Ruby usage (internal function)
1087
+ *
1088
+ * Notes:
1089
+ * - Same code as the private function SetMagickPixelPacket in ImageMagick.
1090
+ *
1091
+ * @param pixel the pixel
1092
+ * @param pp the MagickPixelPacket to be modified
1093
+ */
795
1094
  void
796
1095
  rm_set_magick_pixel_packet(Pixel *pixel, MagickPixelPacket *pp)
797
1096
  {