rmagick 4.2.6 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.devcontainer/ImageMagick6/devcontainer.json +1 -1
- data/.devcontainer/{ImageMagick7/devcontainer.json → devcontainer.json} +2 -2
- data/.devcontainer/setup-user.sh +1 -1
- data/.editorconfig +1 -1
- data/.github/workflows/ci.yml +87 -9
- data/.gitignore +4 -0
- data/.rubocop_todo.yml +16 -9
- data/.yardopts +1 -1
- data/CHANGELOG.md +130 -0
- data/Gemfile +20 -0
- data/README.md +10 -17
- data/Rakefile +63 -80
- data/before_install_linux.sh +3 -3
- data/before_install_osx.sh +6 -5
- data/ext/RMagick/extconf.rb +112 -52
- data/ext/RMagick/{rmagick.c → rmagick.cpp} +19 -22
- data/ext/RMagick/rmagick.h +88 -59
- data/ext/RMagick/rmagick_gvl.h +224 -0
- data/ext/RMagick/{rmdraw.c → rmdraw.cpp} +170 -159
- data/ext/RMagick/{rmenum.c → rmenum.cpp} +69 -50
- data/ext/RMagick/{rmfill.c → rmfill.cpp} +85 -24
- data/ext/RMagick/{rmilist.c → rmilist.cpp} +191 -93
- data/ext/RMagick/{rmimage.c → rmimage.cpp} +1543 -989
- data/ext/RMagick/{rminfo.c → rminfo.cpp} +140 -152
- data/ext/RMagick/{rmkinfo.c → rmkinfo.cpp} +46 -34
- data/ext/RMagick/rmmain.cpp +1923 -0
- data/ext/RMagick/{rmmontage.c → rmmontage.cpp} +50 -29
- data/ext/RMagick/{rmpixel.c → rmpixel.cpp} +108 -83
- data/ext/RMagick/{rmstruct.c → rmstruct.cpp} +6 -6
- data/ext/RMagick/{rmutil.c → rmutil.cpp} +62 -161
- data/lib/rmagick/version.rb +3 -1
- data/lib/rmagick.rb +2 -0
- data/lib/rmagick_internal.rb +76 -110
- data/lib/rvg/embellishable.rb +6 -2
- data/lib/rvg/misc.rb +7 -7
- data/lib/rvg/rvg.rb +2 -0
- data/lib/rvg/stretchable.rb +2 -2
- data/lib/rvg/transformable.rb +1 -1
- data/rmagick.gemspec +4 -13
- data/sig/rmagick/_draw_common_methods.rbs +64 -0
- data/sig/rmagick/_image_common_methods.rbs +389 -0
- data/sig/rmagick/draw.rbs +38 -0
- data/sig/rmagick/draw_attribute.rbs +28 -0
- data/sig/rmagick/enum.rbs +814 -0
- data/sig/rmagick/error.rbs +11 -0
- data/sig/rmagick/fill.rbs +21 -0
- data/sig/rmagick/geometry.rbs +14 -0
- data/sig/rmagick/image.rbs +194 -0
- data/sig/rmagick/image_list.rbs +181 -0
- data/sig/rmagick/iptc.rbs +101 -0
- data/sig/rmagick/kernel_info.rbs +12 -0
- data/sig/rmagick/optional_method_arguments.rbs +10 -0
- data/sig/rmagick/pixel.rbs +46 -0
- data/sig/rmagick/struct.rbs +90 -0
- data/sig/rmagick.rbs +43 -0
- data/sig/rvg/clippath.rbs +34 -0
- data/sig/rvg/container.rbs +78 -0
- data/sig/rvg/deep_equal.rbs +48 -0
- data/sig/rvg/describable.rbs +30 -0
- data/sig/rvg/embellishable.rbs +226 -0
- data/sig/rvg/misc.rbs +145 -0
- data/sig/rvg/paint.rbs +55 -0
- data/sig/rvg/pathdata.rbs +77 -0
- data/sig/rvg/rvg.rbs +125 -0
- data/sig/rvg/stretchable.rbs +56 -0
- data/sig/rvg/stylable.rbs +66 -0
- data/sig/rvg/text.rbs +118 -0
- data/sig/rvg/transformable.rbs +59 -0
- data/sig/rvg/units.rbs +33 -0
- metadata +59 -129
- data/.codeclimate.yml +0 -63
- data/deprecated/RMagick.rb +0 -6
- data/ext/RMagick/rmmain.c +0 -1951
@@ -5,8 +5,8 @@
|
|
5
5
|
*
|
6
6
|
* Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
|
7
7
|
*
|
8
|
-
* @file rmpixel.
|
9
|
-
* @version $Id: rmpixel.
|
8
|
+
* @file rmpixel.cpp
|
9
|
+
* @version $Id: rmpixel.cpp,v 1.7 2009/12/21 10:34:58 baror Exp $
|
10
10
|
* @author Tim Hunter
|
11
11
|
******************************************************************************/
|
12
12
|
|
@@ -19,6 +19,15 @@
|
|
19
19
|
|
20
20
|
static VALUE color_arg_rescue(VALUE, VALUE ATTRIBUTE_UNUSED) ATTRIBUTE_NORETURN;
|
21
21
|
static void Color_Name_to_PixelColor(PixelColor *, VALUE);
|
22
|
+
static void Pixel_destroy(void *);
|
23
|
+
static size_t Pixel_memsize(const void *);
|
24
|
+
|
25
|
+
const rb_data_type_t rm_pixel_data_type = {
|
26
|
+
"Magick::Pixel",
|
27
|
+
{ NULL, Pixel_destroy, Pixel_memsize, },
|
28
|
+
0, 0,
|
29
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
30
|
+
};
|
22
31
|
|
23
32
|
|
24
33
|
/**
|
@@ -26,15 +35,30 @@ static void Color_Name_to_PixelColor(PixelColor *, VALUE);
|
|
26
35
|
*
|
27
36
|
* No Ruby usage (internal function)
|
28
37
|
*
|
29
|
-
* @param
|
38
|
+
* @param ptr the Pixel object to destroy
|
30
39
|
*/
|
31
|
-
void
|
32
|
-
|
40
|
+
static void
|
41
|
+
Pixel_destroy(void *ptr)
|
33
42
|
{
|
43
|
+
Pixel *pixel = (Pixel *)ptr;
|
34
44
|
xfree(pixel);
|
35
45
|
}
|
36
46
|
|
37
47
|
|
48
|
+
/**
|
49
|
+
* Get Pixel object size.
|
50
|
+
*
|
51
|
+
* No Ruby usage (internal function)
|
52
|
+
*
|
53
|
+
* @param ptr pointer to the Pixel object
|
54
|
+
*/
|
55
|
+
static size_t
|
56
|
+
Pixel_memsize(const void *ptr)
|
57
|
+
{
|
58
|
+
return sizeof(Pixel);
|
59
|
+
}
|
60
|
+
|
61
|
+
|
38
62
|
/**
|
39
63
|
* Get Pixel red value.
|
40
64
|
*
|
@@ -43,7 +67,7 @@ destroy_Pixel(Pixel *pixel)
|
|
43
67
|
VALUE
|
44
68
|
Pixel_red(VALUE self)
|
45
69
|
{
|
46
|
-
|
70
|
+
IMPLEMENT_TYPED_ATTR_READER(Pixel, red, int, &rm_pixel_data_type);
|
47
71
|
}
|
48
72
|
|
49
73
|
/**
|
@@ -54,7 +78,7 @@ Pixel_red(VALUE self)
|
|
54
78
|
VALUE
|
55
79
|
Pixel_green(VALUE self)
|
56
80
|
{
|
57
|
-
|
81
|
+
IMPLEMENT_TYPED_ATTR_READER(Pixel, green, int, &rm_pixel_data_type);
|
58
82
|
}
|
59
83
|
|
60
84
|
/**
|
@@ -65,7 +89,7 @@ Pixel_green(VALUE self)
|
|
65
89
|
VALUE
|
66
90
|
Pixel_blue(VALUE self)
|
67
91
|
{
|
68
|
-
|
92
|
+
IMPLEMENT_TYPED_ATTR_READER(Pixel, blue, int, &rm_pixel_data_type);
|
69
93
|
}
|
70
94
|
|
71
95
|
/**
|
@@ -77,7 +101,7 @@ VALUE
|
|
77
101
|
Pixel_alpha(VALUE self)
|
78
102
|
{
|
79
103
|
Pixel *pixel;
|
80
|
-
|
104
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
81
105
|
#if defined(IMAGEMAGICK_7)
|
82
106
|
return C_int_to_R_int(pixel->alpha);
|
83
107
|
#else
|
@@ -102,7 +126,7 @@ Pixel_red_eq(VALUE self, VALUE v)
|
|
102
126
|
Pixel *pixel;
|
103
127
|
|
104
128
|
rb_check_frozen(self);
|
105
|
-
|
129
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
106
130
|
pixel->red = APP2QUANTUM(v);
|
107
131
|
rb_funcall(self, rm_ID_changed, 0);
|
108
132
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -126,7 +150,7 @@ Pixel_green_eq(VALUE self, VALUE v)
|
|
126
150
|
Pixel *pixel;
|
127
151
|
|
128
152
|
rb_check_frozen(self);
|
129
|
-
|
153
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
130
154
|
pixel->green = APP2QUANTUM(v);
|
131
155
|
rb_funcall(self, rm_ID_changed, 0);
|
132
156
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -150,7 +174,7 @@ Pixel_blue_eq(VALUE self, VALUE v)
|
|
150
174
|
Pixel *pixel;
|
151
175
|
|
152
176
|
rb_check_frozen(self);
|
153
|
-
|
177
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
154
178
|
pixel->blue = APP2QUANTUM(v);
|
155
179
|
rb_funcall(self, rm_ID_changed, 0);
|
156
180
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -174,7 +198,7 @@ Pixel_alpha_eq(VALUE self, VALUE v)
|
|
174
198
|
Pixel *pixel;
|
175
199
|
|
176
200
|
rb_check_frozen(self);
|
177
|
-
|
201
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
178
202
|
#if defined(IMAGEMAGICK_7)
|
179
203
|
pixel->alpha = APP2QUANTUM(v);
|
180
204
|
rb_funcall(self, rm_ID_changed, 0);
|
@@ -198,7 +222,7 @@ Pixel_cyan(VALUE self)
|
|
198
222
|
{
|
199
223
|
Pixel *pixel;
|
200
224
|
|
201
|
-
|
225
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
202
226
|
return INT2NUM(pixel->red);
|
203
227
|
}
|
204
228
|
|
@@ -219,7 +243,7 @@ Pixel_cyan_eq(VALUE self, VALUE v)
|
|
219
243
|
Pixel *pixel;
|
220
244
|
|
221
245
|
rb_check_frozen(self);
|
222
|
-
|
246
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
223
247
|
pixel->red = APP2QUANTUM(v);
|
224
248
|
rb_funcall(self, rm_ID_changed, 0);
|
225
249
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -236,7 +260,7 @@ Pixel_magenta(VALUE self)
|
|
236
260
|
{
|
237
261
|
Pixel *pixel;
|
238
262
|
|
239
|
-
|
263
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
240
264
|
return INT2NUM(pixel->green);
|
241
265
|
}
|
242
266
|
|
@@ -257,7 +281,7 @@ Pixel_magenta_eq(VALUE self, VALUE v)
|
|
257
281
|
Pixel *pixel;
|
258
282
|
|
259
283
|
rb_check_frozen(self);
|
260
|
-
|
284
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
261
285
|
pixel->green = APP2QUANTUM(v);
|
262
286
|
rb_funcall(self, rm_ID_changed, 0);
|
263
287
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -274,7 +298,7 @@ Pixel_yellow(VALUE self)
|
|
274
298
|
{
|
275
299
|
Pixel *pixel;
|
276
300
|
|
277
|
-
|
301
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
278
302
|
return INT2NUM(pixel->blue);
|
279
303
|
}
|
280
304
|
|
@@ -295,7 +319,7 @@ Pixel_yellow_eq(VALUE self, VALUE v)
|
|
295
319
|
Pixel *pixel;
|
296
320
|
|
297
321
|
rb_check_frozen(self);
|
298
|
-
|
322
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
299
323
|
pixel->blue = APP2QUANTUM(v);
|
300
324
|
rb_funcall(self, rm_ID_changed, 0);
|
301
325
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -312,7 +336,7 @@ Pixel_black(VALUE self)
|
|
312
336
|
{
|
313
337
|
Pixel *pixel;
|
314
338
|
|
315
|
-
|
339
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
316
340
|
return INT2NUM(pixel->black);
|
317
341
|
}
|
318
342
|
|
@@ -333,7 +357,7 @@ Pixel_black_eq(VALUE self, VALUE v)
|
|
333
357
|
Pixel *pixel;
|
334
358
|
|
335
359
|
rb_check_frozen(self);
|
336
|
-
|
360
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
337
361
|
pixel->black = APP2QUANTUM(v);
|
338
362
|
rb_funcall(self, rm_ID_changed, 0);
|
339
363
|
rb_funcall(self, rm_ID_notify_observers, 1, self);
|
@@ -376,7 +400,7 @@ Color_to_PixelColor(PixelColor *pp, VALUE color)
|
|
376
400
|
if (CLASS_OF(color) == Class_Pixel)
|
377
401
|
{
|
378
402
|
memset(pp, 0, sizeof(*pp));
|
379
|
-
|
403
|
+
TypedData_Get_Struct(color, Pixel, &rm_pixel_data_type, pixel);
|
380
404
|
pp->red = pixel->red;
|
381
405
|
pp->green = pixel->green;
|
382
406
|
pp->blue = pixel->blue;
|
@@ -390,7 +414,7 @@ Color_to_PixelColor(PixelColor *pp, VALUE color)
|
|
390
414
|
else
|
391
415
|
{
|
392
416
|
// require 'to_str' here instead of just 'to_s'.
|
393
|
-
color = rb_rescue(rb_str_to_str, color, color_arg_rescue, color);
|
417
|
+
color = rb_rescue(RESCUE_FUNC(rb_str_to_str), color, RESCUE_EXCEPTION_HANDLER_FUNC(color_arg_rescue), color);
|
394
418
|
Color_Name_to_PixelColor(pp, color);
|
395
419
|
}
|
396
420
|
}
|
@@ -415,7 +439,7 @@ Color_to_Pixel(Pixel *pp, VALUE color)
|
|
415
439
|
{
|
416
440
|
Pixel *pixel;
|
417
441
|
|
418
|
-
|
442
|
+
TypedData_Get_Struct(color, Pixel, &rm_pixel_data_type, pixel);
|
419
443
|
memcpy(pp, pixel, sizeof(Pixel));
|
420
444
|
}
|
421
445
|
else
|
@@ -468,13 +492,13 @@ Color_Name_to_PixelColor(PixelColor *color, VALUE name_arg)
|
|
468
492
|
* @return [Magick::Pixel] a new Magick::Pixel object
|
469
493
|
*/
|
470
494
|
VALUE
|
471
|
-
Pixel_alloc(VALUE
|
495
|
+
Pixel_alloc(VALUE klass)
|
472
496
|
{
|
473
497
|
Pixel *pixel;
|
474
498
|
|
475
499
|
pixel = ALLOC(Pixel);
|
476
500
|
memset(pixel, '\0', sizeof(Pixel));
|
477
|
-
return
|
501
|
+
return TypedData_Wrap_Struct(klass, &rm_pixel_data_type, pixel);
|
478
502
|
}
|
479
503
|
|
480
504
|
|
@@ -490,17 +514,17 @@ Pixel_case_eq(VALUE self, VALUE other)
|
|
490
514
|
{
|
491
515
|
if (CLASS_OF(self) == CLASS_OF(other))
|
492
516
|
{
|
493
|
-
Pixel *
|
517
|
+
Pixel *self_pixel, *other_pixel;
|
494
518
|
|
495
|
-
|
496
|
-
|
497
|
-
return (
|
498
|
-
&&
|
499
|
-
&&
|
519
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, self_pixel);
|
520
|
+
TypedData_Get_Struct(other, Pixel, &rm_pixel_data_type, other_pixel);
|
521
|
+
return (self_pixel->red == other_pixel->red
|
522
|
+
&& self_pixel->blue == other_pixel->blue
|
523
|
+
&& self_pixel->green == other_pixel->green
|
500
524
|
#if defined(IMAGEMAGICK_7)
|
501
|
-
&&
|
525
|
+
&& self_pixel->alpha == other_pixel->alpha) ? Qtrue : Qfalse;
|
502
526
|
#else
|
503
|
-
&&
|
527
|
+
&& self_pixel->opacity == other_pixel->opacity) ? Qtrue : Qfalse;
|
504
528
|
#endif
|
505
529
|
}
|
506
530
|
|
@@ -547,7 +571,7 @@ Pixel_dup(VALUE self)
|
|
547
571
|
|
548
572
|
pixel = ALLOC(Pixel);
|
549
573
|
memset(pixel, '\0', sizeof(Pixel));
|
550
|
-
dup =
|
574
|
+
dup = TypedData_Wrap_Struct(CLASS_OF(self), &rm_pixel_data_type, pixel);
|
551
575
|
RB_GC_GUARD(dup);
|
552
576
|
|
553
577
|
return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
|
@@ -571,8 +595,8 @@ Pixel_eql_q(VALUE self, VALUE other)
|
|
571
595
|
* Compare pixel values for equality.
|
572
596
|
*
|
573
597
|
* @overload fcmp(other, fuzz = 0.0, colorspace = Magick::RGBColorspace)
|
574
|
-
* @param other [Magick::Pixel] The pixel to which the receiver is compared
|
575
|
-
* @param fuzz [
|
598
|
+
* @param other [Magick::Pixel, String] The pixel to which the receiver is compared
|
599
|
+
* @param fuzz [Numeric] The amount of fuzz to allow before the colors are considered to be different
|
576
600
|
* @param colorspace [Magick::ColorspaceType] The colorspace
|
577
601
|
* @return [Boolean] true if equal, otherwise false
|
578
602
|
*/
|
@@ -582,7 +606,7 @@ Pixel_fcmp(int argc, VALUE *argv, VALUE self)
|
|
582
606
|
double fuzz = 0.0;
|
583
607
|
unsigned int equal;
|
584
608
|
ColorspaceType colorspace = RGBColorspace;
|
585
|
-
PixelColor
|
609
|
+
PixelColor self_pixel_color, other_pixel_color;
|
586
610
|
#if defined(IMAGEMAGICK_6)
|
587
611
|
Image *image;
|
588
612
|
Info *info;
|
@@ -602,15 +626,15 @@ Pixel_fcmp(int argc, VALUE *argv, VALUE self)
|
|
602
626
|
break;
|
603
627
|
}
|
604
628
|
|
605
|
-
Color_to_PixelColor(&
|
606
|
-
Color_to_PixelColor(&
|
629
|
+
Color_to_PixelColor(&self_pixel_color, self);
|
630
|
+
Color_to_PixelColor(&other_pixel_color, argv[0]);
|
607
631
|
|
608
632
|
#if defined(IMAGEMAGICK_7)
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
equal = IsFuzzyEquivalencePixelInfo(&
|
633
|
+
self_pixel_color.fuzz = fuzz;
|
634
|
+
self_pixel_color.colorspace = colorspace;
|
635
|
+
other_pixel_color.fuzz = fuzz;
|
636
|
+
other_pixel_color.colorspace = colorspace;
|
637
|
+
equal = IsFuzzyEquivalencePixelInfo(&self_pixel_color, &other_pixel_color);
|
614
638
|
#else
|
615
639
|
// The IsColorSimilar function expects to get the
|
616
640
|
// colorspace and fuzz parameters from an Image structure.
|
@@ -634,7 +658,7 @@ Pixel_fcmp(int argc, VALUE *argv, VALUE self)
|
|
634
658
|
image->colorspace = colorspace;
|
635
659
|
image->fuzz = fuzz;
|
636
660
|
|
637
|
-
equal = IsColorSimilar(image, &
|
661
|
+
equal = IsColorSimilar(image, &self_pixel_color, &other_pixel_color);
|
638
662
|
DestroyImage(image);
|
639
663
|
#endif
|
640
664
|
|
@@ -655,7 +679,7 @@ Pixel_fcmp(int argc, VALUE *argv, VALUE self)
|
|
655
679
|
* @see Magick::Pixel#to_color
|
656
680
|
*/
|
657
681
|
VALUE
|
658
|
-
Pixel_from_color(VALUE
|
682
|
+
Pixel_from_color(VALUE klass ATTRIBUTE_UNUSED, VALUE name)
|
659
683
|
{
|
660
684
|
PixelColor pp;
|
661
685
|
ExceptionInfo *exception;
|
@@ -687,11 +711,11 @@ Pixel_from_color(VALUE class ATTRIBUTE_UNUSED, VALUE name)
|
|
687
711
|
* @param hue [Numeric, String] A value in the range.
|
688
712
|
* @param saturation [Numeric, String] A value in the range.
|
689
713
|
* @param lightness [Numeric, String] A value in the range.
|
690
|
-
* @param alpha [Numeric] The alpha value.
|
714
|
+
* @param alpha [Numeric, String] The alpha value.
|
691
715
|
* @return [Magick::Pixel] a new Magick::Pixel object
|
692
716
|
*/
|
693
717
|
VALUE
|
694
|
-
Pixel_from_hsla(int argc, VALUE *argv, VALUE
|
718
|
+
Pixel_from_hsla(int argc, VALUE *argv, VALUE klass ATTRIBUTE_UNUSED)
|
695
719
|
{
|
696
720
|
double h, s, l, a = 1.0;
|
697
721
|
MagickPixel pp;
|
@@ -785,7 +809,7 @@ Pixel_from_MagickPixel(const MagickPixel *pp)
|
|
785
809
|
#endif
|
786
810
|
pixel->black = pp->index;
|
787
811
|
|
788
|
-
return
|
812
|
+
return TypedData_Wrap_Struct(Class_Pixel, &rm_pixel_data_type, pixel);
|
789
813
|
}
|
790
814
|
|
791
815
|
|
@@ -817,7 +841,7 @@ Pixel_from_PixelPacket(const PixelPacket *pp)
|
|
817
841
|
pixel->black = 0;
|
818
842
|
#endif
|
819
843
|
|
820
|
-
return
|
844
|
+
return TypedData_Wrap_Struct(Class_Pixel, &rm_pixel_data_type, pixel);
|
821
845
|
}
|
822
846
|
|
823
847
|
|
@@ -849,7 +873,7 @@ Pixel_from_PixelColor(const PixelColor *pp)
|
|
849
873
|
pixel->black = 0;
|
850
874
|
#endif
|
851
875
|
|
852
|
-
return
|
876
|
+
return TypedData_Wrap_Struct(Class_Pixel, &rm_pixel_data_type, pixel);
|
853
877
|
}
|
854
878
|
|
855
879
|
|
@@ -864,7 +888,7 @@ Pixel_hash(VALUE self)
|
|
864
888
|
Pixel *pixel;
|
865
889
|
unsigned int hash;
|
866
890
|
|
867
|
-
|
891
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
868
892
|
|
869
893
|
hash = ScaleQuantumToChar(pixel->red) << 24;
|
870
894
|
hash += ScaleQuantumToChar(pixel->green) << 16;
|
@@ -892,8 +916,8 @@ Pixel_init_copy(VALUE self, VALUE orig)
|
|
892
916
|
{
|
893
917
|
Pixel *copy, *original;
|
894
918
|
|
895
|
-
|
896
|
-
|
919
|
+
TypedData_Get_Struct(orig, Pixel, &rm_pixel_data_type, original);
|
920
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, copy);
|
897
921
|
|
898
922
|
*copy = *original;
|
899
923
|
|
@@ -916,7 +940,7 @@ Pixel_initialize(int argc, VALUE *argv, VALUE self)
|
|
916
940
|
{
|
917
941
|
Pixel *pixel;
|
918
942
|
|
919
|
-
|
943
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
920
944
|
|
921
945
|
#if defined(IMAGEMAGICK_7)
|
922
946
|
pixel->alpha = OpaqueAlpha;
|
@@ -972,7 +996,7 @@ Pixel_intensity(VALUE self)
|
|
972
996
|
Pixel *pixel;
|
973
997
|
Quantum intensity;
|
974
998
|
|
975
|
-
|
999
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
976
1000
|
|
977
1001
|
intensity = ROUND_TO_QUANTUM((0.299*pixel->red)
|
978
1002
|
+ (0.587*pixel->green)
|
@@ -993,7 +1017,7 @@ Pixel_marshal_dump(VALUE self)
|
|
993
1017
|
Pixel *pixel;
|
994
1018
|
VALUE dpixel;
|
995
1019
|
|
996
|
-
|
1020
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
997
1021
|
dpixel = rb_hash_new();
|
998
1022
|
rb_hash_aset(dpixel, CSTR2SYM("red"), QUANTUM2NUM(pixel->red));
|
999
1023
|
rb_hash_aset(dpixel, CSTR2SYM("green"), QUANTUM2NUM(pixel->green));
|
@@ -1021,7 +1045,7 @@ Pixel_marshal_load(VALUE self, VALUE dpixel)
|
|
1021
1045
|
{
|
1022
1046
|
Pixel *pixel;
|
1023
1047
|
|
1024
|
-
|
1048
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1025
1049
|
pixel->red = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("red")));
|
1026
1050
|
pixel->green = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("green")));
|
1027
1051
|
pixel->blue = NUM2QUANTUM(rb_hash_aref(dpixel, CSTR2SYM("blue")));
|
@@ -1043,39 +1067,41 @@ Pixel_marshal_load(VALUE self, VALUE dpixel)
|
|
1043
1067
|
VALUE
|
1044
1068
|
Pixel_spaceship(VALUE self, VALUE other)
|
1045
1069
|
{
|
1046
|
-
Pixel *
|
1070
|
+
Pixel *self_pixel, *other_pixel;
|
1071
|
+
|
1072
|
+
if (CLASS_OF(self) != CLASS_OF(other)) {
|
1073
|
+
return Qnil;
|
1074
|
+
}
|
1047
1075
|
|
1048
|
-
|
1049
|
-
|
1076
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, self_pixel);
|
1077
|
+
TypedData_Get_Struct(other, Pixel, &rm_pixel_data_type, other_pixel);
|
1050
1078
|
|
1051
|
-
if (
|
1079
|
+
if (self_pixel->red != other_pixel->red)
|
1052
1080
|
{
|
1053
|
-
return INT2NUM((
|
1081
|
+
return INT2NUM((self_pixel->red - other_pixel->red)/abs((int)(self_pixel->red - other_pixel->red)));
|
1054
1082
|
}
|
1055
|
-
else if(
|
1083
|
+
else if(self_pixel->green != other_pixel->green)
|
1056
1084
|
{
|
1057
|
-
return INT2NUM((
|
1085
|
+
return INT2NUM((self_pixel->green - other_pixel->green)/abs((int)(self_pixel->green - other_pixel->green)));
|
1058
1086
|
}
|
1059
|
-
else if(
|
1087
|
+
else if(self_pixel->blue != other_pixel->blue)
|
1060
1088
|
{
|
1061
|
-
return INT2NUM((
|
1089
|
+
return INT2NUM((self_pixel->blue - other_pixel->blue)/abs((int)(self_pixel->blue - other_pixel->blue)));
|
1062
1090
|
}
|
1063
1091
|
#if defined(IMAGEMAGICK_7)
|
1064
|
-
else if(
|
1092
|
+
else if(self_pixel->alpha != other_pixel->alpha)
|
1065
1093
|
{
|
1066
|
-
return INT2NUM((
|
1094
|
+
return INT2NUM((self_pixel->alpha - other_pixel->alpha)/abs((int)(self_pixel->alpha - other_pixel->alpha)));
|
1067
1095
|
}
|
1068
1096
|
#else
|
1069
|
-
else if(
|
1097
|
+
else if(self_pixel->opacity != other_pixel->opacity)
|
1070
1098
|
{
|
1071
|
-
return INT2NUM(((QuantumRange -
|
1099
|
+
return INT2NUM(((QuantumRange - self_pixel->opacity) - (QuantumRange - other_pixel->opacity))/abs((int)((QuantumRange - self_pixel->opacity) - (QuantumRange - other_pixel->opacity))));
|
1072
1100
|
}
|
1073
1101
|
#endif
|
1074
1102
|
|
1075
|
-
// Values are equal
|
1076
|
-
|
1077
|
-
return rb_funcall(CLASS_OF(self), rb_intern("<=>"), 1, CLASS_OF(other));
|
1078
|
-
|
1103
|
+
// Values are equal.
|
1104
|
+
return INT2NUM(0);
|
1079
1105
|
}
|
1080
1106
|
|
1081
1107
|
|
@@ -1093,7 +1119,7 @@ Pixel_to_hsla(VALUE self)
|
|
1093
1119
|
Pixel *pixel;
|
1094
1120
|
VALUE hsla;
|
1095
1121
|
|
1096
|
-
|
1122
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1097
1123
|
|
1098
1124
|
ConvertRGBToHSL(pixel->red, pixel->green, pixel->blue, &hue, &sat, &lum);
|
1099
1125
|
hue *= 360.0;
|
@@ -1183,13 +1209,13 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
|
|
1183
1209
|
char name[MaxTextExtent];
|
1184
1210
|
ExceptionInfo *exception;
|
1185
1211
|
ComplianceType compliance = AllCompliance;
|
1186
|
-
|
1212
|
+
MagickBooleanType alpha = MagickFalse;
|
1187
1213
|
unsigned int depth = MAGICKCORE_QUANTUM_DEPTH;
|
1188
1214
|
|
1189
1215
|
switch (argc)
|
1190
1216
|
{
|
1191
1217
|
case 4:
|
1192
|
-
hex = RTEST(argv[3]);
|
1218
|
+
hex = (MagickBooleanType)RTEST(argv[3]);
|
1193
1219
|
case 3:
|
1194
1220
|
depth = NUM2UINT(argv[2]);
|
1195
1221
|
|
@@ -1209,7 +1235,7 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
|
|
1209
1235
|
break;
|
1210
1236
|
}
|
1211
1237
|
case 2:
|
1212
|
-
alpha = RTEST(argv[1]);
|
1238
|
+
alpha = (MagickBooleanType)RTEST(argv[1]);
|
1213
1239
|
case 1:
|
1214
1240
|
VALUE_TO_ENUM(argv[0], compliance, ComplianceType);
|
1215
1241
|
case 0:
|
@@ -1218,7 +1244,7 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
|
|
1218
1244
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
|
1219
1245
|
}
|
1220
1246
|
|
1221
|
-
|
1247
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1222
1248
|
|
1223
1249
|
info = CloneImageInfo(NULL);
|
1224
1250
|
image = rm_acquire_image(info);
|
@@ -1284,7 +1310,7 @@ Pixel_to_s(VALUE self)
|
|
1284
1310
|
Pixel *pixel;
|
1285
1311
|
char buff[100];
|
1286
1312
|
|
1287
|
-
|
1313
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1288
1314
|
snprintf(buff, sizeof(buff), "red=" QuantumFormat ", green=" QuantumFormat ", blue=" QuantumFormat ", alpha=" QuantumFormat,
|
1289
1315
|
pixel->red, pixel->green, pixel->blue,
|
1290
1316
|
#if defined(IMAGEMAGICK_7)
|
@@ -1294,4 +1320,3 @@ Pixel_to_s(VALUE self)
|
|
1294
1320
|
#endif
|
1295
1321
|
return rb_str_new2(buff);
|
1296
1322
|
}
|
1297
|
-
|
@@ -5,8 +5,8 @@
|
|
5
5
|
*
|
6
6
|
* Changes since Nov. 2009 copyright © by Benjamin Thomas and Omer Bar-or
|
7
7
|
*
|
8
|
-
* @file rmstruct.
|
9
|
-
* @version $Id: rmstruct.
|
8
|
+
* @file rmstruct.cpp
|
9
|
+
* @version $Id: rmstruct.cpp,v 1.5 2009/12/20 02:33:34 baror Exp $
|
10
10
|
* @author Tim Hunter
|
11
11
|
******************************************************************************/
|
12
12
|
|
@@ -456,8 +456,8 @@ Export_TypeInfo(TypeInfo *ti, VALUE st)
|
|
456
456
|
{
|
457
457
|
CloneString((char **)&(ti->family), StringValueCStr(m));
|
458
458
|
}
|
459
|
-
m = rb_ary_entry(members, 3); ti->style = m == Qnil ?
|
460
|
-
m = rb_ary_entry(members, 4); ti->stretch = m == Qnil ?
|
459
|
+
m = rb_ary_entry(members, 3); ti->style = m == Qnil ? UndefinedStyle : (StyleType)FIX2INT(Enum_to_i(m));
|
460
|
+
m = rb_ary_entry(members, 4); ti->stretch = m == Qnil ? UndefinedStretch : (StretchType)FIX2INT(Enum_to_i(m));
|
461
461
|
m = rb_ary_entry(members, 5); ti->weight = m == Qnil ? 0 : FIX2INT(m);
|
462
462
|
|
463
463
|
m = rb_ary_entry(members, 6);
|
@@ -524,7 +524,7 @@ Font_to_s(VALUE self)
|
|
524
524
|
strcpy(weight, "BoldWeight");
|
525
525
|
break;
|
526
526
|
default:
|
527
|
-
snprintf(weight, sizeof(weight), "%"RMIuSIZE"", ti.weight);
|
527
|
+
snprintf(weight, sizeof(weight), "%" RMIuSIZE "", ti.weight);
|
528
528
|
break;
|
529
529
|
}
|
530
530
|
|
@@ -732,7 +732,7 @@ RectangleInfo_to_s(VALUE self)
|
|
732
732
|
char buff[100];
|
733
733
|
|
734
734
|
Export_RectangleInfo(&rect, self);
|
735
|
-
snprintf(buff, sizeof(buff), "width=%"RMIuSIZE", height=%"RMIuSIZE", x=%"RMIdSIZE", y=%"RMIdSIZE"",
|
735
|
+
snprintf(buff, sizeof(buff), "width=%" RMIuSIZE ", height=%" RMIuSIZE ", x=%" RMIdSIZE ", y=%" RMIdSIZE "",
|
736
736
|
rect.width, rect.height, rect.x, rect.y);
|
737
737
|
return rb_str_new2(buff);
|
738
738
|
}
|