rmagick 2.13.4 → 2.16.0
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.
- checksums.yaml +4 -4
- data/.editorconfig +14 -0
- data/.hound.yml +2 -0
- data/.rspec +1 -0
- data/.rubocop.yml +340 -0
- data/.simplecov +27 -0
- data/.travis.yml +29 -12
- data/CHANGELOG.md +915 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +31 -3
- data/Gemfile +3 -0
- data/README.textile +94 -4
- data/Rakefile +57 -45
- data/before_install_linux.sh +26 -6
- data/deprecated/RMagick.rb +6 -0
- data/doc/comtasks.html +1 -1
- data/doc/draw.html +7 -4
- data/doc/ex/InitialCoords.rb +16 -17
- data/doc/ex/NewCoordSys.rb +21 -23
- data/doc/ex/OrigCoordSys.rb +8 -10
- data/doc/ex/PreserveAspectRatio.rb +182 -183
- data/doc/ex/RotateScale.rb +27 -28
- data/doc/ex/Skew.rb +27 -27
- data/doc/ex/Use01.rb +7 -8
- data/doc/ex/Use02.rb +11 -12
- data/doc/ex/Use03.rb +7 -7
- data/doc/ex/ViewBox.rb +16 -18
- data/doc/ex/adaptive_threshold.rb +4 -5
- data/doc/ex/add_noise.rb +4 -5
- data/doc/ex/affine.rb +4 -4
- data/doc/ex/affine_transform.rb +4 -4
- data/doc/ex/arc.rb +10 -10
- data/doc/ex/arcpath.rb +7 -8
- data/doc/ex/arcs01.rb +10 -10
- data/doc/ex/arcs02.rb +36 -38
- data/doc/ex/average.rb +5 -5
- data/doc/ex/axes.rb +4 -4
- data/doc/ex/baseline_shift01.rb +11 -12
- data/doc/ex/bilevel_channel.rb +2 -3
- data/doc/ex/blur_image.rb +2 -2
- data/doc/ex/border.rb +2 -2
- data/doc/ex/bounding_box.rb +9 -11
- data/doc/ex/cbezier1.rb +3 -4
- data/doc/ex/cbezier2.rb +3 -4
- data/doc/ex/cbezier3.rb +3 -4
- data/doc/ex/cbezier4.rb +3 -4
- data/doc/ex/cbezier5.rb +2 -3
- data/doc/ex/cbezier6.rb +3 -3
- data/doc/ex/channel.rb +10 -11
- data/doc/ex/charcoal.rb +2 -2
- data/doc/ex/chop.rb +2 -2
- data/doc/ex/circle.rb +3 -3
- data/doc/ex/circle01.rb +6 -7
- data/doc/ex/clip_path.rb +12 -12
- data/doc/ex/coalesce.rb +32 -35
- data/doc/ex/color_fill_to_border.rb +6 -6
- data/doc/ex/color_floodfill.rb +2 -2
- data/doc/ex/color_histogram.rb +17 -18
- data/doc/ex/color_reset.rb +2 -2
- data/doc/ex/colorize.rb +2 -2
- data/doc/ex/colors.rb +30 -30
- data/doc/ex/compose_mask.rb +8 -9
- data/doc/ex/composite.rb +14 -16
- data/doc/ex/composite_layers.rb +15 -15
- data/doc/ex/composite_tiled.rb +5 -7
- data/doc/ex/contrast.rb +12 -12
- data/doc/ex/crop.rb +3 -3
- data/doc/ex/crop_with_gravity.rb +13 -17
- data/doc/ex/cubic01.rb +18 -20
- data/doc/ex/cubic02.rb +64 -67
- data/doc/ex/cycle_colormap.rb +2 -2
- data/doc/ex/dissolve.rb +2 -3
- data/doc/ex/drawcomp.rb +34 -34
- data/doc/ex/drop_shadow.rb +8 -8
- data/doc/ex/edge.rb +2 -2
- data/doc/ex/ellipse.rb +4 -4
- data/doc/ex/ellipse01.rb +10 -11
- data/doc/ex/emboss.rb +2 -2
- data/doc/ex/enhance.rb +2 -2
- data/doc/ex/equalize.rb +2 -2
- data/doc/ex/evenodd.rb +31 -32
- data/doc/ex/fill_pattern.rb +12 -15
- data/doc/ex/flatten_images.rb +13 -13
- data/doc/ex/flip.rb +2 -2
- data/doc/ex/flop.rb +2 -2
- data/doc/ex/font_styles.rb +21 -23
- data/doc/ex/fonts.rb +14 -14
- data/doc/ex/frame.rb +3 -3
- data/doc/ex/gaussian_blur.rb +2 -2
- data/doc/ex/get_multiline_type_metrics.rb +6 -7
- data/doc/ex/get_pixels.rb +13 -14
- data/doc/ex/get_type_metrics.rb +26 -31
- data/doc/ex/gradientfill.rb +12 -12
- data/doc/ex/grav.rb +4 -5
- data/doc/ex/gravity.rb +61 -60
- data/doc/ex/group.rb +16 -16
- data/doc/ex/hatchfill.rb +10 -10
- data/doc/ex/image.rb +29 -31
- data/doc/ex/implode.rb +17 -17
- data/doc/ex/level.rb +2 -2
- data/doc/ex/level_colors.rb +4 -4
- data/doc/ex/line.rb +4 -5
- data/doc/ex/line01.rb +11 -13
- data/doc/ex/mask.rb +7 -8
- data/doc/ex/matte_fill_to_border.rb +2 -3
- data/doc/ex/matte_floodfill.rb +2 -3
- data/doc/ex/matte_replace.rb +2 -3
- data/doc/ex/median_filter.rb +2 -2
- data/doc/ex/modulate.rb +2 -2
- data/doc/ex/mono.rb +4 -4
- data/doc/ex/morph.rb +7 -8
- data/doc/ex/mosaic.rb +15 -15
- data/doc/ex/motion_blur.rb +2 -2
- data/doc/ex/negate.rb +2 -2
- data/doc/ex/negate_channel.rb +2 -2
- data/doc/ex/nested_rvg.rb +11 -11
- data/doc/ex/nonzero.rb +31 -32
- data/doc/ex/normalize.rb +2 -2
- data/doc/ex/oil_paint.rb +2 -2
- data/doc/ex/opacity.rb +3 -3
- data/doc/ex/ordered_dither.rb +2 -2
- data/doc/ex/path.rb +4 -5
- data/doc/ex/pattern1.rb +10 -10
- data/doc/ex/pattern2.rb +7 -7
- data/doc/ex/polaroid.rb +13 -14
- data/doc/ex/polygon.rb +6 -7
- data/doc/ex/polygon01.rb +10 -12
- data/doc/ex/polyline.rb +4 -5
- data/doc/ex/polyline01.rb +11 -13
- data/doc/ex/posterize.rb +2 -2
- data/doc/ex/preview.rb +3 -4
- data/doc/ex/qbezierpath.rb +5 -5
- data/doc/ex/quad01.rb +23 -25
- data/doc/ex/quantize-m.rb +5 -5
- data/doc/ex/radial_blur.rb +2 -2
- data/doc/ex/raise.rb +2 -2
- data/doc/ex/random_threshold_channel.rb +2 -2
- data/doc/ex/rect01.rb +6 -7
- data/doc/ex/rect02.rb +9 -11
- data/doc/ex/rectangle.rb +3 -4
- data/doc/ex/reduce_noise.rb +2 -2
- data/doc/ex/remap.rb +7 -8
- data/doc/ex/remap_images.rb +9 -11
- data/doc/ex/resize_to_fill.rb +3 -5
- data/doc/ex/resize_to_fit.rb +3 -5
- data/doc/ex/roll.rb +2 -2
- data/doc/ex/rotate.rb +6 -7
- data/doc/ex/rotate_f.rb +2 -2
- data/doc/ex/roundrect.rb +4 -5
- data/doc/ex/rubyname.rb +11 -11
- data/doc/ex/rvg_clippath.rb +5 -7
- data/doc/ex/rvg_linecap.rb +25 -26
- data/doc/ex/rvg_linejoin.rb +25 -26
- data/doc/ex/rvg_opacity.rb +10 -11
- data/doc/ex/rvg_pattern.rb +15 -15
- data/doc/ex/rvg_stroke_dasharray.rb +6 -7
- data/doc/ex/segment.rb +2 -2
- data/doc/ex/sepiatone.rb +2 -3
- data/doc/ex/shade.rb +2 -2
- data/doc/ex/shadow.rb +2 -3
- data/doc/ex/shave.rb +2 -2
- data/doc/ex/shear.rb +3 -3
- data/doc/ex/sketch.rb +2 -3
- data/doc/ex/skewx.rb +4 -5
- data/doc/ex/skewy.rb +3 -3
- data/doc/ex/smile.rb +113 -113
- data/doc/ex/solarize.rb +2 -2
- data/doc/ex/sparse_color.rb +29 -30
- data/doc/ex/splice.rb +2 -3
- data/doc/ex/spread.rb +2 -2
- data/doc/ex/stegano.rb +34 -34
- data/doc/ex/stroke_dasharray.rb +4 -5
- data/doc/ex/stroke_fill.rb +4 -5
- data/doc/ex/stroke_linecap.rb +3 -3
- data/doc/ex/stroke_linejoin.rb +3 -3
- data/doc/ex/stroke_width.rb +3 -3
- data/doc/ex/swirl.rb +2 -2
- data/doc/ex/text.rb +4 -4
- data/doc/ex/text01.rb +7 -8
- data/doc/ex/text_align.rb +2 -2
- data/doc/ex/text_antialias.rb +9 -10
- data/doc/ex/text_styles.rb +11 -13
- data/doc/ex/text_undercolor.rb +2 -2
- data/doc/ex/texture_fill_to_border.rb +6 -6
- data/doc/ex/texture_floodfill.rb +2 -2
- data/doc/ex/texturefill.rb +10 -11
- data/doc/ex/threshold.rb +2 -2
- data/doc/ex/to_blob.rb +4 -5
- data/doc/ex/translate.rb +6 -6
- data/doc/ex/transparent.rb +5 -5
- data/doc/ex/transpose.rb +2 -2
- data/doc/ex/transverse.rb +2 -2
- data/doc/ex/tref01.rb +11 -12
- data/doc/ex/triangle01.rb +5 -6
- data/doc/ex/trim.rb +1 -2
- data/doc/ex/tspan01.rb +8 -9
- data/doc/ex/tspan02.rb +9 -11
- data/doc/ex/tspan03.rb +9 -11
- data/doc/ex/unsharp_mask.rb +2 -2
- data/doc/ex/viewex.rb +19 -21
- data/doc/ex/vignette.rb +2 -2
- data/doc/ex/watermark.rb +15 -16
- data/doc/ex/wave.rb +2 -2
- data/doc/ex/wet_floor.rb +17 -18
- data/doc/ex/writing_mode01.rb +8 -9
- data/doc/ex/writing_mode02.rb +8 -8
- data/doc/ilist.html +1 -1
- data/doc/usage.html +8 -8
- data/examples/constitute.rb +6 -6
- data/examples/crop_with_gravity.rb +13 -17
- data/examples/demo.rb +305 -305
- data/examples/describe.rb +27 -28
- data/examples/find_similar_region.rb +16 -16
- data/examples/histogram.rb +228 -232
- data/examples/identify.rb +165 -167
- data/examples/image_opacity.rb +4 -4
- data/examples/import_export.rb +10 -10
- data/examples/pattern_fill.rb +9 -9
- data/examples/rotating_text.rb +13 -14
- data/examples/spinner.rb +18 -19
- data/examples/thumbnail.rb +13 -14
- data/examples/vignette.rb +8 -9
- data/ext/RMagick/extconf.rb +489 -367
- data/ext/RMagick/rmagick.c +11 -4
- data/ext/RMagick/rmagick.h +4 -0
- data/ext/RMagick/rmdraw.c +49 -18
- data/ext/RMagick/rmenum.c +18 -7
- data/ext/RMagick/rmfill.c +4 -1
- data/ext/RMagick/rmilist.c +49 -13
- data/ext/RMagick/rmimage.c +196 -59
- data/ext/RMagick/rminfo.c +33 -10
- data/ext/RMagick/rmmain.c +18 -6
- data/ext/RMagick/rmmontage.c +12 -4
- data/ext/RMagick/rmpixel.c +18 -5
- data/ext/RMagick/rmstruct.c +108 -31
- data/ext/RMagick/rmutil.c +50 -26
- data/lib/rmagick/version.rb +4 -3
- data/lib/rmagick_internal.rb +1159 -1176
- data/lib/rvg/clippath.rb +36 -39
- data/lib/rvg/container.rb +115 -124
- data/lib/rvg/deep_equal.rb +46 -50
- data/lib/rvg/describable.rb +41 -47
- data/lib/rvg/embellishable.rb +384 -410
- data/lib/rvg/misc.rb +697 -714
- data/lib/rvg/paint.rb +42 -47
- data/lib/rvg/pathdata.rb +120 -125
- data/lib/rvg/rvg.rb +213 -213
- data/lib/rvg/stretchable.rb +159 -162
- data/lib/rvg/stylable.rb +109 -117
- data/lib/rvg/text.rb +9 -24
- data/lib/rvg/transformable.rb +120 -127
- data/lib/rvg/units.rb +58 -61
- data/rmagick.gemspec +46 -15
- data/spec/rmagick/ImageList1_spec.rb +24 -0
- data/spec/rmagick/draw_spec.rb +156 -0
- data/spec/rmagick/image/blue_shift_spec.rb +16 -0
- data/spec/rmagick/image/composite_spec.rb +140 -0
- data/spec/rmagick/image/constitute_spec.rb +15 -0
- data/spec/rmagick/image/dispatch_spec.rb +18 -0
- data/spec/rmagick/image/from_blob_spec.rb +14 -0
- data/spec/rmagick/image/ping_spec.rb +14 -0
- data/spec/rmagick/image/properties_spec.rb +29 -0
- data/spec/spec_helper.rb +4 -0
- data/test/Image1.rb +529 -727
- data/test/Image2.rb +1291 -1299
- data/test/Image3.rb +978 -981
- data/test/ImageList1.rb +7 -9
- data/test/ImageList2.rb +346 -350
- data/test/Image_attributes.rb +683 -686
- data/test/Import_Export.rb +25 -30
- data/test/Info.rb +339 -343
- data/test/Magick.rb +250 -253
- data/test/Pixel.rb +107 -110
- data/test/Preview.rb +48 -53
- data/test/test_all_basic.rb +15 -11
- data/test/tmpnam_test.rb +3 -3
- data/wercker.yml +10 -0
- metadata +77 -10
- data/ChangeLog +0 -816
- data/lib/RMagick.rb +0 -1
- data/test/Draw.rb +0 -121
data/ext/RMagick/rmagick.c
CHANGED
@@ -34,7 +34,7 @@ Magick_colors(VALUE class)
|
|
34
34
|
{
|
35
35
|
const ColorInfo **color_info_list;
|
36
36
|
size_t number_colors, x;
|
37
|
-
|
37
|
+
VALUE ary;
|
38
38
|
ExceptionInfo *exception;
|
39
39
|
|
40
40
|
exception = AcquireExceptionInfo();
|
@@ -62,6 +62,7 @@ Magick_colors(VALUE class)
|
|
62
62
|
}
|
63
63
|
|
64
64
|
magick_free((void *)color_info_list);
|
65
|
+
RB_GC_GUARD(ary);
|
65
66
|
return ary;
|
66
67
|
}
|
67
68
|
}
|
@@ -83,7 +84,7 @@ Magick_fonts(VALUE class)
|
|
83
84
|
{
|
84
85
|
const TypeInfo **type_info;
|
85
86
|
size_t number_types, x;
|
86
|
-
|
87
|
+
VALUE ary;
|
87
88
|
ExceptionInfo *exception;
|
88
89
|
|
89
90
|
exception = AcquireExceptionInfo();
|
@@ -108,6 +109,7 @@ Magick_fonts(VALUE class)
|
|
108
109
|
(void) rb_ary_push(ary, Import_TypeInfo((const TypeInfo *)type_info[x]));
|
109
110
|
}
|
110
111
|
magick_free((void *)type_info);
|
112
|
+
RB_GC_GUARD(ary);
|
111
113
|
return ary;
|
112
114
|
}
|
113
115
|
|
@@ -167,7 +169,7 @@ Magick_init_formats(VALUE class)
|
|
167
169
|
{
|
168
170
|
const MagickInfo **magick_info;
|
169
171
|
size_t number_formats, x;
|
170
|
-
|
172
|
+
VALUE formats;
|
171
173
|
ExceptionInfo *exception;
|
172
174
|
|
173
175
|
class = class; // defeat "never referenced" message from icc
|
@@ -186,6 +188,7 @@ Magick_init_formats(VALUE class)
|
|
186
188
|
, rb_str_new2(magick_info[x]->name)
|
187
189
|
, MagickInfo_to_format((const MagickInfo *)magick_info[x]));
|
188
190
|
}
|
191
|
+
RB_GC_GUARD(formats);
|
189
192
|
return formats;
|
190
193
|
}
|
191
194
|
|
@@ -206,7 +209,7 @@ Magick_init_formats(VALUE class)
|
|
206
209
|
VALUE
|
207
210
|
Magick_limit_resource(int argc, VALUE *argv, VALUE class)
|
208
211
|
{
|
209
|
-
|
212
|
+
VALUE resource, limit;
|
210
213
|
ResourceType res = UndefinedResource;
|
211
214
|
char *str;
|
212
215
|
ID id;
|
@@ -280,6 +283,8 @@ Magick_limit_resource(int argc, VALUE *argv, VALUE class)
|
|
280
283
|
break;
|
281
284
|
}
|
282
285
|
|
286
|
+
RB_GC_GUARD(resource);
|
287
|
+
|
283
288
|
cur_limit = GetMagickResourceLimit(res);
|
284
289
|
|
285
290
|
if (argc > 1)
|
@@ -287,6 +292,8 @@ Magick_limit_resource(int argc, VALUE *argv, VALUE class)
|
|
287
292
|
(void) SetMagickResourceLimit(res, (MagickSizeType)NUM2ULONG(limit));
|
288
293
|
}
|
289
294
|
|
295
|
+
RB_GC_GUARD(limit);
|
296
|
+
|
290
297
|
return ULONG2NUM(cur_limit);
|
291
298
|
}
|
292
299
|
|
data/ext/RMagick/rmagick.h
CHANGED
@@ -139,6 +139,10 @@
|
|
139
139
|
#define RARRAY_PTR(a) RARRAY((a))->ptr /**< Ruby array pointer */
|
140
140
|
#endif
|
141
141
|
|
142
|
+
// Backport this macro to 1.8.6
|
143
|
+
#if !defined(RB_GC_GUARD)
|
144
|
+
#define RB_GC_GUARD(x) (x)
|
145
|
+
#endif
|
142
146
|
|
143
147
|
//! Convert a C string to a Ruby symbol. Used in marshal_dump/marshal_load methods
|
144
148
|
#define CSTR2SYM(s) ID2SYM(rb_intern(s))
|
data/ext/RMagick/rmdraw.c
CHANGED
@@ -497,7 +497,7 @@ Draw_interword_spacing_eq(VALUE self, VALUE spacing)
|
|
497
497
|
static VALUE
|
498
498
|
image_to_str(Image *image)
|
499
499
|
{
|
500
|
-
|
500
|
+
VALUE dimg = Qnil;
|
501
501
|
unsigned char *blob;
|
502
502
|
size_t length;
|
503
503
|
Info *info;
|
@@ -515,6 +515,8 @@ image_to_str(Image *image)
|
|
515
515
|
magick_free((void*)blob);
|
516
516
|
}
|
517
517
|
|
518
|
+
RB_GC_GUARD(dimg);
|
519
|
+
|
518
520
|
return dimg;
|
519
521
|
}
|
520
522
|
|
@@ -664,7 +666,7 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
|
|
664
666
|
{
|
665
667
|
Draw *draw;
|
666
668
|
Pixel *pixel;
|
667
|
-
|
669
|
+
VALUE val;
|
668
670
|
|
669
671
|
Data_Get_Struct(self, Draw, draw);
|
670
672
|
|
@@ -725,6 +727,8 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
|
|
725
727
|
|
726
728
|
draw->primitives = rb_hash_aref(ddraw, CSTR2SYM("primitives"));
|
727
729
|
|
730
|
+
RB_GC_GUARD(val);
|
731
|
+
|
728
732
|
return self;
|
729
733
|
}
|
730
734
|
|
@@ -1051,7 +1055,7 @@ VALUE Draw_annotate(
|
|
1051
1055
|
VALUE
|
1052
1056
|
Draw_clone(VALUE self)
|
1053
1057
|
{
|
1054
|
-
|
1058
|
+
VALUE clone;
|
1055
1059
|
|
1056
1060
|
clone = Draw_dup(self);
|
1057
1061
|
if (OBJ_FROZEN(self))
|
@@ -1059,6 +1063,8 @@ Draw_clone(VALUE self)
|
|
1059
1063
|
OBJ_FREEZE(clone);
|
1060
1064
|
}
|
1061
1065
|
|
1066
|
+
RB_GC_GUARD(clone);
|
1067
|
+
|
1062
1068
|
return clone;
|
1063
1069
|
}
|
1064
1070
|
|
@@ -1087,7 +1093,7 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
1087
1093
|
const char *op = "Over";
|
1088
1094
|
double x, y, width, height;
|
1089
1095
|
CompositeOperator cop = OverCompositeOp;
|
1090
|
-
|
1096
|
+
VALUE image;
|
1091
1097
|
Image *comp_img;
|
1092
1098
|
struct TmpFile_Name *tmpfile_name;
|
1093
1099
|
char name[MaxTextExtent];
|
@@ -1339,6 +1345,8 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
1339
1345
|
// Send "primitive" to self.
|
1340
1346
|
(void) rb_funcall(self, rb_intern("primitive"), 1, rb_str_new2(primitive));
|
1341
1347
|
|
1348
|
+
RB_GC_GUARD(image);
|
1349
|
+
|
1342
1350
|
return self;
|
1343
1351
|
}
|
1344
1352
|
|
@@ -1399,7 +1407,7 @@ VALUE
|
|
1399
1407
|
Draw_dup(VALUE self)
|
1400
1408
|
{
|
1401
1409
|
Draw *draw;
|
1402
|
-
|
1410
|
+
VALUE dup;
|
1403
1411
|
|
1404
1412
|
draw = ALLOC(Draw);
|
1405
1413
|
memset(draw, 0, sizeof(Draw));
|
@@ -1408,6 +1416,9 @@ Draw_dup(VALUE self)
|
|
1408
1416
|
{
|
1409
1417
|
(void)rb_obj_taint(dup);
|
1410
1418
|
}
|
1419
|
+
|
1420
|
+
RB_GC_GUARD(dup);
|
1421
|
+
|
1411
1422
|
return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
|
1412
1423
|
}
|
1413
1424
|
|
@@ -1513,7 +1524,7 @@ VALUE
|
|
1513
1524
|
Draw_initialize(VALUE self)
|
1514
1525
|
{
|
1515
1526
|
Draw *draw, *draw_options;
|
1516
|
-
|
1527
|
+
VALUE options;
|
1517
1528
|
|
1518
1529
|
Data_Get_Struct(self, Draw, draw);
|
1519
1530
|
|
@@ -1522,6 +1533,8 @@ Draw_initialize(VALUE self)
|
|
1522
1533
|
draw->info = draw_options->info;
|
1523
1534
|
draw_options->info = NULL;
|
1524
1535
|
|
1536
|
+
RB_GC_GUARD(options);
|
1537
|
+
|
1525
1538
|
return self;
|
1526
1539
|
}
|
1527
1540
|
|
@@ -1560,12 +1573,14 @@ Draw_inspect(VALUE self)
|
|
1560
1573
|
VALUE Draw_alloc(VALUE class)
|
1561
1574
|
{
|
1562
1575
|
Draw *draw;
|
1563
|
-
|
1576
|
+
VALUE draw_obj;
|
1564
1577
|
|
1565
1578
|
draw = ALLOC(Draw);
|
1566
1579
|
memset(draw, 0, sizeof(Draw));
|
1567
1580
|
draw_obj = Data_Wrap_Struct(class, mark_Draw, destroy_Draw, draw);
|
1568
1581
|
|
1582
|
+
RB_GC_GUARD(draw_obj);
|
1583
|
+
|
1569
1584
|
return draw_obj;
|
1570
1585
|
}
|
1571
1586
|
|
@@ -1685,12 +1700,14 @@ VALUE
|
|
1685
1700
|
DrawOptions_alloc(VALUE class)
|
1686
1701
|
{
|
1687
1702
|
Draw *draw_options;
|
1688
|
-
|
1703
|
+
VALUE draw_options_obj;
|
1689
1704
|
|
1690
1705
|
draw_options = ALLOC(Draw);
|
1691
1706
|
memset(draw_options, 0, sizeof(Draw));
|
1692
1707
|
draw_options_obj = Data_Wrap_Struct(class, mark_Draw, destroy_Draw, draw_options);
|
1693
1708
|
|
1709
|
+
RB_GC_GUARD(draw_options_obj);
|
1710
|
+
|
1694
1711
|
return draw_options_obj;
|
1695
1712
|
}
|
1696
1713
|
|
@@ -1745,7 +1762,7 @@ DrawOptions_initialize(VALUE self)
|
|
1745
1762
|
VALUE
|
1746
1763
|
PolaroidOptions_alloc(VALUE class)
|
1747
1764
|
{
|
1748
|
-
|
1765
|
+
VALUE polaroid_obj;
|
1749
1766
|
ImageInfo *image_info;
|
1750
1767
|
Draw *draw;
|
1751
1768
|
|
@@ -1759,6 +1776,8 @@ PolaroidOptions_alloc(VALUE class)
|
|
1759
1776
|
|
1760
1777
|
polaroid_obj = Data_Wrap_Struct(class, NULL, destroy_Draw, draw);
|
1761
1778
|
|
1779
|
+
RB_GC_GUARD(polaroid_obj);
|
1780
|
+
|
1762
1781
|
return polaroid_obj;
|
1763
1782
|
}
|
1764
1783
|
|
@@ -1863,7 +1882,7 @@ static VALUE
|
|
1863
1882
|
get_dummy_tm_img(VALUE klass)
|
1864
1883
|
{
|
1865
1884
|
#define DUMMY_IMG_CLASS_VAR "@@_dummy_img_"
|
1866
|
-
|
1885
|
+
VALUE dummy_img = 0;
|
1867
1886
|
Info *info;
|
1868
1887
|
Image *image;
|
1869
1888
|
|
@@ -1887,6 +1906,8 @@ get_dummy_tm_img(VALUE klass)
|
|
1887
1906
|
}
|
1888
1907
|
dummy_img = rb_cv_get(klass, DUMMY_IMG_CLASS_VAR);
|
1889
1908
|
|
1909
|
+
RB_GC_GUARD(dummy_img);
|
1910
|
+
|
1890
1911
|
return dummy_img;
|
1891
1912
|
}
|
1892
1913
|
|
@@ -1918,7 +1939,7 @@ get_type_metrics(
|
|
1918
1939
|
#define ATTRS_L ((int)(sizeof(attrs)-1))
|
1919
1940
|
Image *image;
|
1920
1941
|
Draw *draw;
|
1921
|
-
|
1942
|
+
VALUE t;
|
1922
1943
|
TypeMetric metrics;
|
1923
1944
|
char *text = NULL;
|
1924
1945
|
long text_l;
|
@@ -1930,21 +1951,28 @@ get_type_metrics(
|
|
1930
1951
|
case 1: // use default image
|
1931
1952
|
text = rm_str2cstr(argv[0], &text_l);
|
1932
1953
|
|
1933
|
-
for (x = 0; x < text_l; x++)
|
1954
|
+
for (x = 0; x < text_l-1; x++)
|
1934
1955
|
{
|
1935
1956
|
// Ensure text string doesn't refer to image attributes.
|
1936
|
-
if (text[x] == '%'
|
1957
|
+
if (text[x] == '%')
|
1937
1958
|
{
|
1938
1959
|
int y;
|
1939
1960
|
char spec = text[x+1];
|
1940
1961
|
|
1941
|
-
|
1962
|
+
if (spec == '%')
|
1942
1963
|
{
|
1943
|
-
|
1964
|
+
x++;
|
1965
|
+
}
|
1966
|
+
else
|
1967
|
+
{
|
1968
|
+
for (y = 0; y < ATTRS_L; y++)
|
1944
1969
|
{
|
1945
|
-
|
1946
|
-
|
1947
|
-
|
1970
|
+
if (spec == attrs[y])
|
1971
|
+
{
|
1972
|
+
rb_raise(rb_eArgError,
|
1973
|
+
"text string contains image attribute reference `%%%c'",
|
1974
|
+
spec);
|
1975
|
+
}
|
1948
1976
|
}
|
1949
1977
|
}
|
1950
1978
|
}
|
@@ -1987,5 +2015,8 @@ get_type_metrics(
|
|
1987
2015
|
rb_raise(rb_eRuntimeError, "Can't measure text. Are the fonts installed? "
|
1988
2016
|
"Is the FreeType library installed?");
|
1989
2017
|
}
|
2018
|
+
|
2019
|
+
RB_GC_GUARD(t);
|
2020
|
+
|
1990
2021
|
return Import_TypeMetric(&metrics);
|
1991
2022
|
}
|
data/ext/RMagick/rmenum.c
CHANGED
@@ -78,10 +78,13 @@ VALUE
|
|
78
78
|
Enum_alloc(VALUE class)
|
79
79
|
{
|
80
80
|
MagickEnum *magick_enum;
|
81
|
-
|
81
|
+
VALUE enumr;
|
82
82
|
|
83
83
|
enumr = Data_Make_Struct(class, MagickEnum, NULL, NULL, magick_enum);
|
84
84
|
rb_obj_freeze(enumr);
|
85
|
+
|
86
|
+
RB_GC_GUARD(enumr);
|
87
|
+
|
85
88
|
return enumr;
|
86
89
|
}
|
87
90
|
|
@@ -176,6 +179,10 @@ Enum_spaceship(VALUE self, VALUE other)
|
|
176
179
|
{
|
177
180
|
MagickEnum *this, *that;
|
178
181
|
|
182
|
+
if(CLASS_OF(self) != CLASS_OF(other)) {
|
183
|
+
return Qnil;
|
184
|
+
}
|
185
|
+
|
179
186
|
Data_Get_Struct(self, MagickEnum, this);
|
180
187
|
Data_Get_Struct(other, MagickEnum, that);
|
181
188
|
|
@@ -188,9 +195,7 @@ Enum_spaceship(VALUE self, VALUE other)
|
|
188
195
|
return INT2FIX(-1);
|
189
196
|
}
|
190
197
|
|
191
|
-
|
192
|
-
|
193
|
-
return rb_funcall(CLASS_OF(self), rm_ID_spaceship, 1, CLASS_OF(other));
|
198
|
+
return INT2FIX(0);
|
194
199
|
}
|
195
200
|
|
196
201
|
|
@@ -228,7 +233,7 @@ VALUE
|
|
228
233
|
Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
|
229
234
|
{
|
230
235
|
VALUE super_argv[2];
|
231
|
-
|
236
|
+
VALUE enumerators;
|
232
237
|
|
233
238
|
super_argv[0] = sym;
|
234
239
|
super_argv[1] = val;
|
@@ -242,6 +247,8 @@ Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
|
|
242
247
|
enumerators = rb_cv_get(CLASS_OF(self), ENUMERATORS_CLASS_VAR);
|
243
248
|
(void) rb_ary_push(enumerators, self);
|
244
249
|
|
250
|
+
RB_GC_GUARD(enumerators);
|
251
|
+
|
245
252
|
return self;
|
246
253
|
}
|
247
254
|
|
@@ -284,8 +291,8 @@ Enum_type_inspect(VALUE self)
|
|
284
291
|
static VALUE
|
285
292
|
Enum_type_values(VALUE class)
|
286
293
|
{
|
287
|
-
|
288
|
-
|
294
|
+
VALUE enumerators, copy;
|
295
|
+
VALUE rv;
|
289
296
|
int x;
|
290
297
|
|
291
298
|
enumerators = rb_cv_get(class, ENUMERATORS_CLASS_VAR);
|
@@ -309,6 +316,10 @@ Enum_type_values(VALUE class)
|
|
309
316
|
rv = copy;
|
310
317
|
}
|
311
318
|
|
319
|
+
RB_GC_GUARD(enumerators);
|
320
|
+
RB_GC_GUARD(copy);
|
321
|
+
RB_GC_GUARD(rv);
|
322
|
+
|
312
323
|
return rv;
|
313
324
|
}
|
314
325
|
|
data/ext/RMagick/rmfill.c
CHANGED
@@ -675,7 +675,7 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
|
|
675
675
|
{
|
676
676
|
rm_TextureFill *fill;
|
677
677
|
Image *texture;
|
678
|
-
|
678
|
+
VALUE texture_image;
|
679
679
|
|
680
680
|
Data_Get_Struct(self, rm_TextureFill, fill);
|
681
681
|
|
@@ -686,6 +686,9 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
|
|
686
686
|
(void) ReferenceImage(texture);
|
687
687
|
|
688
688
|
fill->texture = texture;
|
689
|
+
|
690
|
+
RB_GC_GUARD(texture_image);
|
691
|
+
|
689
692
|
return self;
|
690
693
|
}
|
691
694
|
|
data/ext/RMagick/rmilist.c
CHANGED
@@ -44,7 +44,7 @@ ImageList_animate(int argc, VALUE *argv, VALUE self)
|
|
44
44
|
{
|
45
45
|
Image *images;
|
46
46
|
Info *info;
|
47
|
-
|
47
|
+
VALUE info_obj;
|
48
48
|
|
49
49
|
if (argc > 1)
|
50
50
|
{
|
@@ -74,6 +74,8 @@ ImageList_animate(int argc, VALUE *argv, VALUE self)
|
|
74
74
|
rm_check_image_exception(images, RetainOnError);
|
75
75
|
rm_split(images);
|
76
76
|
|
77
|
+
RB_GC_GUARD(info_obj);
|
78
|
+
|
77
79
|
return self;
|
78
80
|
}
|
79
81
|
|
@@ -202,7 +204,7 @@ ImageList_coalesce(VALUE self)
|
|
202
204
|
VALUE
|
203
205
|
ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
|
204
206
|
{
|
205
|
-
|
207
|
+
VALUE source_images;
|
206
208
|
Image *dest, *source, *new_images;
|
207
209
|
RectangleInfo geometry;
|
208
210
|
CompositeOperator operator = OverCompositeOp;
|
@@ -242,6 +244,8 @@ ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
|
|
242
244
|
rm_check_exception(exception, new_images, DestroyOnError);
|
243
245
|
(void) DestroyExceptionInfo(exception);
|
244
246
|
|
247
|
+
RB_GC_GUARD(source_images);
|
248
|
+
|
245
249
|
return rm_imagelist_from_images(new_images);
|
246
250
|
}
|
247
251
|
|
@@ -289,7 +293,7 @@ ImageList_display(VALUE self)
|
|
289
293
|
{
|
290
294
|
Image *images;
|
291
295
|
Info *info;
|
292
|
-
|
296
|
+
VALUE info_obj;
|
293
297
|
|
294
298
|
// Create a new Info object to use with this call
|
295
299
|
info_obj = rm_info_new();
|
@@ -302,6 +306,8 @@ ImageList_display(VALUE self)
|
|
302
306
|
rm_split(images);
|
303
307
|
rm_check_image_exception(images, RetainOnError);
|
304
308
|
|
309
|
+
RB_GC_GUARD(info_obj);
|
310
|
+
|
305
311
|
return self;
|
306
312
|
}
|
307
313
|
|
@@ -417,7 +423,7 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
|
|
417
423
|
Image *images, *new_images = NULL;
|
418
424
|
Image *map;
|
419
425
|
unsigned int dither = MagickFalse;
|
420
|
-
|
426
|
+
VALUE scene, new_imagelist, t;
|
421
427
|
ExceptionInfo *exception;
|
422
428
|
|
423
429
|
#if defined(HAVE_REMAPIMAGES)
|
@@ -465,6 +471,10 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
|
|
465
471
|
scene = rb_iv_get(self, "@scene");
|
466
472
|
(void) imagelist_scene_eq(new_imagelist, scene);
|
467
473
|
|
474
|
+
RB_GC_GUARD(scene);
|
475
|
+
RB_GC_GUARD(new_imagelist);
|
476
|
+
RB_GC_GUARD(t);
|
477
|
+
|
468
478
|
return new_imagelist;
|
469
479
|
}
|
470
480
|
|
@@ -485,7 +495,7 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
|
|
485
495
|
VALUE
|
486
496
|
ImageList_montage(VALUE self)
|
487
497
|
{
|
488
|
-
|
498
|
+
VALUE montage_obj;
|
489
499
|
Montage *montage;
|
490
500
|
Image *new_images, *images;
|
491
501
|
ExceptionInfo *exception;
|
@@ -523,6 +533,8 @@ ImageList_montage(VALUE self)
|
|
523
533
|
|
524
534
|
rm_ensure_result(new_images);
|
525
535
|
|
536
|
+
RB_GC_GUARD(montage_obj);
|
537
|
+
|
526
538
|
return rm_imagelist_from_images(new_images);
|
527
539
|
}
|
528
540
|
|
@@ -754,7 +766,7 @@ ImageList_new(void)
|
|
754
766
|
VALUE
|
755
767
|
rm_imagelist_from_images(Image *images)
|
756
768
|
{
|
757
|
-
|
769
|
+
VALUE new_imagelist;
|
758
770
|
Image *image;
|
759
771
|
|
760
772
|
if (!images)
|
@@ -771,6 +783,9 @@ rm_imagelist_from_images(Image *images)
|
|
771
783
|
}
|
772
784
|
|
773
785
|
(void) rb_iv_set(new_imagelist, "@scene", INT2FIX(0));
|
786
|
+
|
787
|
+
RB_GC_GUARD(new_imagelist);
|
788
|
+
|
774
789
|
return new_imagelist;
|
775
790
|
}
|
776
791
|
|
@@ -790,7 +805,7 @@ images_from_imagelist(VALUE imagelist)
|
|
790
805
|
{
|
791
806
|
long x, len;
|
792
807
|
Image *head = NULL;
|
793
|
-
|
808
|
+
VALUE images, t;
|
794
809
|
|
795
810
|
len = check_imagelist_length(imagelist);
|
796
811
|
|
@@ -801,9 +816,17 @@ images_from_imagelist(VALUE imagelist)
|
|
801
816
|
|
802
817
|
t = rb_ary_entry(images, x);
|
803
818
|
image = rm_check_destroyed(t);
|
819
|
+
// avoid a loop in this linked imagelist, issue #202
|
820
|
+
if (head == image || GetPreviousImageInList(image) != NULL)
|
821
|
+
{
|
822
|
+
image = rm_clone_image(image);
|
823
|
+
}
|
804
824
|
AppendImageToList(&head, image);
|
805
825
|
}
|
806
826
|
|
827
|
+
RB_GC_GUARD(images);
|
828
|
+
RB_GC_GUARD(t);
|
829
|
+
|
807
830
|
return head;
|
808
831
|
}
|
809
832
|
|
@@ -837,7 +860,10 @@ imagelist_scene_eq(VALUE imagelist, VALUE scene)
|
|
837
860
|
static long
|
838
861
|
imagelist_length(VALUE imagelist)
|
839
862
|
{
|
840
|
-
|
863
|
+
VALUE images = rb_iv_get(imagelist, "@images");
|
864
|
+
|
865
|
+
RB_GC_GUARD(images);
|
866
|
+
|
841
867
|
return RARRAY_LEN(images);
|
842
868
|
}
|
843
869
|
|
@@ -942,7 +968,7 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
|
|
942
968
|
Image *new_image;
|
943
969
|
QuantizeInfo quantize_info;
|
944
970
|
ExceptionInfo *exception;
|
945
|
-
|
971
|
+
VALUE new_imagelist, scene;
|
946
972
|
|
947
973
|
GetQuantizeInfo(&quantize_info);
|
948
974
|
|
@@ -1000,6 +1026,9 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
|
|
1000
1026
|
scene = rb_iv_get(self, "@scene");
|
1001
1027
|
(void) rb_iv_set(new_imagelist, "@scene", scene);
|
1002
1028
|
|
1029
|
+
RB_GC_GUARD(new_imagelist);
|
1030
|
+
RB_GC_GUARD(scene);
|
1031
|
+
|
1003
1032
|
return new_imagelist;
|
1004
1033
|
}
|
1005
1034
|
|
@@ -1032,8 +1061,9 @@ ImageList_remap(int argc, VALUE *argv, VALUE self)
|
|
1032
1061
|
|
1033
1062
|
if (argc > 0 && argv[0] != Qnil)
|
1034
1063
|
{
|
1035
|
-
|
1064
|
+
VALUE t = rm_cur_image(argv[0]);
|
1036
1065
|
remap_image = rm_check_destroyed(t);
|
1066
|
+
RB_GC_GUARD(t);
|
1037
1067
|
}
|
1038
1068
|
|
1039
1069
|
GetQuantizeInfo(&quantize_info);
|
@@ -1087,8 +1117,8 @@ ImageList_to_blob(VALUE self)
|
|
1087
1117
|
{
|
1088
1118
|
Image *images, *image;
|
1089
1119
|
Info *info;
|
1090
|
-
|
1091
|
-
|
1120
|
+
VALUE info_obj;
|
1121
|
+
VALUE blob_str;
|
1092
1122
|
void *blob = NULL;
|
1093
1123
|
size_t length = 0;
|
1094
1124
|
ExceptionInfo *exception;
|
@@ -1141,6 +1171,9 @@ ImageList_to_blob(VALUE self)
|
|
1141
1171
|
blob_str = rb_str_new(blob, (long)length);
|
1142
1172
|
magick_free((void*)blob);
|
1143
1173
|
|
1174
|
+
RB_GC_GUARD(info_obj);
|
1175
|
+
RB_GC_GUARD(blob_str);
|
1176
|
+
|
1144
1177
|
return blob_str;
|
1145
1178
|
}
|
1146
1179
|
|
@@ -1164,7 +1197,7 @@ ImageList_write(VALUE self, VALUE file)
|
|
1164
1197
|
Image *images, *img;
|
1165
1198
|
Info *info;
|
1166
1199
|
const MagickInfo *m;
|
1167
|
-
|
1200
|
+
VALUE info_obj;
|
1168
1201
|
unsigned long scene;
|
1169
1202
|
ExceptionInfo *exception;
|
1170
1203
|
|
@@ -1230,5 +1263,8 @@ ImageList_write(VALUE self, VALUE file)
|
|
1230
1263
|
}
|
1231
1264
|
|
1232
1265
|
rm_split(images);
|
1266
|
+
|
1267
|
+
RB_GC_GUARD(info_obj);
|
1268
|
+
|
1233
1269
|
return self;
|
1234
1270
|
}
|