rmagick 4.1.0.rc2 → 4.1.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/.codeclimate.yml +63 -0
- data/.editorconfig +3 -0
- data/.github/workflows/ci.yml +148 -0
- data/.gitignore +3 -1
- data/.rspec +1 -0
- data/.rubocop.yml +24 -0
- data/.rubocop_todo.yml +80 -270
- data/.yardopts +5 -0
- data/CHANGELOG.md +63 -0
- data/CONTRIBUTING.md +14 -10
- data/README.md +292 -0
- data/Rakefile +16 -22
- data/before_install_linux.sh +22 -32
- data/before_install_osx.sh +56 -2
- data/ext/RMagick/extconf.rb +100 -94
- data/ext/RMagick/rmagick.c +77 -104
- data/ext/RMagick/rmagick.h +74 -70
- data/ext/RMagick/rmdraw.c +261 -444
- data/ext/RMagick/rmenum.c +96 -113
- data/ext/RMagick/rmfill.c +46 -77
- data/ext/RMagick/rmilist.c +136 -244
- data/ext/RMagick/rmimage.c +3395 -4166
- data/ext/RMagick/rminfo.c +531 -737
- data/ext/RMagick/rmkinfo.c +21 -87
- data/ext/RMagick/rmmain.c +405 -245
- data/ext/RMagick/rmmontage.c +60 -126
- data/ext/RMagick/rmpixel.c +401 -345
- data/ext/RMagick/rmstruct.c +62 -88
- data/ext/RMagick/rmutil.c +112 -218
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +128 -77
- data/lib/rvg/clippath.rb +2 -1
- data/lib/rvg/container.rb +10 -5
- data/lib/rvg/describable.rb +1 -1
- data/lib/rvg/embellishable.rb +5 -4
- data/lib/rvg/misc.rb +15 -12
- data/lib/rvg/paint.rb +2 -1
- data/lib/rvg/pathdata.rb +12 -11
- data/lib/rvg/rvg.rb +8 -4
- data/lib/rvg/stylable.rb +9 -7
- data/lib/rvg/text.rb +11 -6
- data/lib/rvg/transformable.rb +3 -2
- data/lib/rvg/units.rb +1 -1
- data/rmagick.gemspec +7 -6
- metadata +31 -421
- data/.appveyor.yml +0 -57
- data/.circleci/config.yml +0 -56
- data/.ruby-version +0 -1
- data/.simplecov +0 -27
- data/.travis.yml +0 -64
- data/Doxyfile +0 -1514
- data/README.textile +0 -259
- data/benchmarks/memory/README.md +0 -50
- data/benchmarks/memory/image_new.rb +0 -8
- data/benchmarks/memory/rmagick.gnuplot +0 -16
- data/doc/.cvsignore +0 -1
- data/doc/comtasks.html +0 -287
- data/doc/constants.html +0 -1581
- data/doc/css/doc.css +0 -299
- data/doc/css/popup.css +0 -34
- data/doc/css/ref.css +0 -67
- data/doc/draw.html +0 -3272
- data/doc/ex/InitialCoords.rb +0 -22
- data/doc/ex/NewCoordSys.rb +0 -30
- data/doc/ex/OrigCoordSys.rb +0 -16
- data/doc/ex/PreserveAspectRatio.rb +0 -204
- data/doc/ex/RotateScale.rb +0 -36
- data/doc/ex/Skew.rb +0 -38
- data/doc/ex/Use01.rb +0 -15
- data/doc/ex/Use02.rb +0 -20
- data/doc/ex/Use03.rb +0 -16
- data/doc/ex/ViewBox.rb +0 -31
- data/doc/ex/adaptive_threshold.rb +0 -9
- data/doc/ex/add_noise.rb +0 -16
- data/doc/ex/affine.rb +0 -48
- data/doc/ex/affine_transform.rb +0 -20
- data/doc/ex/arc.rb +0 -49
- data/doc/ex/arcpath.rb +0 -32
- data/doc/ex/arcs01.rb +0 -28
- data/doc/ex/arcs02.rb +0 -59
- data/doc/ex/average.rb +0 -15
- data/doc/ex/axes.rb +0 -64
- data/doc/ex/baseline_shift01.rb +0 -17
- data/doc/ex/bilevel_channel.rb +0 -8
- data/doc/ex/blur_image.rb +0 -12
- data/doc/ex/border.rb +0 -10
- data/doc/ex/bounding_box.rb +0 -42
- data/doc/ex/cbezier1.rb +0 -41
- data/doc/ex/cbezier2.rb +0 -41
- data/doc/ex/cbezier3.rb +0 -41
- data/doc/ex/cbezier4.rb +0 -42
- data/doc/ex/cbezier5.rb +0 -42
- data/doc/ex/cbezier6.rb +0 -53
- data/doc/ex/channel.rb +0 -25
- data/doc/ex/charcoal.rb +0 -12
- data/doc/ex/chop.rb +0 -29
- data/doc/ex/circle.rb +0 -33
- data/doc/ex/circle01.rb +0 -16
- data/doc/ex/clip_path.rb +0 -60
- data/doc/ex/coalesce.rb +0 -57
- data/doc/ex/color_fill_to_border.rb +0 -29
- data/doc/ex/color_floodfill.rb +0 -28
- data/doc/ex/color_histogram.rb +0 -47
- data/doc/ex/color_reset.rb +0 -11
- data/doc/ex/colorize.rb +0 -16
- data/doc/ex/colors.rb +0 -64
- data/doc/ex/compose_mask.rb +0 -22
- data/doc/ex/composite.rb +0 -133
- data/doc/ex/composite_layers.rb +0 -52
- data/doc/ex/composite_tiled.rb +0 -21
- data/doc/ex/contrast.rb +0 -36
- data/doc/ex/crop.rb +0 -31
- data/doc/ex/crop_with_gravity.rb +0 -42
- data/doc/ex/cubic01.rb +0 -43
- data/doc/ex/cubic02.rb +0 -91
- data/doc/ex/cycle_colormap.rb +0 -21
- data/doc/ex/dissolve.rb +0 -12
- data/doc/ex/drawcomp.rb +0 -41
- data/doc/ex/drop_shadow.rb +0 -60
- data/doc/ex/edge.rb +0 -11
- data/doc/ex/ellipse.rb +0 -45
- data/doc/ex/ellipse01.rb +0 -21
- data/doc/ex/emboss.rb +0 -11
- data/doc/ex/enhance.rb +0 -28
- data/doc/ex/equalize.rb +0 -11
- data/doc/ex/evenodd.rb +0 -42
- data/doc/ex/fill_pattern.rb +0 -23
- data/doc/ex/flatten_images.rb +0 -36
- data/doc/ex/flip.rb +0 -11
- data/doc/ex/flop.rb +0 -11
- data/doc/ex/font_styles.rb +0 -32
- data/doc/ex/fonts.rb +0 -16
- data/doc/ex/frame.rb +0 -12
- data/doc/ex/gaussian_blur.rb +0 -11
- data/doc/ex/get_multiline_type_metrics.rb +0 -41
- data/doc/ex/get_pixels.rb +0 -45
- data/doc/ex/get_type_metrics.rb +0 -142
- data/doc/ex/gradientfill.rb +0 -27
- data/doc/ex/grav.rb +0 -45
- data/doc/ex/gravity.rb +0 -78
- data/doc/ex/group.rb +0 -26
- data/doc/ex/hatchfill.rb +0 -27
- data/doc/ex/image.rb +0 -44
- data/doc/ex/images/Apple.miff +0 -0
- data/doc/ex/images/Ballerina.jpg +0 -0
- data/doc/ex/images/Ballerina3.jpg +0 -0
- data/doc/ex/images/Button_0.gif +0 -0
- data/doc/ex/images/Button_1.gif +0 -0
- data/doc/ex/images/Button_2.gif +0 -0
- data/doc/ex/images/Button_3.gif +0 -0
- data/doc/ex/images/Button_4.gif +0 -0
- data/doc/ex/images/Button_5.gif +0 -0
- data/doc/ex/images/Button_6.gif +0 -0
- data/doc/ex/images/Button_7.gif +0 -0
- data/doc/ex/images/Button_8.gif +0 -0
- data/doc/ex/images/Button_9.gif +0 -0
- data/doc/ex/images/Button_A.gif +0 -0
- data/doc/ex/images/Button_B.gif +0 -0
- data/doc/ex/images/Button_C.gif +0 -0
- data/doc/ex/images/Button_D.gif +0 -0
- data/doc/ex/images/Button_E.gif +0 -0
- data/doc/ex/images/Button_F.gif +0 -0
- data/doc/ex/images/Button_G.gif +0 -0
- data/doc/ex/images/Button_H.gif +0 -0
- data/doc/ex/images/Button_I.gif +0 -0
- data/doc/ex/images/Button_J.gif +0 -0
- data/doc/ex/images/Button_K.gif +0 -0
- data/doc/ex/images/Button_L.gif +0 -0
- data/doc/ex/images/Button_M.gif +0 -0
- data/doc/ex/images/Button_N.gif +0 -0
- data/doc/ex/images/Button_O.gif +0 -0
- data/doc/ex/images/Button_P.gif +0 -0
- data/doc/ex/images/Button_Q.gif +0 -0
- data/doc/ex/images/Button_R.gif +0 -0
- data/doc/ex/images/Button_S.gif +0 -0
- data/doc/ex/images/Button_T.gif +0 -0
- data/doc/ex/images/Button_U.gif +0 -0
- data/doc/ex/images/Button_V.gif +0 -0
- data/doc/ex/images/Button_W.gif +0 -0
- data/doc/ex/images/Button_X.gif +0 -0
- data/doc/ex/images/Button_Y.gif +0 -0
- data/doc/ex/images/Button_Z.gif +0 -0
- data/doc/ex/images/Cheetah.jpg +0 -0
- data/doc/ex/images/Coffee.png +0 -0
- data/doc/ex/images/Flower_Hat.jpg +0 -0
- data/doc/ex/images/Gold_Statue.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons.jpg +0 -0
- data/doc/ex/images/Hot_Air_Balloons_H.jpg +0 -0
- data/doc/ex/images/Leaf.miff +0 -0
- data/doc/ex/images/No.png +0 -0
- data/doc/ex/images/Polynesia.jpg +0 -0
- data/doc/ex/images/Red_Rocks.jpg +0 -0
- data/doc/ex/images/Rocks_On_Beach.miff +0 -0
- data/doc/ex/images/Shorts.jpg +0 -0
- data/doc/ex/images/Snake.png +0 -0
- data/doc/ex/images/Violin.jpg +0 -0
- data/doc/ex/images/Yellow_Rose.miff +0 -0
- data/doc/ex/images/big-duck.gif +0 -0
- data/doc/ex/images/duck.gif +0 -0
- data/doc/ex/images/duck0.gif +0 -0
- data/doc/ex/images/duck1.gif +0 -0
- data/doc/ex/images/duck10.gif +0 -0
- data/doc/ex/images/duck11.gif +0 -0
- data/doc/ex/images/duck12.gif +0 -0
- data/doc/ex/images/duck13.gif +0 -0
- data/doc/ex/images/duck14.gif +0 -0
- data/doc/ex/images/duck15.gif +0 -0
- data/doc/ex/images/duck2.gif +0 -0
- data/doc/ex/images/duck3.gif +0 -0
- data/doc/ex/images/duck4.gif +0 -0
- data/doc/ex/images/duck5.gif +0 -0
- data/doc/ex/images/duck6.gif +0 -0
- data/doc/ex/images/duck7.gif +0 -0
- data/doc/ex/images/duck8.gif +0 -0
- data/doc/ex/images/duck9.gif +0 -0
- data/doc/ex/images/graydient230x6.gif +0 -0
- data/doc/ex/images/image_with_profile.jpg +0 -0
- data/doc/ex/images/logo400x83.gif +0 -0
- data/doc/ex/images/model.miff +0 -0
- data/doc/ex/images/notimplemented.gif +0 -0
- data/doc/ex/images/smile.miff +0 -0
- data/doc/ex/images/spin.gif +0 -0
- data/doc/ex/implode.rb +0 -34
- data/doc/ex/level.rb +0 -11
- data/doc/ex/level_colors.rb +0 -11
- data/doc/ex/line.rb +0 -41
- data/doc/ex/line01.rb +0 -21
- data/doc/ex/mask.rb +0 -35
- data/doc/ex/matte_fill_to_border.rb +0 -39
- data/doc/ex/matte_floodfill.rb +0 -32
- data/doc/ex/matte_replace.rb +0 -39
- data/doc/ex/median_filter.rb +0 -28
- data/doc/ex/modulate.rb +0 -11
- data/doc/ex/mono.rb +0 -23
- data/doc/ex/morph.rb +0 -25
- data/doc/ex/mosaic.rb +0 -37
- data/doc/ex/motion_blur.rb +0 -11
- data/doc/ex/negate.rb +0 -11
- data/doc/ex/negate_channel.rb +0 -9
- data/doc/ex/nested_rvg.rb +0 -21
- data/doc/ex/nonzero.rb +0 -42
- data/doc/ex/normalize.rb +0 -11
- data/doc/ex/oil_paint.rb +0 -11
- data/doc/ex/opacity.rb +0 -37
- data/doc/ex/ordered_dither.rb +0 -11
- data/doc/ex/path.rb +0 -63
- data/doc/ex/pattern1.rb +0 -25
- data/doc/ex/pattern2.rb +0 -26
- data/doc/ex/polaroid.rb +0 -26
- data/doc/ex/polygon.rb +0 -23
- data/doc/ex/polygon01.rb +0 -21
- data/doc/ex/polyline.rb +0 -22
- data/doc/ex/polyline01.rb +0 -21
- data/doc/ex/posterize.rb +0 -8
- data/doc/ex/preview.rb +0 -8
- data/doc/ex/qbezierpath.rb +0 -52
- data/doc/ex/quad01.rb +0 -34
- data/doc/ex/quantize-m.rb +0 -25
- data/doc/ex/radial_blur.rb +0 -9
- data/doc/ex/raise.rb +0 -8
- data/doc/ex/random_threshold_channel.rb +0 -13
- data/doc/ex/rect01.rb +0 -14
- data/doc/ex/rect02.rb +0 -20
- data/doc/ex/rectangle.rb +0 -34
- data/doc/ex/reduce_noise.rb +0 -28
- data/doc/ex/remap.rb +0 -11
- data/doc/ex/remap_images.rb +0 -19
- data/doc/ex/resize_to_fill.rb +0 -8
- data/doc/ex/resize_to_fit.rb +0 -8
- data/doc/ex/roll.rb +0 -9
- data/doc/ex/rotate.rb +0 -44
- data/doc/ex/rotate_f.rb +0 -14
- data/doc/ex/roundrect.rb +0 -33
- data/doc/ex/rubyname.rb +0 -30
- data/doc/ex/rvg_clippath.rb +0 -12
- data/doc/ex/rvg_linecap.rb +0 -42
- data/doc/ex/rvg_linejoin.rb +0 -40
- data/doc/ex/rvg_opacity.rb +0 -18
- data/doc/ex/rvg_pattern.rb +0 -26
- data/doc/ex/rvg_stroke_dasharray.rb +0 -11
- data/doc/ex/segment.rb +0 -11
- data/doc/ex/sepiatone.rb +0 -7
- data/doc/ex/shade.rb +0 -11
- data/doc/ex/shadow.rb +0 -30
- data/doc/ex/shave.rb +0 -15
- data/doc/ex/shear.rb +0 -10
- data/doc/ex/sketch.rb +0 -17
- data/doc/ex/skewx.rb +0 -51
- data/doc/ex/skewy.rb +0 -47
- data/doc/ex/smile.rb +0 -126
- data/doc/ex/solarize.rb +0 -11
- data/doc/ex/sparse_color.rb +0 -55
- data/doc/ex/splice.rb +0 -8
- data/doc/ex/spread.rb +0 -11
- data/doc/ex/stegano.rb +0 -54
- data/doc/ex/stroke_dasharray.rb +0 -42
- data/doc/ex/stroke_fill.rb +0 -10
- data/doc/ex/stroke_linecap.rb +0 -44
- data/doc/ex/stroke_linejoin.rb +0 -48
- data/doc/ex/stroke_width.rb +0 -49
- data/doc/ex/swirl.rb +0 -17
- data/doc/ex/text.rb +0 -37
- data/doc/ex/text01.rb +0 -16
- data/doc/ex/text_align.rb +0 -36
- data/doc/ex/text_antialias.rb +0 -37
- data/doc/ex/text_styles.rb +0 -19
- data/doc/ex/text_undercolor.rb +0 -28
- data/doc/ex/texture_fill_to_border.rb +0 -34
- data/doc/ex/texture_floodfill.rb +0 -32
- data/doc/ex/texturefill.rb +0 -24
- data/doc/ex/threshold.rb +0 -13
- data/doc/ex/to_blob.rb +0 -13
- data/doc/ex/translate.rb +0 -39
- data/doc/ex/transparent.rb +0 -38
- data/doc/ex/transpose.rb +0 -9
- data/doc/ex/transverse.rb +0 -9
- data/doc/ex/tref01.rb +0 -24
- data/doc/ex/triangle01.rb +0 -15
- data/doc/ex/trim.rb +0 -23
- data/doc/ex/tspan01.rb +0 -17
- data/doc/ex/tspan02.rb +0 -17
- data/doc/ex/tspan03.rb +0 -19
- data/doc/ex/unsharp_mask.rb +0 -28
- data/doc/ex/viewex.rb +0 -33
- data/doc/ex/vignette.rb +0 -12
- data/doc/ex/watermark.rb +0 -27
- data/doc/ex/wave.rb +0 -9
- data/doc/ex/wet_floor.rb +0 -58
- data/doc/ex/writing_mode01.rb +0 -26
- data/doc/ex/writing_mode02.rb +0 -26
- data/doc/ilist.html +0 -2056
- data/doc/image1.html +0 -4680
- data/doc/image2.html +0 -3665
- data/doc/image3.html +0 -4522
- data/doc/imageattrs.html +0 -1638
- data/doc/imusage.html +0 -514
- data/doc/index.html +0 -416
- data/doc/info.html +0 -1499
- data/doc/magick.html +0 -570
- data/doc/optequiv.html +0 -2435
- data/doc/rvg.html +0 -975
- data/doc/rvgclip.html +0 -248
- data/doc/rvggroup.html +0 -305
- data/doc/rvgimage.html +0 -289
- data/doc/rvgpattern.html +0 -475
- data/doc/rvgshape.html +0 -406
- data/doc/rvgstyle.html +0 -270
- data/doc/rvgtext.html +0 -465
- data/doc/rvgtspan.html +0 -238
- data/doc/rvgtut.html +0 -530
- data/doc/rvguse.html +0 -145
- data/doc/rvgxform.html +0 -294
- data/doc/scripts/doc.js +0 -22
- data/doc/scripts/stripeTables.js +0 -23
- data/doc/struct.html +0 -1339
- data/doc/usage.html +0 -1621
- data/examples/constitute.rb +0 -7
- data/examples/crop_with_gravity.rb +0 -43
- data/examples/demo.rb +0 -323
- data/examples/describe.rb +0 -41
- data/examples/find_similar_region.rb +0 -34
- data/examples/histogram.rb +0 -312
- data/examples/identify.rb +0 -174
- data/examples/image_opacity.rb +0 -28
- data/examples/import_export.rb +0 -31
- data/examples/pattern_fill.rb +0 -37
- data/examples/rotating_text.rb +0 -45
- data/examples/spinner.rb +0 -49
- data/examples/thumbnail.rb +0 -64
- data/examples/vignette.rb +0 -78
- data/spec/rmagick/ImageList1_spec.rb +0 -24
- data/spec/rmagick/draw_spec.rb +0 -155
- data/spec/rmagick/image/blue_shift_spec.rb +0 -14
- data/spec/rmagick/image/channel_entropy_spec.rb +0 -9
- data/spec/rmagick/image/composite_spec.rb +0 -72
- data/spec/rmagick/image/constitute_spec.rb +0 -13
- data/spec/rmagick/image/dispatch_spec.rb +0 -16
- data/spec/rmagick/image/dissolve_spec.rb +0 -54
- data/spec/rmagick/image/from_blob_spec.rb +0 -12
- data/spec/rmagick/image/ping_spec.rb +0 -12
- data/spec/rmagick/image/properties_spec.rb +0 -27
- data/spec/rmagick/image/read_spec.rb +0 -28
- data/spec/spec_helper.rb +0 -9
- data/spec/support/issue_200/app.rb +0 -8
- data/test/Draw.rb +0 -351
- data/test/Enum.rb +0 -228
- data/test/Fill.rb +0 -93
- data/test/Image1.rb +0 -606
- data/test/Image2.rb +0 -1408
- data/test/Image3.rb +0 -1086
- data/test/ImageList1.rb +0 -858
- data/test/ImageList2.rb +0 -375
- data/test/Image_attributes.rb +0 -635
- data/test/Import_Export.rb +0 -111
- data/test/Info.rb +0 -436
- data/test/KernelInfo.rb +0 -59
- data/test/Magick.rb +0 -311
- data/test/Pixel.rb +0 -259
- data/test/PolaroidOptions.rb +0 -23
- data/test/Preview.rb +0 -26
- data/test/Struct.rb +0 -45
- data/test/appearance/Montage.rb +0 -26
- data/test/appearance/appearance_assertion.rb +0 -13
- data/test/appearance/expected/montage_border_color.jpg +0 -0
- data/test/cmyk.icm +0 -0
- data/test/lib/internal/Draw.rb +0 -811
- data/test/lib/internal/Geometry.rb +0 -98
- data/test/lib/internal/Magick.rb +0 -40
- data/test/srgb.icm +0 -0
- data/test/test_all_basic.rb +0 -49
- data/test/tmpnam_test.rb +0 -50
data/ext/RMagick/rmstruct.c
CHANGED
@@ -82,7 +82,7 @@ Export_AffineMatrix(AffineMatrix *am, VALUE st)
|
|
82
82
|
|
83
83
|
|
84
84
|
/**
|
85
|
-
* Create a Magick::ChromaticityInfo object from a ChromaticityInfo structure.
|
85
|
+
* Create a {Magick::ChromaticityInfo} object from a ChromaticityInfo structure.
|
86
86
|
*
|
87
87
|
* No Ruby usage (internal function)
|
88
88
|
*
|
@@ -107,8 +107,8 @@ ChromaticityInfo_new(ChromaticityInfo *ci)
|
|
107
107
|
RB_GC_GUARD(blue_primary);
|
108
108
|
RB_GC_GUARD(white_point);
|
109
109
|
|
110
|
-
return rb_funcall(Class_Chromaticity, rm_ID_new, 4
|
111
|
-
|
110
|
+
return rb_funcall(Class_Chromaticity, rm_ID_new, 4,
|
111
|
+
red_primary, green_primary, blue_primary, white_point);
|
112
112
|
}
|
113
113
|
|
114
114
|
|
@@ -127,24 +127,22 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
|
|
127
127
|
VALUE chrom_members;
|
128
128
|
VALUE red_primary, green_primary, blue_primary, white_point;
|
129
129
|
VALUE entry_members, x, y;
|
130
|
-
ID values_id;
|
131
130
|
|
132
131
|
if (CLASS_OF(chrom) != Class_Chromaticity)
|
133
132
|
{
|
134
133
|
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
135
134
|
rb_class2name(CLASS_OF(chrom)));
|
136
135
|
}
|
137
|
-
values_id = rm_ID_values;
|
138
136
|
|
139
137
|
// Get the struct members in an array
|
140
|
-
chrom_members = rb_funcall(chrom,
|
138
|
+
chrom_members = rb_funcall(chrom, rm_ID_values, 0);
|
141
139
|
red_primary = rb_ary_entry(chrom_members, 0);
|
142
140
|
green_primary = rb_ary_entry(chrom_members, 1);
|
143
141
|
blue_primary = rb_ary_entry(chrom_members, 2);
|
144
142
|
white_point = rb_ary_entry(chrom_members, 3);
|
145
143
|
|
146
144
|
// Get the red_primary PrimaryInfo members in an array
|
147
|
-
entry_members = rb_funcall(red_primary,
|
145
|
+
entry_members = rb_funcall(red_primary, rm_ID_values, 0);
|
148
146
|
x = rb_ary_entry(entry_members, 0); // red_primary.x
|
149
147
|
ci->red_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
|
150
148
|
y = rb_ary_entry(entry_members, 1); // red_primary.y
|
@@ -152,7 +150,7 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
|
|
152
150
|
ci->red_primary.z = 0.0;
|
153
151
|
|
154
152
|
// Get the green_primary PrimaryInfo members in an array
|
155
|
-
entry_members = rb_funcall(green_primary,
|
153
|
+
entry_members = rb_funcall(green_primary, rm_ID_values, 0);
|
156
154
|
x = rb_ary_entry(entry_members, 0); // green_primary.x
|
157
155
|
ci->green_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
|
158
156
|
y = rb_ary_entry(entry_members, 1); // green_primary.y
|
@@ -160,7 +158,7 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
|
|
160
158
|
ci->green_primary.z = 0.0;
|
161
159
|
|
162
160
|
// Get the blue_primary PrimaryInfo members in an array
|
163
|
-
entry_members = rb_funcall(blue_primary,
|
161
|
+
entry_members = rb_funcall(blue_primary, rm_ID_values, 0);
|
164
162
|
x = rb_ary_entry(entry_members, 0); // blue_primary.x
|
165
163
|
ci->blue_primary.x = x == Qnil ? 0.0 : NUM2DBL(x);
|
166
164
|
y = rb_ary_entry(entry_members, 1); // blue_primary.y
|
@@ -168,7 +166,7 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
|
|
168
166
|
ci->blue_primary.z = 0.0;
|
169
167
|
|
170
168
|
// Get the white_point PrimaryInfo members in an array
|
171
|
-
entry_members = rb_funcall(white_point,
|
169
|
+
entry_members = rb_funcall(white_point, rm_ID_values, 0);
|
172
170
|
x = rb_ary_entry(entry_members, 0); // white_point.x
|
173
171
|
ci->white_point.x = x == Qnil ? 0.0 : NUM2DBL(x);
|
174
172
|
y = rb_ary_entry(entry_members, 1); // white_point.y
|
@@ -187,13 +185,9 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
|
|
187
185
|
|
188
186
|
|
189
187
|
/**
|
190
|
-
*
|
188
|
+
* Return a string representation of a {Magick::Chromaticity} object.
|
191
189
|
*
|
192
|
-
*
|
193
|
-
* - @verbatim Magick::Chromaticity#to_s @endverbatim
|
194
|
-
*
|
195
|
-
* @param self this object
|
196
|
-
* @return the string
|
190
|
+
* @return [String] the string
|
197
191
|
*/
|
198
192
|
VALUE
|
199
193
|
ChromaticityInfo_to_s(VALUE self)
|
@@ -202,7 +196,8 @@ ChromaticityInfo_to_s(VALUE self)
|
|
202
196
|
char buff[200];
|
203
197
|
|
204
198
|
Export_ChromaticityInfo(&ci, self);
|
205
|
-
|
199
|
+
snprintf(buff, sizeof(buff),
|
200
|
+
"red_primary=(x=%g,y=%g) "
|
206
201
|
"green_primary=(x=%g,y=%g) "
|
207
202
|
"blue_primary=(x=%g,y=%g) "
|
208
203
|
"white_point=(x=%g,y=%g) ",
|
@@ -240,8 +235,8 @@ Import_ColorInfo(const ColorInfo *ci)
|
|
240
235
|
RB_GC_GUARD(compliance);
|
241
236
|
RB_GC_GUARD(color);
|
242
237
|
|
243
|
-
return rb_funcall(Class_Color, rm_ID_new, 3
|
244
|
-
|
238
|
+
return rb_funcall(Class_Color, rm_ID_new, 3,
|
239
|
+
name, compliance, color);
|
245
240
|
}
|
246
241
|
|
247
242
|
|
@@ -272,7 +267,7 @@ Export_ColorInfo(ColorInfo *ci, VALUE st)
|
|
272
267
|
m = rb_ary_entry(members, 0);
|
273
268
|
if (m != Qnil)
|
274
269
|
{
|
275
|
-
|
270
|
+
CloneString((char **)&(ci->name), StringValueCStr(m));
|
276
271
|
}
|
277
272
|
m = rb_ary_entry(members, 1);
|
278
273
|
if (m != Qnil)
|
@@ -351,13 +346,9 @@ destroy_ColorInfo(ColorInfo *ci)
|
|
351
346
|
|
352
347
|
|
353
348
|
/**
|
354
|
-
* Return a string representation of a Magick::Color object.
|
355
|
-
*
|
356
|
-
* Ruby usage:
|
357
|
-
* - @verbatim Color#to_s @endverbatim
|
349
|
+
* Return a string representation of a {Magick::Color} object.
|
358
350
|
*
|
359
|
-
* @
|
360
|
-
* @return the string
|
351
|
+
* @return [String] the string
|
361
352
|
*/
|
362
353
|
VALUE
|
363
354
|
Color_to_s(VALUE self)
|
@@ -367,7 +358,8 @@ Color_to_s(VALUE self)
|
|
367
358
|
|
368
359
|
Export_ColorInfo(&ci, self);
|
369
360
|
|
370
|
-
|
361
|
+
snprintf(buff, sizeof(buff),
|
362
|
+
"name=%s, compliance=%s, "
|
371
363
|
#if (MAGICKCORE_QUANTUM_DEPTH == 32 || MAGICKCORE_QUANTUM_DEPTH == 64) && defined(HAVE_TYPE_LONG_DOUBLE)
|
372
364
|
"color.red=%Lg, color.green=%Lg, color.blue=%Lg, color.alpha=%Lg ",
|
373
365
|
#else
|
@@ -421,9 +413,9 @@ Import_TypeInfo(const TypeInfo *ti)
|
|
421
413
|
RB_GC_GUARD(foundry);
|
422
414
|
RB_GC_GUARD(format);
|
423
415
|
|
424
|
-
return rb_funcall(Class_Font, rm_ID_new, 9
|
425
|
-
|
426
|
-
|
416
|
+
return rb_funcall(Class_Font, rm_ID_new, 9,
|
417
|
+
name, description, family, style,
|
418
|
+
stretch, weight, encoding, foundry, format);
|
427
419
|
}
|
428
420
|
|
429
421
|
|
@@ -452,17 +444,17 @@ Export_TypeInfo(TypeInfo *ti, VALUE st)
|
|
452
444
|
m = rb_ary_entry(members, 0);
|
453
445
|
if (m != Qnil)
|
454
446
|
{
|
455
|
-
|
447
|
+
CloneString((char **)&(ti->name), StringValueCStr(m));
|
456
448
|
}
|
457
449
|
m = rb_ary_entry(members, 1);
|
458
450
|
if (m != Qnil)
|
459
451
|
{
|
460
|
-
|
452
|
+
CloneString((char **)&(ti->description), StringValueCStr(m));
|
461
453
|
}
|
462
454
|
m = rb_ary_entry(members, 2);
|
463
455
|
if (m != Qnil)
|
464
456
|
{
|
465
|
-
|
457
|
+
CloneString((char **)&(ti->family), StringValueCStr(m));
|
466
458
|
}
|
467
459
|
m = rb_ary_entry(members, 3); ti->style = m == Qnil ? 0 : FIX2INT(Enum_to_i(m));
|
468
460
|
m = rb_ary_entry(members, 4); ti->stretch = m == Qnil ? 0 : FIX2INT(Enum_to_i(m));
|
@@ -470,13 +462,13 @@ Export_TypeInfo(TypeInfo *ti, VALUE st)
|
|
470
462
|
|
471
463
|
m = rb_ary_entry(members, 6);
|
472
464
|
if (m != Qnil)
|
473
|
-
|
465
|
+
CloneString((char **)&(ti->encoding), StringValueCStr(m));
|
474
466
|
m = rb_ary_entry(members, 7);
|
475
467
|
if (m != Qnil)
|
476
|
-
|
468
|
+
CloneString((char **)&(ti->foundry), StringValueCStr(m));
|
477
469
|
m = rb_ary_entry(members, 8);
|
478
470
|
if (m != Qnil)
|
479
|
-
|
471
|
+
CloneString((char **)&(ti->format), StringValueCStr(m));
|
480
472
|
|
481
473
|
RB_GC_GUARD(members);
|
482
474
|
RB_GC_GUARD(m);
|
@@ -510,12 +502,9 @@ destroy_TypeInfo(TypeInfo *ti)
|
|
510
502
|
|
511
503
|
|
512
504
|
/**
|
513
|
-
*
|
514
|
-
*
|
515
|
-
* No Ruby usage (internal function)
|
505
|
+
* Return a string representation of a {Magick::Font} object.
|
516
506
|
*
|
517
|
-
* @
|
518
|
-
* @return the string
|
507
|
+
* @return [String] the string
|
519
508
|
*/
|
520
509
|
VALUE
|
521
510
|
Font_to_s(VALUE self)
|
@@ -535,11 +524,12 @@ Font_to_s(VALUE self)
|
|
535
524
|
strcpy(weight, "BoldWeight");
|
536
525
|
break;
|
537
526
|
default:
|
538
|
-
|
527
|
+
snprintf(weight, sizeof(weight), "%"RMIuSIZE"", ti.weight);
|
539
528
|
break;
|
540
529
|
}
|
541
530
|
|
542
|
-
|
531
|
+
snprintf(buff, sizeof(buff),
|
532
|
+
"name=%s, description=%s, "
|
543
533
|
"family=%s, style=%s, stretch=%s, weight=%s, "
|
544
534
|
"encoding=%s, foundry=%s, format=%s",
|
545
535
|
ti.name,
|
@@ -569,8 +559,8 @@ Font_to_s(VALUE self)
|
|
569
559
|
VALUE
|
570
560
|
Import_PointInfo(PointInfo *p)
|
571
561
|
{
|
572
|
-
return rb_funcall(Class_Point, rm_ID_new, 2
|
573
|
-
|
562
|
+
return rb_funcall(Class_Point, rm_ID_new, 2,
|
563
|
+
INT2FIX(p->x), INT2FIX(p->y));
|
574
564
|
}
|
575
565
|
|
576
566
|
|
@@ -614,8 +604,8 @@ Export_PointInfo(PointInfo *pi, VALUE sp)
|
|
614
604
|
VALUE
|
615
605
|
Import_PrimaryInfo(PrimaryInfo *p)
|
616
606
|
{
|
617
|
-
return rb_funcall(Class_Primary, rm_ID_new, 3
|
618
|
-
|
607
|
+
return rb_funcall(Class_Primary, rm_ID_new, 3,
|
608
|
+
INT2FIX(p->x), INT2FIX(p->y), INT2FIX(p->z));
|
619
609
|
}
|
620
610
|
|
621
611
|
|
@@ -651,13 +641,9 @@ Export_PrimaryInfo(PrimaryInfo *pi, VALUE sp)
|
|
651
641
|
|
652
642
|
|
653
643
|
/**
|
654
|
-
*
|
644
|
+
* Return a string representation of a {Magick::PrimaryInfo} object.
|
655
645
|
*
|
656
|
-
*
|
657
|
-
* - @verbatim Magick::PrimaryInfo#to_s @endverbatim
|
658
|
-
*
|
659
|
-
* @param self this object
|
660
|
-
* @return the string
|
646
|
+
* @return [String] the string
|
661
647
|
*/
|
662
648
|
VALUE
|
663
649
|
PrimaryInfo_to_s(VALUE self)
|
@@ -666,7 +652,7 @@ PrimaryInfo_to_s(VALUE self)
|
|
666
652
|
char buff[100];
|
667
653
|
|
668
654
|
Export_PrimaryInfo(&pi, self);
|
669
|
-
|
655
|
+
snprintf(buff, sizeof(buff), "x=%g, y=%g, z=%g", pi.x, pi.y, pi.z);
|
670
656
|
return rb_str_new2(buff);
|
671
657
|
}
|
672
658
|
|
@@ -696,8 +682,8 @@ Import_RectangleInfo(RectangleInfo *rect)
|
|
696
682
|
RB_GC_GUARD(x);
|
697
683
|
RB_GC_GUARD(y);
|
698
684
|
|
699
|
-
return rb_funcall(Class_Rectangle, rm_ID_new, 4
|
700
|
-
|
685
|
+
return rb_funcall(Class_Rectangle, rm_ID_new, 4,
|
686
|
+
width, height, x, y);
|
701
687
|
}
|
702
688
|
|
703
689
|
|
@@ -735,13 +721,9 @@ Export_RectangleInfo(RectangleInfo *rect, VALUE sr)
|
|
735
721
|
|
736
722
|
|
737
723
|
/**
|
738
|
-
*
|
739
|
-
*
|
740
|
-
* Ruby usage:
|
741
|
-
* - @verbatim Magick::Rectangle#to_s @endverbatim
|
724
|
+
* Return a string representation of a {Magick::Rectangle} object.
|
742
725
|
*
|
743
|
-
* @
|
744
|
-
* @return the string
|
726
|
+
* @return [String] the string
|
745
727
|
*/
|
746
728
|
VALUE
|
747
729
|
RectangleInfo_to_s(VALUE self)
|
@@ -750,8 +732,8 @@ RectangleInfo_to_s(VALUE self)
|
|
750
732
|
char buff[100];
|
751
733
|
|
752
734
|
Export_RectangleInfo(&rect, self);
|
753
|
-
|
754
|
-
|
735
|
+
snprintf(buff, sizeof(buff), "width=%"RMIuSIZE", height=%"RMIuSIZE", x=%"RMIdSIZE", y=%"RMIdSIZE"",
|
736
|
+
rect.width, rect.height, rect.x, rect.y);
|
755
737
|
return rb_str_new2(buff);
|
756
738
|
}
|
757
739
|
|
@@ -818,13 +800,9 @@ Export_SegmentInfo(SegmentInfo *segment, VALUE s)
|
|
818
800
|
|
819
801
|
|
820
802
|
/**
|
821
|
-
*
|
803
|
+
* Return a string representation of a {Magick::Segment} object.
|
822
804
|
*
|
823
|
-
*
|
824
|
-
* - @verbatim Magick::SegmentInfo#to_s @endverbatim
|
825
|
-
*
|
826
|
-
* @param self this object
|
827
|
-
* @return the string
|
805
|
+
* @return [String] the string
|
828
806
|
*/
|
829
807
|
VALUE
|
830
808
|
SegmentInfo_to_s(VALUE self)
|
@@ -833,8 +811,8 @@ SegmentInfo_to_s(VALUE self)
|
|
833
811
|
char buff[100];
|
834
812
|
|
835
813
|
Export_SegmentInfo(&segment, self);
|
836
|
-
|
837
|
-
|
814
|
+
snprintf(buff, sizeof(buff), "x1=%g, y1=%g, x2=%g, y2=%g",
|
815
|
+
segment.x1, segment.y1, segment.x2, segment.y2);
|
838
816
|
return rb_str_new2(buff);
|
839
817
|
}
|
840
818
|
|
@@ -875,10 +853,10 @@ Import_TypeMetric(TypeMetric *tm)
|
|
875
853
|
RB_GC_GUARD(underline_position);
|
876
854
|
RB_GC_GUARD(underline_thickness);
|
877
855
|
|
878
|
-
return rb_funcall(Class_TypeMetric, rm_ID_new, 9
|
879
|
-
|
880
|
-
|
881
|
-
|
856
|
+
return rb_funcall(Class_TypeMetric, rm_ID_new, 9,
|
857
|
+
pixels_per_em, ascent, descent, width,
|
858
|
+
height, max_advance, bounds,
|
859
|
+
underline_position, underline_thickness);
|
882
860
|
}
|
883
861
|
|
884
862
|
|
@@ -932,13 +910,9 @@ Export_TypeMetric(TypeMetric *tm, VALUE st)
|
|
932
910
|
|
933
911
|
|
934
912
|
/**
|
935
|
-
*
|
936
|
-
*
|
937
|
-
* Ruby usage:
|
938
|
-
* - @verbatim Magick::TypeMetric#to_s @endverbatim
|
913
|
+
* Return a string representation of a {Magick::TypeMetric} object.
|
939
914
|
*
|
940
|
-
* @
|
941
|
-
* @return the string
|
915
|
+
* @return [String] the string
|
942
916
|
*/
|
943
917
|
VALUE
|
944
918
|
TypeMetric_to_s(VALUE self)
|
@@ -950,17 +924,17 @@ TypeMetric_to_s(VALUE self)
|
|
950
924
|
|
951
925
|
Export_TypeMetric(&tm, self);
|
952
926
|
|
953
|
-
len =
|
927
|
+
len = snprintf(temp, sizeof(temp), "pixels_per_em=(x=%g,y=%g) ", tm.pixels_per_em.x, tm.pixels_per_em.y);
|
954
928
|
str = rb_str_new(temp, len);
|
955
|
-
len =
|
929
|
+
len = snprintf(temp, sizeof(temp), "ascent=%g descent=%g ",tm.ascent, tm.descent);
|
956
930
|
rb_str_cat(str, temp, len);
|
957
|
-
len =
|
931
|
+
len = snprintf(temp, sizeof(temp), "width=%g height=%g max_advance=%g ", tm.width, tm.height, tm.max_advance);
|
958
932
|
rb_str_cat(str, temp, len);
|
959
|
-
len =
|
933
|
+
len = snprintf(temp, sizeof(temp), "bounds.x1=%g bounds.y1=%g ", tm.bounds.x1, tm.bounds.y1);
|
960
934
|
rb_str_cat(str, temp, len);
|
961
|
-
len =
|
935
|
+
len = snprintf(temp, sizeof(temp), "bounds.x2=%g bounds.y2=%g ", tm.bounds.x2, tm.bounds.y2);
|
962
936
|
rb_str_cat(str, temp, len);
|
963
|
-
len =
|
937
|
+
len = snprintf(temp, sizeof(temp), "underline_position=%g underline_thickness=%g", tm.underline_position, tm.underline_thickness);
|
964
938
|
rb_str_cat(str, temp, len);
|
965
939
|
|
966
940
|
RB_GC_GUARD(str);
|
data/ext/RMagick/rmutil.c
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
#include "rmagick.h"
|
14
14
|
#include <errno.h>
|
15
15
|
|
16
|
+
static VALUE rescue_not_str(VALUE, VALUE ATTRIBUTE_UNUSED) ATTRIBUTE_NORETURN;
|
16
17
|
static void handle_exception(ExceptionInfo *, Image *, ErrorRetention);
|
17
18
|
|
18
19
|
|
@@ -78,7 +79,7 @@ magick_malloc(const size_t size)
|
|
78
79
|
void
|
79
80
|
magick_free(void *ptr)
|
80
81
|
{
|
81
|
-
|
82
|
+
RelinquishMagickMemory(ptr);
|
82
83
|
}
|
83
84
|
|
84
85
|
|
@@ -112,28 +113,6 @@ magick_safe_realloc(void *memory, const size_t count, const size_t quantum)
|
|
112
113
|
}
|
113
114
|
|
114
115
|
|
115
|
-
/**
|
116
|
-
* ImageMagick version of realloc.
|
117
|
-
*
|
118
|
-
* No Ruby usage (internal function)
|
119
|
-
*
|
120
|
-
* @param ptr pointer to the existing block of memory
|
121
|
-
* @param size the new size of memory to allocate
|
122
|
-
* @return pointer to a block of memory
|
123
|
-
*/
|
124
|
-
void *
|
125
|
-
magick_realloc(void *ptr, const size_t size)
|
126
|
-
{
|
127
|
-
void *v;
|
128
|
-
v = ResizeMagickMemory(ptr, size);
|
129
|
-
if (!v)
|
130
|
-
{
|
131
|
-
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
132
|
-
}
|
133
|
-
return v;
|
134
|
-
}
|
135
|
-
|
136
|
-
|
137
116
|
/**
|
138
117
|
* Make a copy of a string in malloc'd memory.
|
139
118
|
*
|
@@ -149,7 +128,7 @@ magick_realloc(void *ptr, const size_t size)
|
|
149
128
|
void
|
150
129
|
magick_clone_string(char **new_str, const char *str)
|
151
130
|
{
|
152
|
-
|
131
|
+
CloneString(new_str, str);
|
153
132
|
}
|
154
133
|
|
155
134
|
|
@@ -208,6 +187,28 @@ rm_strncasecmp(const char *s1, const char *s2, size_t n)
|
|
208
187
|
}
|
209
188
|
|
210
189
|
|
190
|
+
/**
|
191
|
+
* Get string length.
|
192
|
+
*
|
193
|
+
* No Ruby usage (internal function)
|
194
|
+
*
|
195
|
+
* @param str the string
|
196
|
+
* @param strsz the maximum number of characters
|
197
|
+
* @return same as strnlen_s()
|
198
|
+
*/
|
199
|
+
size_t
|
200
|
+
rm_strnlen_s(const char *str, size_t strsz)
|
201
|
+
{
|
202
|
+
size_t length = 0;
|
203
|
+
while(*str && length < strsz)
|
204
|
+
{
|
205
|
+
str++;
|
206
|
+
length++;
|
207
|
+
}
|
208
|
+
return length;
|
209
|
+
}
|
210
|
+
|
211
|
+
|
211
212
|
/**
|
212
213
|
* Raise exception if array too short.
|
213
214
|
*
|
@@ -243,7 +244,7 @@ rm_check_ary_type(VALUE ary)
|
|
243
244
|
VALUE checked = rb_check_array_type(ary);
|
244
245
|
if (NIL_P(checked))
|
245
246
|
{
|
246
|
-
rb_raise(rb_eTypeError, "wrong argument type %"
|
247
|
+
rb_raise(rb_eTypeError, "wrong argument type %"RMIsVALUE" was given. (must respond to :to_ary)", rb_obj_class(ary));
|
247
248
|
}
|
248
249
|
return checked;
|
249
250
|
}
|
@@ -295,35 +296,12 @@ rm_check_frozen(VALUE obj)
|
|
295
296
|
*
|
296
297
|
* No Ruby usage (internal function)
|
297
298
|
*
|
298
|
-
* @
|
299
|
-
* @return 0
|
300
|
-
* @throw TypeError
|
299
|
+
* @raise [TypeError]
|
301
300
|
*/
|
302
301
|
VALUE
|
303
302
|
rm_no_freeze(VALUE obj)
|
304
303
|
{
|
305
304
|
rb_raise(rb_eTypeError, "can't freeze %s", rb_class2name(CLASS_OF(obj)));
|
306
|
-
return (VALUE)0;
|
307
|
-
}
|
308
|
-
|
309
|
-
|
310
|
-
/**
|
311
|
-
* Return obj.to_s, or obj if obj is already a string.
|
312
|
-
*
|
313
|
-
* No Ruby usage (internal function)
|
314
|
-
*
|
315
|
-
* @param obj a Ruby object
|
316
|
-
* @return a String representation of obj
|
317
|
-
*/
|
318
|
-
VALUE
|
319
|
-
rm_to_s(VALUE obj)
|
320
|
-
{
|
321
|
-
|
322
|
-
if (TYPE(obj) != T_STRING)
|
323
|
-
{
|
324
|
-
return rb_funcall(obj, rm_ID_to_s, 0);
|
325
|
-
}
|
326
|
-
return obj;
|
327
305
|
}
|
328
306
|
|
329
307
|
|
@@ -348,21 +326,6 @@ rm_str2cstr(VALUE str, long *len)
|
|
348
326
|
}
|
349
327
|
|
350
328
|
|
351
|
-
/**
|
352
|
-
* Try to convert the argument to a double, raise an exception if fail.
|
353
|
-
*
|
354
|
-
* No Ruby usage (internal function)
|
355
|
-
*
|
356
|
-
* @param arg the argument
|
357
|
-
* @return arg
|
358
|
-
*/
|
359
|
-
static VALUE
|
360
|
-
arg_is_number(VALUE arg)
|
361
|
-
{
|
362
|
-
return DBL2NUM(NUM2DBL(arg));
|
363
|
-
}
|
364
|
-
|
365
|
-
|
366
329
|
/**
|
367
330
|
* Called when `rb_str_to_str' raises an exception.
|
368
331
|
*
|
@@ -373,11 +336,10 @@ arg_is_number(VALUE arg)
|
|
373
336
|
* @throw TypeError
|
374
337
|
*/
|
375
338
|
static VALUE
|
376
|
-
rescue_not_str(VALUE arg)
|
339
|
+
rescue_not_str(VALUE arg, VALUE raised_exc ATTRIBUTE_UNUSED)
|
377
340
|
{
|
378
341
|
rb_raise(rb_eTypeError, "argument must be a number or a string in the form 'NN%%' (%s given)",
|
379
342
|
rb_class2name(CLASS_OF(arg)));
|
380
|
-
return (VALUE)0;
|
381
343
|
}
|
382
344
|
|
383
345
|
|
@@ -396,17 +358,16 @@ double
|
|
396
358
|
rm_percentage(VALUE arg, double max)
|
397
359
|
{
|
398
360
|
double pct;
|
399
|
-
|
400
|
-
char *pct_str, *end;
|
361
|
+
char *end;
|
401
362
|
int not_num;
|
402
363
|
|
403
|
-
|
404
|
-
(void) rb_protect(arg_is_number, arg, ¬_num);
|
405
|
-
|
406
|
-
if (not_num)
|
364
|
+
if (!rm_check_num2dbl(arg))
|
407
365
|
{
|
366
|
+
char *pct_str;
|
367
|
+
long pct_long;
|
368
|
+
|
408
369
|
arg = rb_rescue(rb_str_to_str, arg, rescue_not_str, arg);
|
409
|
-
pct_str =
|
370
|
+
pct_str = StringValueCStr(arg);
|
410
371
|
errno = 0;
|
411
372
|
pct_long = strtol(pct_str, &end, 10);
|
412
373
|
if (errno == ERANGE)
|
@@ -455,7 +416,7 @@ rm_percentage(VALUE arg, double max)
|
|
455
416
|
static VALUE
|
456
417
|
check_num2dbl(VALUE obj)
|
457
418
|
{
|
458
|
-
|
419
|
+
rb_num2dbl(obj);
|
459
420
|
return INT2FIX(1);
|
460
421
|
}
|
461
422
|
|
@@ -469,7 +430,7 @@ check_num2dbl(VALUE obj)
|
|
469
430
|
* @return 0
|
470
431
|
*/
|
471
432
|
static VALUE
|
472
|
-
rescue_not_dbl(VALUE ignored ATTRIBUTE_UNUSED)
|
433
|
+
rescue_not_dbl(VALUE ignored ATTRIBUTE_UNUSED, VALUE raised_exc ATTRIBUTE_UNUSED)
|
473
434
|
{
|
474
435
|
return INT2FIX(0);
|
475
436
|
}
|
@@ -505,7 +466,7 @@ rm_str_to_pct(VALUE str)
|
|
505
466
|
char *pct_str, *end;
|
506
467
|
|
507
468
|
str = rb_rescue(rb_str_to_str, str, rescue_not_str, str);
|
508
|
-
pct_str =
|
469
|
+
pct_str = StringValueCStr(str);
|
509
470
|
errno = 0;
|
510
471
|
pct = strtol(pct_str, &end, 10);
|
511
472
|
|
@@ -541,17 +502,16 @@ double
|
|
541
502
|
rm_fuzz_to_dbl(VALUE fuzz_arg)
|
542
503
|
{
|
543
504
|
double fuzz;
|
544
|
-
char *
|
505
|
+
char *end;
|
545
506
|
int not_num;
|
546
507
|
|
547
|
-
|
548
|
-
(void) rb_protect(arg_is_number, fuzz_arg, ¬_num);
|
549
|
-
|
550
|
-
if (not_num)
|
508
|
+
if (!rm_check_num2dbl(fuzz_arg))
|
551
509
|
{
|
510
|
+
char *fuzz_str;
|
511
|
+
|
552
512
|
// Convert to string, issue error message if failure.
|
553
513
|
fuzz_arg = rb_rescue(rb_str_to_str, fuzz_arg, rescue_not_str, fuzz_arg);
|
554
|
-
fuzz_str =
|
514
|
+
fuzz_str = StringValueCStr(fuzz_arg);
|
555
515
|
errno = 0;
|
556
516
|
fuzz = strtod(fuzz_str, &end);
|
557
517
|
if (errno == ERANGE)
|
@@ -606,11 +566,9 @@ rm_app2quantum(VALUE obj)
|
|
606
566
|
|
607
567
|
if (TYPE(obj) == T_FLOAT)
|
608
568
|
{
|
609
|
-
v =
|
569
|
+
v = rb_Integer(obj);
|
610
570
|
}
|
611
571
|
|
612
|
-
RB_GC_GUARD(v);
|
613
|
-
|
614
572
|
return NUM2QUANTUM(v);
|
615
573
|
}
|
616
574
|
|
@@ -632,8 +590,8 @@ rm_acquire_image(ImageInfo *info)
|
|
632
590
|
|
633
591
|
exception = AcquireExceptionInfo();
|
634
592
|
new_image = AcquireImage(info, exception);
|
635
|
-
CHECK_EXCEPTION()
|
636
|
-
|
593
|
+
CHECK_EXCEPTION();
|
594
|
+
DestroyExceptionInfo(exception);
|
637
595
|
return new_image;
|
638
596
|
#else
|
639
597
|
return AcquireImage(info);
|
@@ -683,9 +641,9 @@ rm_pixelcolor_to_color_name(Image *image, PixelColor *color)
|
|
683
641
|
pp.colorspace = image->colorspace;
|
684
642
|
#endif
|
685
643
|
|
686
|
-
|
687
|
-
CHECK_EXCEPTION()
|
688
|
-
|
644
|
+
QueryColorname(image, &pp, X11Compliance, name, exception);
|
645
|
+
CHECK_EXCEPTION();
|
646
|
+
DestroyExceptionInfo(exception);
|
689
647
|
|
690
648
|
return rb_str_new2(name);
|
691
649
|
}
|
@@ -726,7 +684,7 @@ rm_pixelcolor_to_color_name_info(Info *info, PixelColor *color)
|
|
726
684
|
#endif
|
727
685
|
|
728
686
|
color_name = rm_pixelcolor_to_color_name(image, color);
|
729
|
-
|
687
|
+
DestroyImage(image);
|
730
688
|
|
731
689
|
return color_name;
|
732
690
|
}
|
@@ -765,13 +723,13 @@ rm_set_magickpixel(MagickPixel *pp, const char *color)
|
|
765
723
|
exception = AcquireExceptionInfo();
|
766
724
|
|
767
725
|
#if defined(IMAGEMAGICK_7)
|
768
|
-
|
726
|
+
QueryColorCompliance(color, AllCompliance, pp, exception);
|
769
727
|
#else
|
770
|
-
|
728
|
+
QueryMagickColor(color, pp, exception);
|
771
729
|
#endif
|
772
730
|
// This exception is ignored because the color comes from places where we control
|
773
731
|
// the value and it is very unlikely that an exception will be thrown.
|
774
|
-
|
732
|
+
DestroyExceptionInfo(exception);
|
775
733
|
}
|
776
734
|
|
777
735
|
/**
|
@@ -785,10 +743,11 @@ rm_set_magickpixel(MagickPixel *pp, const char *color)
|
|
785
743
|
*
|
786
744
|
* @param image the image
|
787
745
|
* @param temp_name the temporary name to use
|
746
|
+
* @param temp_name_l the length of temp_name
|
788
747
|
* @return the "filename" of the registered image
|
789
748
|
*/
|
790
749
|
void
|
791
|
-
rm_write_temp_image(Image *image, char *temp_name)
|
750
|
+
rm_write_temp_image(Image *image, char *temp_name, size_t temp_name_l)
|
792
751
|
{
|
793
752
|
|
794
753
|
#define TMPNAM_CLASS_VAR "@@_tmpnam_"
|
@@ -815,11 +774,11 @@ rm_write_temp_image(Image *image, char *temp_name)
|
|
815
774
|
|
816
775
|
id += 1;
|
817
776
|
rb_cv_set(Module_Magick, TMPNAM_CLASS_VAR, INT2FIX(id));
|
818
|
-
|
777
|
+
snprintf(temp_name, temp_name_l, "mpri:%d", id);
|
819
778
|
|
820
779
|
// Omit "mpri:" from filename to form the key
|
821
780
|
okay = SetImageRegistry(ImageRegistryType, temp_name+5, image, exception);
|
822
|
-
CHECK_EXCEPTION()
|
781
|
+
CHECK_EXCEPTION();
|
823
782
|
DestroyExceptionInfo(exception);
|
824
783
|
if (!okay)
|
825
784
|
{
|
@@ -890,7 +849,7 @@ rm_magick_error(const char *msg)
|
|
890
849
|
mesg = rb_str_new2(msg);
|
891
850
|
|
892
851
|
exc = rb_funcall(Class_ImageMagickError, rm_ID_new, 2, mesg, Qnil);
|
893
|
-
|
852
|
+
rb_funcall(rb_cObject, rb_intern("raise"), 1, exc);
|
894
853
|
|
895
854
|
RB_GC_GUARD(exc);
|
896
855
|
RB_GC_GUARD(mesg);
|
@@ -899,19 +858,12 @@ rm_magick_error(const char *msg)
|
|
899
858
|
|
900
859
|
/**
|
901
860
|
* Initialize a new ImageMagickError object - store the "loc" string in the
|
902
|
-
*
|
903
|
-
*
|
904
|
-
* Ruby usage:
|
905
|
-
* - @verbatim ImageMagickError#initialize(msg) @endverbatim
|
906
|
-
* - @verbatim ImageMagickError#initialize(msg, loc) @endverbatim
|
907
|
-
*
|
908
|
-
* Notes:
|
909
|
-
* - Default loc is nil
|
861
|
+
* magick_location instance variable.
|
910
862
|
*
|
911
|
-
* @
|
912
|
-
*
|
913
|
-
*
|
914
|
-
*
|
863
|
+
* @overload initialize(msg, loc = nil)
|
864
|
+
* @param msg [String] the exception message
|
865
|
+
* @param loc [String] the location stored in the magick_location instance variable
|
866
|
+
* @return [Magick::ImageMagickError] self
|
915
867
|
*/
|
916
868
|
VALUE
|
917
869
|
ImageMagickError_initialize(int argc, VALUE *argv, VALUE self)
|
@@ -933,8 +885,8 @@ ImageMagickError_initialize(int argc, VALUE *argv, VALUE self)
|
|
933
885
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 2)", argc);
|
934
886
|
}
|
935
887
|
|
936
|
-
|
937
|
-
|
888
|
+
rb_call_super(super_argc, (const VALUE *)super_argv);
|
889
|
+
rb_iv_set(self, "@"MAGICK_LOC, extra);
|
938
890
|
|
939
891
|
RB_GC_GUARD(extra);
|
940
892
|
|
@@ -960,8 +912,8 @@ rm_get_property(const Image *img, const char *property)
|
|
960
912
|
|
961
913
|
exception = AcquireExceptionInfo();
|
962
914
|
result = GetImageProperty(img, property, exception);
|
963
|
-
CHECK_EXCEPTION()
|
964
|
-
|
915
|
+
CHECK_EXCEPTION();
|
916
|
+
DestroyExceptionInfo(exception);
|
965
917
|
return result;
|
966
918
|
#else
|
967
919
|
return GetImageProperty(img, property);
|
@@ -988,8 +940,8 @@ rm_set_property(Image *image, const char *property, const char *value)
|
|
988
940
|
|
989
941
|
exception = AcquireExceptionInfo();
|
990
942
|
okay = SetImageProperty(image, property, value, exception);
|
991
|
-
CHECK_EXCEPTION()
|
992
|
-
|
943
|
+
CHECK_EXCEPTION();
|
944
|
+
DestroyExceptionInfo(exception);
|
993
945
|
return okay;
|
994
946
|
#else
|
995
947
|
return SetImageProperty(image, property, value);
|
@@ -1008,16 +960,17 @@ rm_set_property(Image *image, const char *property, const char *value)
|
|
1008
960
|
*/
|
1009
961
|
void rm_set_user_artifact(Image *images, Info *info)
|
1010
962
|
{
|
1011
|
-
Image *image;
|
1012
963
|
const char *value;
|
1013
964
|
|
1014
965
|
value = GetImageOption(info, "user");
|
1015
966
|
if (value)
|
1016
967
|
{
|
968
|
+
Image *image;
|
969
|
+
|
1017
970
|
image = GetFirstImageInList(images);
|
1018
971
|
while (image)
|
1019
972
|
{
|
1020
|
-
|
973
|
+
SetImageArtifact(image, "user", value);
|
1021
974
|
image = GetNextImageInList(image);
|
1022
975
|
}
|
1023
976
|
}
|
@@ -1049,7 +1002,7 @@ rm_get_optional_arguments(VALUE img)
|
|
1049
1002
|
optional_method_arguments = rb_const_get_from(Module_Magick, rb_intern("OptionalMethodArguments"));
|
1050
1003
|
argv[0] = img;
|
1051
1004
|
opt_args = rb_class_new_instance(1, argv, optional_method_arguments);
|
1052
|
-
|
1005
|
+
rb_obj_instance_eval(0, NULL, opt_args);
|
1053
1006
|
}
|
1054
1007
|
|
1055
1008
|
RB_GC_GUARD(optional_method_arguments);
|
@@ -1070,17 +1023,18 @@ rm_get_optional_arguments(VALUE img)
|
|
1070
1023
|
static void copy_options(Image *image, Info *info)
|
1071
1024
|
{
|
1072
1025
|
char property[MaxTextExtent];
|
1073
|
-
const char *
|
1026
|
+
const char *option;
|
1074
1027
|
|
1075
1028
|
ResetImageOptionIterator(info);
|
1076
1029
|
for (option = GetNextImageOption(info); option; option = GetNextImageOption(info))
|
1077
1030
|
{
|
1078
|
-
|
1031
|
+
const char *value;
|
1032
|
+
|
1033
|
+
value = GetImageOption(info, option);
|
1079
1034
|
if (value)
|
1080
1035
|
{
|
1081
|
-
|
1082
|
-
property
|
1083
|
-
(void) SetImageArtifact(image, property, value);
|
1036
|
+
strlcpy(property, value, sizeof(property));
|
1037
|
+
SetImageArtifact(image, property, value);
|
1084
1038
|
}
|
1085
1039
|
}
|
1086
1040
|
}
|
@@ -1106,13 +1060,13 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1106
1060
|
|
1107
1061
|
// The option strings will be set only when their attribute values were
|
1108
1062
|
// set in the optional argument block.
|
1109
|
-
option = GetImageOption(info,"background");
|
1063
|
+
option = GetImageOption(info, "background");
|
1110
1064
|
if (option)
|
1111
1065
|
{
|
1112
1066
|
image->background_color = info->background_color;
|
1113
1067
|
}
|
1114
1068
|
|
1115
|
-
option = GetImageOption(info,"bordercolor");
|
1069
|
+
option = GetImageOption(info, "bordercolor");
|
1116
1070
|
if (option)
|
1117
1071
|
{
|
1118
1072
|
image->border_color = info->border_color;
|
@@ -1126,7 +1080,7 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1126
1080
|
// We should not throw an exception in this method because we will
|
1127
1081
|
// leak memory in the place where this method is called. And that is
|
1128
1082
|
// why the exception is being ignored here.
|
1129
|
-
|
1083
|
+
DestroyExceptionInfo(exception);
|
1130
1084
|
#else
|
1131
1085
|
SetImageColorspace(image, info->colorspace);
|
1132
1086
|
#endif
|
@@ -1195,7 +1149,7 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1195
1149
|
image->interlace = info->interlace;
|
1196
1150
|
}
|
1197
1151
|
|
1198
|
-
option = GetImageOption(info,"mattecolor");
|
1152
|
+
option = GetImageOption(info, "mattecolor");
|
1199
1153
|
if (option)
|
1200
1154
|
{
|
1201
1155
|
image->matte_color = info->matte_color;
|
@@ -1208,7 +1162,7 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1208
1162
|
|
1209
1163
|
if (info->page)
|
1210
1164
|
{
|
1211
|
-
|
1165
|
+
ParseAbsoluteGeometry(info->page, &image->page);
|
1212
1166
|
}
|
1213
1167
|
|
1214
1168
|
if (info->quality != 0UL)
|
@@ -1225,7 +1179,7 @@ void rm_sync_image_options(Image *image, Info *info)
|
|
1225
1179
|
option = GetImageOption(info, "tile-offset");
|
1226
1180
|
if (option)
|
1227
1181
|
{
|
1228
|
-
|
1182
|
+
ParseAbsoluteGeometry(option, &image->tile_offset);
|
1229
1183
|
}
|
1230
1184
|
|
1231
1185
|
option = GetImageOption(info, "transparent");
|
@@ -1308,10 +1262,10 @@ rm_exif_by_entry(Image *image)
|
|
1308
1262
|
ExceptionInfo *exception;
|
1309
1263
|
|
1310
1264
|
exception = AcquireExceptionInfo();
|
1311
|
-
|
1312
|
-
CHECK_EXCEPTION()
|
1265
|
+
GetImageProperty(image, "exif:*", exception);
|
1266
|
+
CHECK_EXCEPTION();
|
1313
1267
|
#else
|
1314
|
-
|
1268
|
+
GetImageProperty(image, "exif:*");
|
1315
1269
|
#endif
|
1316
1270
|
|
1317
1271
|
ResetImagePropertyIterator(image);
|
@@ -1321,7 +1275,7 @@ rm_exif_by_entry(Image *image)
|
|
1321
1275
|
while (property)
|
1322
1276
|
{
|
1323
1277
|
// ignore properties that don't start with "exif:"
|
1324
|
-
property_l =
|
1278
|
+
property_l = rm_strnlen_s(property, MaxTextExtent);
|
1325
1279
|
if (property_l > 5 && rm_strncasecmp(property, "exif:", 5) == 0)
|
1326
1280
|
{
|
1327
1281
|
if (len > 0)
|
@@ -1331,14 +1285,14 @@ rm_exif_by_entry(Image *image)
|
|
1331
1285
|
len += property_l - 5;
|
1332
1286
|
#if defined(IMAGEMAGICK_7)
|
1333
1287
|
value = GetImageProperty(image, property, exception);
|
1334
|
-
CHECK_EXCEPTION()
|
1288
|
+
CHECK_EXCEPTION();
|
1335
1289
|
#else
|
1336
1290
|
value = GetImageProperty(image, property);
|
1337
1291
|
#endif
|
1338
1292
|
if (value)
|
1339
1293
|
{
|
1340
1294
|
// add 1 for the = between property and value
|
1341
|
-
len += 1 +
|
1295
|
+
len += 1 + rm_strnlen_s(value, MaxTextExtent);
|
1342
1296
|
}
|
1343
1297
|
}
|
1344
1298
|
property = GetNextImageProperty(image);
|
@@ -1347,7 +1301,7 @@ rm_exif_by_entry(Image *image)
|
|
1347
1301
|
if (len == 0)
|
1348
1302
|
{
|
1349
1303
|
#if defined(IMAGEMAGICK_7)
|
1350
|
-
|
1304
|
+
DestroyExceptionInfo(exception);
|
1351
1305
|
#endif
|
1352
1306
|
return Qnil;
|
1353
1307
|
}
|
@@ -1361,7 +1315,7 @@ rm_exif_by_entry(Image *image)
|
|
1361
1315
|
|
1362
1316
|
while (property)
|
1363
1317
|
{
|
1364
|
-
property_l =
|
1318
|
+
property_l = rm_strnlen_s(property, MaxTextExtent);
|
1365
1319
|
if (property_l > 5 && rm_strncasecmp(property, "exif:", 5) == 0)
|
1366
1320
|
{
|
1367
1321
|
if (len > 0)
|
@@ -1382,7 +1336,7 @@ rm_exif_by_entry(Image *image)
|
|
1382
1336
|
#endif
|
1383
1337
|
if (value)
|
1384
1338
|
{
|
1385
|
-
value_l =
|
1339
|
+
value_l = rm_strnlen_s(value, MaxTextExtent);
|
1386
1340
|
str[len++] = '=';
|
1387
1341
|
memcpy(str+len, value, value_l);
|
1388
1342
|
len += value_l;
|
@@ -1392,7 +1346,7 @@ rm_exif_by_entry(Image *image)
|
|
1392
1346
|
}
|
1393
1347
|
|
1394
1348
|
#if defined(IMAGEMAGICK_7)
|
1395
|
-
|
1349
|
+
DestroyExceptionInfo(exception);
|
1396
1350
|
#endif
|
1397
1351
|
|
1398
1352
|
v = rb_str_new(str, len);
|
@@ -1427,10 +1381,10 @@ rm_exif_by_number(Image *image)
|
|
1427
1381
|
ExceptionInfo *exception;
|
1428
1382
|
|
1429
1383
|
exception = AcquireExceptionInfo();
|
1430
|
-
|
1431
|
-
CHECK_EXCEPTION()
|
1384
|
+
GetImageProperty(image, "exif:!", exception);
|
1385
|
+
CHECK_EXCEPTION();
|
1432
1386
|
#else
|
1433
|
-
|
1387
|
+
GetImageProperty(image, "exif:!");
|
1434
1388
|
#endif
|
1435
1389
|
ResetImagePropertyIterator(image);
|
1436
1390
|
property = GetNextImageProperty(image);
|
@@ -1439,7 +1393,7 @@ rm_exif_by_number(Image *image)
|
|
1439
1393
|
while (property)
|
1440
1394
|
{
|
1441
1395
|
// ignore properties that don't start with "#"
|
1442
|
-
property_l =
|
1396
|
+
property_l = rm_strnlen_s(property, MaxTextExtent);
|
1443
1397
|
if (property_l > 1 && property[0] == '#')
|
1444
1398
|
{
|
1445
1399
|
if (len > 0)
|
@@ -1449,14 +1403,14 @@ rm_exif_by_number(Image *image)
|
|
1449
1403
|
len += property_l;
|
1450
1404
|
#if defined(IMAGEMAGICK_7)
|
1451
1405
|
value = GetImageProperty(image, property, exception);
|
1452
|
-
CHECK_EXCEPTION()
|
1406
|
+
CHECK_EXCEPTION();
|
1453
1407
|
#else
|
1454
1408
|
value = GetImageProperty(image, property);
|
1455
1409
|
#endif
|
1456
1410
|
if (value)
|
1457
1411
|
{
|
1458
1412
|
// add 1 for the = between property and value
|
1459
|
-
len += 1 +
|
1413
|
+
len += 1 + rm_strnlen_s(value, MaxTextExtent);
|
1460
1414
|
}
|
1461
1415
|
}
|
1462
1416
|
property = GetNextImageProperty(image);
|
@@ -1465,7 +1419,7 @@ rm_exif_by_number(Image *image)
|
|
1465
1419
|
if (len == 0)
|
1466
1420
|
{
|
1467
1421
|
#if defined(IMAGEMAGICK_7)
|
1468
|
-
|
1422
|
+
DestroyExceptionInfo(exception);
|
1469
1423
|
#endif
|
1470
1424
|
return Qnil;
|
1471
1425
|
}
|
@@ -1479,7 +1433,7 @@ rm_exif_by_number(Image *image)
|
|
1479
1433
|
|
1480
1434
|
while (property)
|
1481
1435
|
{
|
1482
|
-
property_l =
|
1436
|
+
property_l = rm_strnlen_s(property, MaxTextExtent);
|
1483
1437
|
if (property_l > 1 && property[0] == '#')
|
1484
1438
|
{
|
1485
1439
|
if (len > 0)
|
@@ -1500,7 +1454,7 @@ rm_exif_by_number(Image *image)
|
|
1500
1454
|
#endif
|
1501
1455
|
if (value)
|
1502
1456
|
{
|
1503
|
-
value_l =
|
1457
|
+
value_l = rm_strnlen_s(value, MaxTextExtent);
|
1504
1458
|
str[len++] = '=';
|
1505
1459
|
memcpy(str+len, value, value_l);
|
1506
1460
|
len += value_l;
|
@@ -1510,7 +1464,7 @@ rm_exif_by_number(Image *image)
|
|
1510
1464
|
}
|
1511
1465
|
|
1512
1466
|
#if defined(IMAGEMAGICK_7)
|
1513
|
-
|
1467
|
+
DestroyExceptionInfo(exception);
|
1514
1468
|
#endif
|
1515
1469
|
|
1516
1470
|
v = rb_str_new(str, len);
|
@@ -1522,66 +1476,6 @@ rm_exif_by_number(Image *image)
|
|
1522
1476
|
}
|
1523
1477
|
|
1524
1478
|
|
1525
|
-
/**
|
1526
|
-
* Get the values from a Geometry object and return them in C variables.
|
1527
|
-
*
|
1528
|
-
* No Ruby usage (internal function)
|
1529
|
-
*
|
1530
|
-
* Notes:
|
1531
|
-
* - No return value: modifies x, y, width, height, and flag
|
1532
|
-
*
|
1533
|
-
* @param geom the Geometry object
|
1534
|
-
* @param x pointer to the x position of the start of the rectangle
|
1535
|
-
* @param y pointer to the y position of the start of the rectangle
|
1536
|
-
* @param width pointer to the width of the rectangle
|
1537
|
-
* @param height pointer to the height of the rectangle
|
1538
|
-
* @param flag pointer to the Geometry's flag
|
1539
|
-
*/
|
1540
|
-
void
|
1541
|
-
rm_get_geometry(
|
1542
|
-
VALUE geom,
|
1543
|
-
long *x,
|
1544
|
-
long *y,
|
1545
|
-
unsigned long *width,
|
1546
|
-
unsigned long *height,
|
1547
|
-
int *flag)
|
1548
|
-
{
|
1549
|
-
VALUE v;
|
1550
|
-
|
1551
|
-
v = rb_funcall(geom, rm_ID_x, 0);
|
1552
|
-
*x = NUM2LONG(v);
|
1553
|
-
v = rb_funcall(geom, rm_ID_y, 0);
|
1554
|
-
*y = NUM2LONG(v);
|
1555
|
-
v = rb_funcall(geom, rm_ID_width, 0);
|
1556
|
-
*width = NUM2ULONG(v);
|
1557
|
-
v = rb_funcall(geom, rm_ID_height, 0);
|
1558
|
-
*height = NUM2ULONG(v);
|
1559
|
-
|
1560
|
-
// Getting the flag field is a bit more difficult since it's
|
1561
|
-
// supposed to be an instance of the GeometryValue Enum class. We
|
1562
|
-
// may not know the VALUE for the GeometryValue class, and we
|
1563
|
-
// need to check that the flag field is an instance of that class.
|
1564
|
-
if (flag)
|
1565
|
-
{
|
1566
|
-
MagickEnum *magick_enum;
|
1567
|
-
|
1568
|
-
v = rb_funcall(geom, rm_ID_flag, 0);
|
1569
|
-
if (!Class_GeometryValue)
|
1570
|
-
{
|
1571
|
-
Class_GeometryValue = rb_const_get(Module_Magick, rm_ID_GeometryValue);
|
1572
|
-
}
|
1573
|
-
if (CLASS_OF(v) != Class_GeometryValue)
|
1574
|
-
{
|
1575
|
-
rb_raise(rb_eTypeError, "wrong enumeration type - expected %s, got %s"
|
1576
|
-
, rb_class2name(Class_GeometryValue),rb_class2name(CLASS_OF(v)));
|
1577
|
-
}
|
1578
|
-
Data_Get_Struct(v, MagickEnum, magick_enum);
|
1579
|
-
*flag = magick_enum->val;
|
1580
|
-
}
|
1581
|
-
|
1582
|
-
}
|
1583
|
-
|
1584
|
-
|
1585
1479
|
/**
|
1586
1480
|
* Clone an image, handle errors.
|
1587
1481
|
*
|
@@ -1607,7 +1501,7 @@ rm_clone_image(Image *image)
|
|
1607
1501
|
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
1608
1502
|
}
|
1609
1503
|
rm_check_exception(exception, clone, DestroyOnError);
|
1610
|
-
|
1504
|
+
DestroyExceptionInfo(exception);
|
1611
1505
|
|
1612
1506
|
return clone;
|
1613
1507
|
}
|
@@ -1690,7 +1584,7 @@ rm_split(Image *image)
|
|
1690
1584
|
}
|
1691
1585
|
while (image)
|
1692
1586
|
{
|
1693
|
-
|
1587
|
+
RemoveFirstImageFromList(&image);
|
1694
1588
|
}
|
1695
1589
|
}
|
1696
1590
|
|
@@ -1743,7 +1637,7 @@ rm_check_image_exception(Image *imglist, ErrorRetention retention)
|
|
1743
1637
|
rm_check_exception(exception, imglist, retention);
|
1744
1638
|
}
|
1745
1639
|
|
1746
|
-
|
1640
|
+
DestroyExceptionInfo(exception);
|
1747
1641
|
}
|
1748
1642
|
#endif
|
1749
1643
|
|
@@ -1763,7 +1657,7 @@ static void
|
|
1763
1657
|
format_exception(const ExceptionType severity, const char *reason, const char *description, char *msg)
|
1764
1658
|
{
|
1765
1659
|
int len;
|
1766
|
-
memset(msg, 0,
|
1660
|
+
memset(msg, 0, ERROR_MSG_SIZE);
|
1767
1661
|
|
1768
1662
|
len = snprintf(msg, ERROR_MSG_SIZE, "%s%s%s",
|
1769
1663
|
GetLocaleExceptionMessage(severity, reason),
|
@@ -1892,7 +1786,7 @@ handle_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention retent
|
|
1892
1786
|
{
|
1893
1787
|
if (retention == DestroyOnError)
|
1894
1788
|
{
|
1895
|
-
|
1789
|
+
DestroyImageList(imglist);
|
1896
1790
|
imglist = NULL;
|
1897
1791
|
}
|
1898
1792
|
else
|
@@ -1903,7 +1797,7 @@ handle_exception(ExceptionInfo *exception, Image *imglist, ErrorRetention retent
|
|
1903
1797
|
|
1904
1798
|
format_exception(exception->severity, exception->reason, exception->description, msg);
|
1905
1799
|
|
1906
|
-
|
1800
|
+
DestroyExceptionInfo(exception);
|
1907
1801
|
|
1908
1802
|
rm_magick_error(msg);
|
1909
1803
|
}
|
@@ -1947,7 +1841,7 @@ rm_should_raise_exception(ExceptionInfo *exception, const ExceptionRetention ret
|
|
1947
1841
|
|
1948
1842
|
if (retention == DestroyExceptionRetention)
|
1949
1843
|
{
|
1950
|
-
|
1844
|
+
DestroyExceptionInfo(exception);
|
1951
1845
|
}
|
1952
1846
|
|
1953
1847
|
return MagickFalse;
|
@@ -1971,7 +1865,7 @@ rm_raise_exception(ExceptionInfo *exception)
|
|
1971
1865
|
|
1972
1866
|
format_exception(exception->severity, exception->reason, exception->description, msg);
|
1973
1867
|
|
1974
|
-
|
1868
|
+
DestroyExceptionInfo(exception);
|
1975
1869
|
|
1976
1870
|
rm_magick_error(msg);
|
1977
1871
|
}
|