rmagick 4.2.2 → 5.3.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/Dockerfile +14 -0
- data/.devcontainer/ImageMagick6/devcontainer.json +11 -0
- data/.devcontainer/devcontainer.json +11 -0
- data/.devcontainer/setup-repo.sh +10 -0
- data/.devcontainer/setup-user.sh +45 -0
- data/.github/workflows/ci.yml +55 -24
- data/.gitignore +2 -0
- data/.rubocop_todo.yml +0 -1
- data/CHANGELOG.md +93 -0
- data/README.md +8 -16
- data/Rakefile +53 -81
- data/before_install_linux.sh +4 -4
- data/before_install_osx.sh +7 -6
- data/ext/RMagick/extconf.rb +81 -37
- data/ext/RMagick/rmagick.h +29 -20
- data/ext/RMagick/rmagick_gvl.h +224 -0
- data/ext/RMagick/rmdraw.c +140 -127
- data/ext/RMagick/rmenum.c +34 -15
- data/ext/RMagick/rmfill.c +77 -16
- data/ext/RMagick/rmilist.c +163 -74
- data/ext/RMagick/rmimage.c +1130 -630
- data/ext/RMagick/rminfo.c +109 -121
- data/ext/RMagick/rmkinfo.c +43 -13
- data/ext/RMagick/rmmain.c +15 -11
- data/ext/RMagick/rmmontage.c +45 -24
- data/ext/RMagick/rmpixel.c +66 -42
- data/ext/RMagick/rmstruct.c +6 -6
- data/ext/RMagick/rmutil.c +29 -88
- data/lib/rmagick/version.rb +3 -1
- data/lib/rmagick.rb +2 -0
- data/lib/rmagick_internal.rb +9 -48
- data/lib/rvg/rvg.rb +2 -2
- data/rmagick.gemspec +6 -6
- metadata +25 -8
- data/.codeclimate.yml +0 -63
- data/deprecated/RMagick.rb +0 -6
data/ext/RMagick/rmpixel.c
CHANGED
@@ -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);
|
@@ -172,9 +196,9 @@ VALUE
|
|
172
196
|
Pixel_alpha_eq(VALUE self, VALUE v)
|
173
197
|
{
|
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,13 +400,13 @@ 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;
|
383
407
|
#if defined(IMAGEMAGICK_7)
|
384
|
-
pp->alpha = pixel->alpha;
|
385
408
|
pp->black = pixel->black;
|
409
|
+
rm_set_pixelinfo_alpha(pp, pixel->alpha);
|
386
410
|
#else
|
387
411
|
pp->opacity = pixel->opacity;
|
388
412
|
#endif
|
@@ -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
|
@@ -474,7 +498,7 @@ Pixel_alloc(VALUE class)
|
|
474
498
|
|
475
499
|
pixel = ALLOC(Pixel);
|
476
500
|
memset(pixel, '\0', sizeof(Pixel));
|
477
|
-
return
|
501
|
+
return TypedData_Wrap_Struct(class, &rm_pixel_data_type, pixel);
|
478
502
|
}
|
479
503
|
|
480
504
|
|
@@ -492,8 +516,8 @@ Pixel_case_eq(VALUE self, VALUE other)
|
|
492
516
|
{
|
493
517
|
Pixel *this, *that;
|
494
518
|
|
495
|
-
|
496
|
-
|
519
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, this);
|
520
|
+
TypedData_Get_Struct(other, Pixel, &rm_pixel_data_type, that);
|
497
521
|
return (this->red == that->red
|
498
522
|
&& this->blue == that->blue
|
499
523
|
&& this->green == that->green
|
@@ -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);
|
@@ -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")));
|
@@ -1045,8 +1069,8 @@ Pixel_spaceship(VALUE self, VALUE other)
|
|
1045
1069
|
{
|
1046
1070
|
Pixel *this, *that;
|
1047
1071
|
|
1048
|
-
|
1049
|
-
|
1072
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, this);
|
1073
|
+
TypedData_Get_Struct(other, Pixel, &rm_pixel_data_type, that);
|
1050
1074
|
|
1051
1075
|
if (this->red != that->red)
|
1052
1076
|
{
|
@@ -1093,7 +1117,7 @@ Pixel_to_hsla(VALUE self)
|
|
1093
1117
|
Pixel *pixel;
|
1094
1118
|
VALUE hsla;
|
1095
1119
|
|
1096
|
-
|
1120
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1097
1121
|
|
1098
1122
|
ConvertRGBToHSL(pixel->red, pixel->green, pixel->blue, &hue, &sat, &lum);
|
1099
1123
|
hue *= 360.0;
|
@@ -1218,7 +1242,7 @@ Pixel_to_color(int argc, VALUE *argv, VALUE self)
|
|
1218
1242
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
|
1219
1243
|
}
|
1220
1244
|
|
1221
|
-
|
1245
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1222
1246
|
|
1223
1247
|
info = CloneImageInfo(NULL);
|
1224
1248
|
image = rm_acquire_image(info);
|
@@ -1284,7 +1308,7 @@ Pixel_to_s(VALUE self)
|
|
1284
1308
|
Pixel *pixel;
|
1285
1309
|
char buff[100];
|
1286
1310
|
|
1287
|
-
|
1311
|
+
TypedData_Get_Struct(self, Pixel, &rm_pixel_data_type, pixel);
|
1288
1312
|
snprintf(buff, sizeof(buff), "red=" QuantumFormat ", green=" QuantumFormat ", blue=" QuantumFormat ", alpha=" QuantumFormat,
|
1289
1313
|
pixel->red, pixel->green, pixel->blue,
|
1290
1314
|
#if defined(IMAGEMAGICK_7)
|
data/ext/RMagick/rmstruct.c
CHANGED
@@ -285,7 +285,7 @@ Export_ColorInfo(ColorInfo *ci, VALUE st)
|
|
285
285
|
ci->color.green = (MagickRealType) pixel.green;
|
286
286
|
ci->color.blue = (MagickRealType) pixel.blue;
|
287
287
|
#if defined(IMAGEMAGICK_7)
|
288
|
-
ci->color
|
288
|
+
rm_set_pixelinfo_alpha(&ci->color, (MagickRealType) OpaqueAlpha);
|
289
289
|
#else
|
290
290
|
ci->color.opacity = (MagickRealType) OpaqueOpacity;
|
291
291
|
#endif
|
@@ -672,10 +672,10 @@ Import_RectangleInfo(RectangleInfo *rect)
|
|
672
672
|
VALUE height;
|
673
673
|
VALUE x, y;
|
674
674
|
|
675
|
-
width =
|
676
|
-
height =
|
677
|
-
x =
|
678
|
-
y =
|
675
|
+
width = ULONG2NUM(rect->width);
|
676
|
+
height = ULONG2NUM(rect->height);
|
677
|
+
x = LONG2NUM(rect->x);
|
678
|
+
y = LONG2NUM(rect->y);
|
679
679
|
|
680
680
|
RB_GC_GUARD(width);
|
681
681
|
RB_GC_GUARD(height);
|
@@ -760,7 +760,7 @@ Import_SegmentInfo(SegmentInfo *segment)
|
|
760
760
|
RB_GC_GUARD(y1);
|
761
761
|
RB_GC_GUARD(x2);
|
762
762
|
RB_GC_GUARD(y2);
|
763
|
-
|
763
|
+
|
764
764
|
return rb_funcall(Class_Segment, rm_ID_new, 4, x1, y1, x2, y2);
|
765
765
|
}
|
766
766
|
|
data/ext/RMagick/rmutil.c
CHANGED
@@ -22,6 +22,9 @@ static VALUE rescue_not_str(VALUE, VALUE ATTRIBUTE_UNUSED) ATTRIBUTE_NORETURN;
|
|
22
22
|
static void handle_exception(ExceptionInfo *, Image *, ErrorRetention);
|
23
23
|
|
24
24
|
|
25
|
+
DEFINE_GVL_STUB5(CloneImage, const Image *, const size_t, const size_t, const MagickBooleanType, ExceptionInfo *);
|
26
|
+
|
27
|
+
|
25
28
|
/**
|
26
29
|
* ImageMagick safe version of malloc.
|
27
30
|
*
|
@@ -269,7 +272,7 @@ rm_check_destroyed(VALUE obj)
|
|
269
272
|
{
|
270
273
|
Image *image;
|
271
274
|
|
272
|
-
|
275
|
+
TypedData_Get_Struct(obj, Image, &rm_image_data_type, image);
|
273
276
|
if (!image)
|
274
277
|
{
|
275
278
|
rb_raise(Class_DestroyedImageError, "destroyed image");
|
@@ -780,7 +783,7 @@ rm_write_temp_image(Image *image, char *temp_name, size_t temp_name_l)
|
|
780
783
|
snprintf(temp_name, temp_name_l, "mpri:%d", id);
|
781
784
|
|
782
785
|
// Omit "mpri:" from filename to form the key
|
783
|
-
okay = SetImageRegistry(ImageRegistryType, temp_name+5, image, exception);
|
786
|
+
okay = (MagickBooleanType)SetImageRegistry(ImageRegistryType, temp_name+5, image, exception);
|
784
787
|
CHECK_EXCEPTION();
|
785
788
|
DestroyExceptionInfo(exception);
|
786
789
|
if (!okay)
|
@@ -858,6 +861,25 @@ rm_magick_error(const char *msg)
|
|
858
861
|
RB_GC_GUARD(mesg);
|
859
862
|
}
|
860
863
|
|
864
|
+
#if defined(IMAGEMAGICK_7)
|
865
|
+
/**
|
866
|
+
* Sets the alpha channel of a pixel color
|
867
|
+
*
|
868
|
+
* No Ruby usage (internal function)
|
869
|
+
*
|
870
|
+
* @param pixel the Pixel
|
871
|
+
* @param value the value
|
872
|
+
*/
|
873
|
+
void
|
874
|
+
rm_set_pixelinfo_alpha(PixelInfo *pixel, const MagickRealType value)
|
875
|
+
{
|
876
|
+
pixel->alpha = value;
|
877
|
+
if (value != (MagickRealType) OpaqueAlpha)
|
878
|
+
{
|
879
|
+
pixel->alpha_trait = BlendPixelTrait;
|
880
|
+
}
|
881
|
+
}
|
882
|
+
#endif
|
861
883
|
|
862
884
|
/**
|
863
885
|
* Initialize a new ImageMagickError object - store the "loc" string in the
|
@@ -1006,14 +1028,7 @@ rm_get_optional_arguments(VALUE img)
|
|
1006
1028
|
argv[0] = img;
|
1007
1029
|
opt_args = rb_class_new_instance(1, argv, optional_method_arguments);
|
1008
1030
|
|
1009
|
-
|
1010
|
-
{
|
1011
|
-
rb_obj_instance_eval(0, NULL, opt_args);
|
1012
|
-
}
|
1013
|
-
else
|
1014
|
-
{
|
1015
|
-
rb_yield(opt_args);
|
1016
|
-
}
|
1031
|
+
rb_yield(opt_args);
|
1017
1032
|
}
|
1018
1033
|
|
1019
1034
|
RB_GC_GUARD(optional_method_arguments);
|
@@ -1253,7 +1268,7 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1253
1268
|
/**
|
1254
1269
|
* Replicate old (ImageMagick < 6.3.2) EXIF:* functionality using
|
1255
1270
|
* GetImageProperty by returning the exif entries as a single string, separated
|
1256
|
-
* by \n's. Do this so that RMagick
|
1271
|
+
* by \n's. Do this so that RMagick works no matter which version of
|
1257
1272
|
* ImageMagick is in use.
|
1258
1273
|
*
|
1259
1274
|
* No Ruby usage (internal function)
|
@@ -1372,7 +1387,7 @@ rm_exif_by_entry(Image *image)
|
|
1372
1387
|
/**
|
1373
1388
|
* Replicate old (ImageMagick < 6.3.2) EXIF:! functionality using
|
1374
1389
|
* GetImageProperty by returning the exif entries as a single string, separated
|
1375
|
-
* by \n's. Do this so that RMagick
|
1390
|
+
* by \n's. Do this so that RMagick works no matter which version of
|
1376
1391
|
* ImageMagick is in use.
|
1377
1392
|
*
|
1378
1393
|
* No Ruby usage (internal function)
|
@@ -1506,7 +1521,8 @@ rm_clone_image(Image *image)
|
|
1506
1521
|
ExceptionInfo *exception;
|
1507
1522
|
|
1508
1523
|
exception = AcquireExceptionInfo();
|
1509
|
-
|
1524
|
+
GVL_STRUCT_TYPE(CloneImage) args = { image, 0, 0, MagickTrue, exception };
|
1525
|
+
clone = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CloneImage), &args);
|
1510
1526
|
if (!clone)
|
1511
1527
|
{
|
1512
1528
|
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
@@ -1518,64 +1534,6 @@ rm_clone_image(Image *image)
|
|
1518
1534
|
}
|
1519
1535
|
|
1520
1536
|
|
1521
|
-
/**
|
1522
|
-
* SetImage(Info)ProgressMonitor exit.
|
1523
|
-
*
|
1524
|
-
* No Ruby usage (internal function)
|
1525
|
-
*
|
1526
|
-
* Notes:
|
1527
|
-
* - ImageMagick's "tag" argument is unused. We pass along the method name
|
1528
|
-
* instead.
|
1529
|
-
*
|
1530
|
-
* @param tag ImageMagick argument (unused)
|
1531
|
-
* @param of the offset type
|
1532
|
-
* @param sp the size type
|
1533
|
-
* @param client_data pointer to the progress method to call
|
1534
|
-
* @return true if calling client_data returns a non-nil value, otherwise false
|
1535
|
-
*/
|
1536
|
-
MagickBooleanType
|
1537
|
-
rm_progress_monitor(
|
1538
|
-
const char *tag ATTRIBUTE_UNUSED,
|
1539
|
-
const MagickOffsetType of,
|
1540
|
-
const MagickSizeType sp,
|
1541
|
-
void *client_data)
|
1542
|
-
{
|
1543
|
-
VALUE rval;
|
1544
|
-
VALUE method, offset, span;
|
1545
|
-
|
1546
|
-
// Check running thread.
|
1547
|
-
if (rm_current_thread_id() != rm_main_thread_id)
|
1548
|
-
{
|
1549
|
-
// ImageMagick might call back in a different thread than Ruby is running in.
|
1550
|
-
// If it is a different thread, it would not have a Ruby GVL and
|
1551
|
-
// it could not retrieve properly Ruby stack.
|
1552
|
-
|
1553
|
-
// Unfortunately, there is no API available to check if the current thread has a GVL,
|
1554
|
-
// so the thread id was checked in here.
|
1555
|
-
return MagickTrue;
|
1556
|
-
}
|
1557
|
-
|
1558
|
-
#if defined(HAVE_LONG_LONG) // defined in Ruby's defines.h
|
1559
|
-
offset = rb_ll2inum(of);
|
1560
|
-
span = rb_ull2inum(sp);
|
1561
|
-
#else
|
1562
|
-
offset = rb_int2big((long)of);
|
1563
|
-
span = rb_uint2big((unsigned long)sp);
|
1564
|
-
#endif
|
1565
|
-
|
1566
|
-
method = rb_id2str(rb_frame_this_func());
|
1567
|
-
|
1568
|
-
rval = rb_funcall((VALUE)client_data, rm_ID_call, 3, method, offset, span);
|
1569
|
-
|
1570
|
-
RB_GC_GUARD(rval);
|
1571
|
-
RB_GC_GUARD(method);
|
1572
|
-
RB_GC_GUARD(offset);
|
1573
|
-
RB_GC_GUARD(span);
|
1574
|
-
|
1575
|
-
return RTEST(rval) ? MagickTrue : MagickFalse;
|
1576
|
-
}
|
1577
|
-
|
1578
|
-
|
1579
1537
|
/**
|
1580
1538
|
* Remove the ImageMagick links between images in an scene sequence.
|
1581
1539
|
*
|
@@ -1881,20 +1839,3 @@ rm_raise_exception(ExceptionInfo *exception)
|
|
1881
1839
|
|
1882
1840
|
rm_magick_error(msg);
|
1883
1841
|
}
|
1884
|
-
|
1885
|
-
/**
|
1886
|
-
* Get current thread id.
|
1887
|
-
*
|
1888
|
-
* No Ruby usage (internal function)
|
1889
|
-
*
|
1890
|
-
* @return thread id
|
1891
|
-
*/
|
1892
|
-
unsigned long long
|
1893
|
-
rm_current_thread_id()
|
1894
|
-
{
|
1895
|
-
#if defined(_WIN32)
|
1896
|
-
return (unsigned long long)GetCurrentThreadId();
|
1897
|
-
#else
|
1898
|
-
return (unsigned long long)pthread_self();
|
1899
|
-
#endif
|
1900
|
-
}
|
data/lib/rmagick/version.rb
CHANGED
data/lib/rmagick.rb
CHANGED
data/lib/rmagick_internal.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# $Id: RMagick.rb,v 1.84 2009/09/15 22:08:41 rmagick Exp $
|
2
4
|
#==============================================================================
|
3
5
|
# Copyright (C) 2009 by Timothy P. Hunter
|
@@ -12,7 +14,7 @@ if RUBY_PLATFORM =~ /mingw/i
|
|
12
14
|
begin
|
13
15
|
require 'ruby_installer'
|
14
16
|
ENV['PATH'].split(File::PATH_SEPARATOR).grep(/ImageMagick/i).each do |path|
|
15
|
-
RubyInstaller::Runtime.add_dll_directory(path)
|
17
|
+
RubyInstaller::Runtime.add_dll_directory(path) if File.exist?(File.join(path, 'CORE_RL_magick_.dll')) || File.exist?(File.join(path, 'CORE_RL_MagickCore_.dll'))
|
16
18
|
end
|
17
19
|
rescue LoadError
|
18
20
|
end
|
@@ -23,9 +25,6 @@ require 'observer'
|
|
23
25
|
require 'RMagick2.so'
|
24
26
|
|
25
27
|
module Magick
|
26
|
-
@formats = nil
|
27
|
-
@trace_proc = nil
|
28
|
-
@exit_block_set_up = nil
|
29
28
|
IMAGEMAGICK_VERSION = Magick::Magick_version.split[1].split('-').first
|
30
29
|
|
31
30
|
class << self
|
@@ -53,45 +52,13 @@ module Magick
|
|
53
52
|
# => {"3FR"=>" r-+", "3G2"=>" r-+", "3GP"=>" r-+", "A"=>"*rw+",
|
54
53
|
# ...
|
55
54
|
def formats
|
56
|
-
|
55
|
+
formats = init_formats
|
57
56
|
|
58
57
|
if block_given?
|
59
|
-
|
58
|
+
formats.each { |k, v| yield k, v }
|
60
59
|
self
|
61
60
|
else
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# If the Magick module attribute +trace_proc+ is set to a Proc object,
|
67
|
-
# RMagick calls the proc whenever an image is created or destroyed.
|
68
|
-
#
|
69
|
-
# You can use this proc to keep track of which images your program has created
|
70
|
-
# and which have been destroyed.
|
71
|
-
#
|
72
|
-
# @param p [Proc] The proc object.
|
73
|
-
# The following value will be passed into the proc object.
|
74
|
-
# - +which+ - A symbol that indicates which operation the proc is being called for.
|
75
|
-
# If the proc is called for an image creation, the value is +:c+.
|
76
|
-
# If called for an image destruction, the value is +:d+.
|
77
|
-
# - +description+ - A string describing the image. This is the same string that
|
78
|
-
# would be returned by calling the image's inspect method.
|
79
|
-
# - +id+ - A unique identifier for the image. This identifier is not the same as the object's +object_id+.
|
80
|
-
# - +method+ - The name of the method responsible for creating or destroying the image.
|
81
|
-
#
|
82
|
-
# @example
|
83
|
-
# Magick.trace_proc = proc do |which, description, id, method|
|
84
|
-
# ...
|
85
|
-
# end
|
86
|
-
def trace_proc=(p)
|
87
|
-
m = Mutex.new
|
88
|
-
m.synchronize do
|
89
|
-
if @trace_proc.nil? && !p.nil? && !@exit_block_set_up
|
90
|
-
at_exit { @trace_proc = nil }
|
91
|
-
@exit_block_set_up = true
|
92
|
-
end
|
93
|
-
|
94
|
-
@trace_proc = p
|
61
|
+
formats
|
95
62
|
end
|
96
63
|
end
|
97
64
|
end
|
@@ -109,7 +76,7 @@ module Magick
|
|
109
76
|
MinimumGeometry = GeometryValue.new(:MinimumGeometry, 6).freeze
|
110
77
|
|
111
78
|
class Geometry
|
112
|
-
FLAGS = ['', '%', '!', '<', '>', '@', '^']
|
79
|
+
FLAGS = ['', '%', '!', '<', '>', '@', '^'].freeze
|
113
80
|
RFLAGS = {
|
114
81
|
'%' => PercentGeometry,
|
115
82
|
'!' => AspectGeometry,
|
@@ -117,7 +84,7 @@ module Magick
|
|
117
84
|
'>' => GreaterGeometry,
|
118
85
|
'@' => AreaGeometry,
|
119
86
|
'^' => MinimumGeometry
|
120
|
-
}
|
87
|
+
}.freeze
|
121
88
|
|
122
89
|
attr_accessor :width, :height, :x, :y, :flag
|
123
90
|
|
@@ -173,7 +140,7 @@ module Magick
|
|
173
140
|
|
174
141
|
# Convert object to a geometry string
|
175
142
|
def to_s
|
176
|
-
str =
|
143
|
+
str = String.new
|
177
144
|
if @width > 0
|
178
145
|
fmt = @width.truncate == @width ? '%d' : '%.2f'
|
179
146
|
str << sprintf(fmt, @width)
|
@@ -804,12 +771,6 @@ module Magick
|
|
804
771
|
module Post_ObjectData_Descriptor
|
805
772
|
Confirmed_ObjectData_Size = '9:10'
|
806
773
|
end
|
807
|
-
|
808
|
-
# Make all constants above immutable
|
809
|
-
constants.each do |record|
|
810
|
-
rec = const_get(record)
|
811
|
-
rec.constants.each { |ds| rec.const_get(ds).freeze }
|
812
|
-
end
|
813
774
|
end # module Magick::IPTC
|
814
775
|
|
815
776
|
# Ruby-level Magick::Image methods
|