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/rmpixel.c
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
21
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
-
|
49
|
-
|
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
|
-
*
|
62
|
-
*
|
63
|
-
*
|
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
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
101
|
-
|
102
|
-
|
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
|
-
|
125
|
-
|
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
|
-
|
140
|
-
|
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
|
-
|
164
|
-
|
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
|
-
|
200
|
-
|
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
|
-
|
211
|
-
|
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
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
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
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
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 =
|
500
|
+
a = rm_percentage(argv[3],1.0);
|
323
501
|
alpha = MagickTrue;
|
324
502
|
case 3:
|
325
|
-
|
326
|
-
|
327
|
-
|
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 >
|
518
|
+
if (l < 0.0 || l > 255.0)
|
339
519
|
{
|
340
|
-
rb_raise(rb_eRangeError, "lightness %g out of range [0.0,
|
520
|
+
rb_raise(rb_eRangeError, "lightness %g out of range [0.0, 255.0]", l);
|
341
521
|
}
|
342
|
-
if (s < 0.0 || s >
|
522
|
+
if (s < 0.0 || s > 255.0)
|
343
523
|
{
|
344
|
-
rb_raise(rb_eRangeError, "saturation %g out of range [0.0,
|
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
|
-
|
374
|
-
|
375
|
-
|
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
|
-
|
405
|
-
|
406
|
-
|
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
|
-
|
425
|
-
|
426
|
-
|
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
|
-
|
441
|
-
|
442
|
-
|
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
|
-
|
465
|
-
|
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
|
-
|
483
|
-
|
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
|
-
|
526
|
-
|
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
|
-
|
546
|
-
|
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
|
-
|
566
|
-
|
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
|
-
|
584
|
-
|
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
|
-
|
620
|
-
|
621
|
-
|
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 *=
|
635
|
-
lum *=
|
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
|
-
|
656
|
-
|
657
|
-
|
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
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
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
|
-
|
774
|
-
|
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
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
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
|
{
|