rmagick 2.16.0 → 5.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 +5 -5
- data/.codeclimate.yml +63 -0
- 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/.editorconfig +3 -0
- data/.github/ISSUE_TEMPLATE.md +17 -0
- data/.github/workflows/ci.yml +79 -0
- data/.gitignore +5 -1
- data/.rspec +1 -0
- data/.rubocop.yml +37 -340
- data/.rubocop_todo.yml +448 -0
- data/.yardopts +5 -0
- data/CHANGELOG.md +435 -0
- data/CODE_OF_CONDUCT.md +122 -7
- data/CONTRIBUTING.md +37 -6
- data/Gemfile +0 -6
- data/README.md +317 -0
- data/Rakefile +37 -35
- data/before_install_linux.sh +65 -28
- data/before_install_osx.sh +58 -2
- data/ext/RMagick/extconf.rb +286 -393
- data/ext/RMagick/rmagick.c +106 -111
- data/ext/RMagick/rmagick.h +235 -331
- data/ext/RMagick/rmagick_gvl.h +224 -0
- data/ext/RMagick/rmdraw.c +484 -842
- data/ext/RMagick/rmenum.c +316 -755
- data/ext/RMagick/rmfill.c +281 -191
- data/ext/RMagick/rmilist.c +450 -455
- data/ext/RMagick/rmimage.c +6247 -5289
- data/ext/RMagick/rminfo.c +721 -894
- data/ext/RMagick/rmkinfo.c +228 -0
- data/ext/RMagick/rmmain.c +727 -519
- data/ext/RMagick/rmmontage.c +127 -172
- data/ext/RMagick/rmpixel.c +638 -431
- data/ext/RMagick/rmstruct.c +102 -282
- data/ext/RMagick/rmutil.c +450 -363
- data/lib/rmagick/version.rb +5 -4
- data/lib/rmagick.rb +2 -0
- data/lib/rmagick_internal.rb +349 -413
- data/lib/rvg/clippath.rb +3 -4
- data/lib/rvg/container.rb +30 -22
- data/lib/rvg/deep_equal.rb +11 -11
- data/lib/rvg/describable.rb +2 -2
- data/lib/rvg/embellishable.rb +63 -68
- data/lib/rvg/misc.rb +136 -139
- data/lib/rvg/paint.rb +2 -1
- data/lib/rvg/pathdata.rb +7 -8
- data/lib/rvg/rvg.rb +47 -46
- data/lib/rvg/stretchable.rb +22 -28
- data/lib/rvg/stylable.rb +12 -10
- data/lib/rvg/text.rb +169 -165
- data/lib/rvg/transformable.rb +17 -16
- data/lib/rvg/units.rb +5 -5
- data/rmagick.gemspec +16 -39
- metadata +118 -395
- data/.hound.yml +0 -2
- data/.simplecov +0 -27
- data/.travis.yml +0 -74
- data/Doxyfile +0 -1514
- data/README.textile +0 -251
- data/deprecated/RMagick.rb +0 -6
- 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 -53
- 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 -42
- 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 -20
- 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 -47
- data/doc/ex/get_type_metrics.rb +0 -141
- data/doc/ex/gradientfill.rb +0 -27
- data/doc/ex/grav.rb +0 -45
- data/doc/ex/gravity.rb +0 -80
- 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.wmf +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.wmf +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.wmf +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 -35
- 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 -27
- 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 -125
- data/doc/ex/solarize.rb +0 -11
- data/doc/ex/sparse_color.rb +0 -54
- data/doc/ex/splice.rb +0 -8
- data/doc/ex/spread.rb +0 -11
- data/doc/ex/stegano.rb +0 -55
- 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 -565
- 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 -42
- data/examples/demo.rb +0 -324
- data/examples/describe.rb +0 -43
- data/examples/find_similar_region.rb +0 -34
- data/examples/histogram.rb +0 -321
- data/examples/identify.rb +0 -185
- data/examples/image_opacity.rb +0 -29
- data/examples/import_export.rb +0 -31
- data/examples/pattern_fill.rb +0 -38
- data/examples/rotating_text.rb +0 -44
- 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 -156
- data/spec/rmagick/image/blue_shift_spec.rb +0 -16
- data/spec/rmagick/image/composite_spec.rb +0 -140
- data/spec/rmagick/image/constitute_spec.rb +0 -15
- data/spec/rmagick/image/dispatch_spec.rb +0 -18
- data/spec/rmagick/image/from_blob_spec.rb +0 -14
- data/spec/rmagick/image/ping_spec.rb +0 -14
- data/spec/rmagick/image/properties_spec.rb +0 -29
- data/spec/spec_helper.rb +0 -4
- data/test/Image1.rb +0 -565
- data/test/Image2.rb +0 -1304
- data/test/Image3.rb +0 -1030
- data/test/ImageList1.rb +0 -806
- data/test/ImageList2.rb +0 -385
- data/test/Image_attributes.rb +0 -697
- data/test/Import_Export.rb +0 -121
- data/test/Info.rb +0 -345
- data/test/Magick.rb +0 -321
- data/test/Pixel.rb +0 -116
- data/test/Preview.rb +0 -57
- data/test/cmyk.icm +0 -0
- data/test/srgb.icm +0 -0
- data/test/test_all_basic.rb +0 -38
- data/test/tmpnam_test.rb +0 -50
- data/wercker.yml +0 -10
data/ext/RMagick/rmfill.c
CHANGED
@@ -12,6 +12,11 @@
|
|
12
12
|
|
13
13
|
#include "rmagick.h"
|
14
14
|
|
15
|
+
static void GradientFill_free(void *fill);
|
16
|
+
static size_t GradientFill_memsize(const void *ptr);
|
17
|
+
static void TextureFill_free(void *fill_obj);
|
18
|
+
static size_t TextureFill_memsize(const void *ptr);
|
19
|
+
|
15
20
|
/** Data associated with a GradientFill */
|
16
21
|
typedef struct
|
17
22
|
{
|
@@ -19,8 +24,8 @@ typedef struct
|
|
19
24
|
double y1; /**< y position of first point */
|
20
25
|
double x2; /**< x position of second point */
|
21
26
|
double y2; /**< y position of second point */
|
22
|
-
|
23
|
-
|
27
|
+
PixelColor start_color; /**< the start color */
|
28
|
+
PixelColor stop_color; /**< the stop color */
|
24
29
|
} rm_GradientFill;
|
25
30
|
|
26
31
|
/** Data associated with a TextureFill */
|
@@ -29,49 +34,76 @@ typedef struct
|
|
29
34
|
Image *texture; /**< the texture */
|
30
35
|
} rm_TextureFill;
|
31
36
|
|
37
|
+
const rb_data_type_t rm_gradient_fill_data_type = {
|
38
|
+
"Magick::GradientFill",
|
39
|
+
{ NULL, GradientFill_free, GradientFill_memsize, },
|
40
|
+
0, 0,
|
41
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
42
|
+
};
|
43
|
+
|
44
|
+
const rb_data_type_t rm_texture_fill_data_type = {
|
45
|
+
"Magick::TextureFill",
|
46
|
+
{ NULL, TextureFill_free, TextureFill_memsize, },
|
47
|
+
0, 0,
|
48
|
+
RUBY_TYPED_FROZEN_SHAREABLE,
|
49
|
+
};
|
50
|
+
|
51
|
+
|
52
|
+
DEFINE_GVL_STUB2(SyncAuthenticPixels, Image *, ExceptionInfo *);
|
53
|
+
|
54
|
+
|
32
55
|
/**
|
33
|
-
* Free
|
56
|
+
* Free GradientFill or GradientFill subclass object (except for TextureFill).
|
34
57
|
*
|
35
58
|
* No Ruby usage (internal function)
|
36
59
|
*
|
37
60
|
* @param fill the fill
|
38
61
|
*/
|
39
|
-
static void
|
62
|
+
static void
|
63
|
+
GradientFill_free(void *fill)
|
40
64
|
{
|
41
65
|
xfree(fill);
|
42
66
|
}
|
43
67
|
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Get GradientFill object size.
|
71
|
+
*
|
72
|
+
* No Ruby usage (internal function)
|
73
|
+
*
|
74
|
+
* @param ptr pointer to the GradientFill object
|
75
|
+
*/
|
76
|
+
static size_t
|
77
|
+
GradientFill_memsize(const void *ptr)
|
78
|
+
{
|
79
|
+
return sizeof(rm_GradientFill);
|
80
|
+
}
|
81
|
+
|
82
|
+
|
44
83
|
/**
|
45
84
|
* Create new GradientFill object.
|
46
85
|
*
|
47
|
-
*
|
48
|
-
*
|
49
|
-
* @param class the Ruby class to use
|
50
|
-
* @return a new GradientFill object
|
86
|
+
* @return [Magick::GradientFill] a new GradientFill object
|
51
87
|
*/
|
52
88
|
VALUE
|
53
89
|
GradientFill_alloc(VALUE class)
|
54
90
|
{
|
55
91
|
rm_GradientFill *fill;
|
56
92
|
|
57
|
-
return
|
93
|
+
return TypedData_Make_Struct(class, rm_GradientFill, &rm_gradient_fill_data_type, fill);
|
58
94
|
}
|
59
95
|
|
60
96
|
|
61
97
|
/**
|
62
|
-
*
|
63
|
-
*
|
64
|
-
*
|
65
|
-
*
|
66
|
-
*
|
67
|
-
* @param
|
68
|
-
* @param
|
69
|
-
* @param
|
70
|
-
* @
|
71
|
-
* @param y2 y position of second point
|
72
|
-
* @param start_color the start color
|
73
|
-
* @param stop_color the stop color
|
74
|
-
* @return self
|
98
|
+
* Initialize GradientFill object.
|
99
|
+
*
|
100
|
+
* @param x1 [Float] x position of first point
|
101
|
+
* @param y1 [Float] y position of first point
|
102
|
+
* @param x2 [Float] x position of second point
|
103
|
+
* @param y2 [Float] y position of second point
|
104
|
+
* @param start_color [Magick::Pixel, String] the start color
|
105
|
+
* @param stop_color [Magick::Pixel, String] the stop color
|
106
|
+
* @return [Magick::GradientFill] self
|
75
107
|
*/
|
76
108
|
VALUE
|
77
109
|
GradientFill_initialize(
|
@@ -85,14 +117,14 @@ GradientFill_initialize(
|
|
85
117
|
{
|
86
118
|
rm_GradientFill *fill;
|
87
119
|
|
88
|
-
|
120
|
+
TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
|
89
121
|
|
90
122
|
fill->x1 = NUM2DBL(x1);
|
91
123
|
fill->y1 = NUM2DBL(y1);
|
92
124
|
fill->x2 = NUM2DBL(x2);
|
93
125
|
fill->y2 = NUM2DBL(y2);
|
94
|
-
|
95
|
-
|
126
|
+
Color_to_PixelColor(&fill->start_color, start_color);
|
127
|
+
Color_to_PixelColor(&fill->stop_color, stop_color);
|
96
128
|
|
97
129
|
return self;
|
98
130
|
}
|
@@ -113,17 +145,15 @@ point_fill(
|
|
113
145
|
Image *image,
|
114
146
|
double x0,
|
115
147
|
double y0,
|
116
|
-
|
117
|
-
|
148
|
+
PixelColor *start_color,
|
149
|
+
PixelColor *stop_color)
|
118
150
|
{
|
119
151
|
double steps, distance;
|
120
|
-
|
152
|
+
ssize_t x, y;
|
121
153
|
MagickRealType red_step, green_step, blue_step;
|
122
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
123
154
|
ExceptionInfo *exception;
|
124
155
|
|
125
156
|
exception = AcquireExceptionInfo();
|
126
|
-
#endif
|
127
157
|
|
128
158
|
steps = sqrt((double)((image->columns-x0)*(image->columns-x0)
|
129
159
|
+ (image->rows-y0)*(image->rows-y0)));
|
@@ -132,38 +162,42 @@ point_fill(
|
|
132
162
|
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
133
163
|
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
134
164
|
|
135
|
-
for (y = 0; y < image->rows; y++)
|
165
|
+
for (y = 0; y < (ssize_t) image->rows; y++)
|
136
166
|
{
|
137
|
-
|
138
|
-
|
139
|
-
#if defined(HAVE_QUEUEAUTHENTICPIXELS)
|
140
|
-
row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
|
141
|
-
CHECK_EXCEPTION()
|
167
|
+
#if defined(IMAGEMAGICK_7)
|
168
|
+
Quantum *row_pixels;
|
142
169
|
#else
|
143
|
-
row_pixels
|
144
|
-
rm_check_image_exception(image, RetainOnError);
|
170
|
+
PixelPacket *row_pixels;
|
145
171
|
#endif
|
146
|
-
|
172
|
+
|
173
|
+
row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
|
174
|
+
CHECK_EXCEPTION();
|
175
|
+
|
176
|
+
for (x = 0; x < (ssize_t) image->columns; x++)
|
147
177
|
{
|
148
178
|
distance = sqrt((double)((x-x0)*(x-x0)+(y-y0)*(y-y0)));
|
179
|
+
|
180
|
+
#if defined(IMAGEMAGICK_7)
|
181
|
+
SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
|
182
|
+
SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
|
183
|
+
SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
|
184
|
+
SetPixelAlpha(image, OpaqueAlpha, row_pixels);
|
185
|
+
|
186
|
+
row_pixels += GetPixelChannels(image);
|
187
|
+
#else
|
149
188
|
row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
|
150
189
|
row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
|
151
190
|
row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
|
152
191
|
row_pixels[x].opacity = OpaqueOpacity;
|
192
|
+
#endif
|
153
193
|
}
|
154
194
|
|
155
|
-
|
156
|
-
SyncAuthenticPixels
|
157
|
-
CHECK_EXCEPTION()
|
158
|
-
#else
|
159
|
-
SyncImagePixels(image);
|
160
|
-
rm_check_image_exception(image, RetainOnError);
|
161
|
-
#endif
|
195
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
196
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
197
|
+
CHECK_EXCEPTION();
|
162
198
|
}
|
163
199
|
|
164
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
165
200
|
DestroyExceptionInfo(exception);
|
166
|
-
#endif
|
167
201
|
}
|
168
202
|
|
169
203
|
/**
|
@@ -181,18 +215,18 @@ static void
|
|
181
215
|
vertical_fill(
|
182
216
|
Image *image,
|
183
217
|
double x1,
|
184
|
-
|
185
|
-
|
218
|
+
PixelColor *start_color,
|
219
|
+
PixelColor *stop_color)
|
186
220
|
{
|
187
221
|
double steps;
|
188
|
-
|
189
|
-
PixelPacket *master;
|
222
|
+
ssize_t x, y;
|
190
223
|
MagickRealType red_step, green_step, blue_step;
|
191
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
192
224
|
ExceptionInfo *exception;
|
225
|
+
#if defined(IMAGEMAGICK_6)
|
226
|
+
PixelPacket *master;
|
227
|
+
#endif
|
193
228
|
|
194
229
|
exception = AcquireExceptionInfo();
|
195
|
-
#endif
|
196
230
|
|
197
231
|
steps = FMAX(x1, ((long)image->columns)-x1);
|
198
232
|
|
@@ -208,11 +242,38 @@ vertical_fill(
|
|
208
242
|
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
209
243
|
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
210
244
|
|
245
|
+
|
246
|
+
#if defined(IMAGEMAGICK_7)
|
247
|
+
for (y = 0; y < (ssize_t) image->rows; y++)
|
248
|
+
{
|
249
|
+
Quantum *row_pixels;
|
250
|
+
|
251
|
+
row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
|
252
|
+
CHECK_EXCEPTION();
|
253
|
+
|
254
|
+
for (x = 0; x < (ssize_t) image->columns; x++)
|
255
|
+
{
|
256
|
+
double distance = fabs(x1 - x);
|
257
|
+
SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
|
258
|
+
SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
|
259
|
+
SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
|
260
|
+
SetPixelAlpha(image, OpaqueAlpha, row_pixels);
|
261
|
+
|
262
|
+
row_pixels += GetPixelChannels(image);
|
263
|
+
}
|
264
|
+
|
265
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
266
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
267
|
+
CHECK_EXCEPTION();
|
268
|
+
}
|
269
|
+
|
270
|
+
DestroyExceptionInfo(exception);
|
271
|
+
#else
|
211
272
|
// All the rows are the same. Make a "master row" and simply copy
|
212
273
|
// it to each actual row.
|
213
274
|
master = ALLOC_N(PixelPacket, image->columns);
|
214
275
|
|
215
|
-
for (x = 0; x < image->columns; x++)
|
276
|
+
for (x = 0; x < (ssize_t) image->columns; x++)
|
216
277
|
{
|
217
278
|
double distance = fabs(x1 - x);
|
218
279
|
master[x].red = ROUND_TO_QUANTUM(start_color->red + (red_step * distance));
|
@@ -222,34 +283,32 @@ vertical_fill(
|
|
222
283
|
}
|
223
284
|
|
224
285
|
// Now copy the master row to each actual row.
|
225
|
-
for (y = 0; y < image->rows; y++)
|
286
|
+
for (y = 0; y < (ssize_t) image->rows; y++)
|
226
287
|
{
|
227
288
|
PixelPacket *row_pixels;
|
228
289
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
#endif
|
290
|
+
row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
|
291
|
+
if (rm_should_raise_exception(exception, RetainExceptionRetention))
|
292
|
+
{
|
293
|
+
xfree((void *)master);
|
294
|
+
rm_raise_exception(exception);
|
295
|
+
}
|
236
296
|
|
237
297
|
memcpy(row_pixels, master, image->columns * sizeof(PixelPacket));
|
238
298
|
|
239
|
-
|
240
|
-
SyncAuthenticPixels
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
299
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
300
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
301
|
+
if (rm_should_raise_exception(exception, RetainExceptionRetention))
|
302
|
+
{
|
303
|
+
xfree((void *)master);
|
304
|
+
rm_raise_exception(exception);
|
305
|
+
}
|
246
306
|
}
|
247
307
|
|
248
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
249
308
|
DestroyExceptionInfo(exception);
|
250
|
-
#endif
|
251
309
|
|
252
|
-
xfree((void *)master);
|
310
|
+
xfree((void *) master);
|
311
|
+
#endif
|
253
312
|
}
|
254
313
|
|
255
314
|
/**
|
@@ -266,18 +325,18 @@ static void
|
|
266
325
|
horizontal_fill(
|
267
326
|
Image *image,
|
268
327
|
double y1,
|
269
|
-
|
270
|
-
|
328
|
+
PixelColor *start_color,
|
329
|
+
PixelColor *stop_color)
|
271
330
|
{
|
272
331
|
double steps;
|
273
|
-
|
274
|
-
PixelPacket *master;
|
332
|
+
ssize_t x, y;
|
275
333
|
MagickRealType red_step, green_step, blue_step;
|
276
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
277
334
|
ExceptionInfo *exception;
|
335
|
+
#if defined(IMAGEMAGICK_6)
|
336
|
+
PixelPacket *master;
|
337
|
+
#endif
|
278
338
|
|
279
339
|
exception = AcquireExceptionInfo();
|
280
|
-
#endif
|
281
340
|
|
282
341
|
steps = FMAX(y1, ((long)image->rows)-y1);
|
283
342
|
|
@@ -292,11 +351,37 @@ horizontal_fill(
|
|
292
351
|
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
293
352
|
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
294
353
|
|
354
|
+
#if defined(IMAGEMAGICK_7)
|
355
|
+
for (y = 0; y < (ssize_t) image->rows; y++)
|
356
|
+
{
|
357
|
+
Quantum *row_pixels;
|
358
|
+
|
359
|
+
row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
|
360
|
+
CHECK_EXCEPTION();
|
361
|
+
|
362
|
+
double distance = fabs(y1 - y);
|
363
|
+
for (x = 0; x < (ssize_t) image->columns; x++)
|
364
|
+
{
|
365
|
+
SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
|
366
|
+
SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
|
367
|
+
SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
|
368
|
+
SetPixelAlpha(image, OpaqueAlpha, row_pixels);
|
369
|
+
|
370
|
+
row_pixels += GetPixelChannels(image);
|
371
|
+
}
|
372
|
+
|
373
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
374
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
375
|
+
CHECK_EXCEPTION();
|
376
|
+
}
|
377
|
+
|
378
|
+
DestroyExceptionInfo(exception);
|
379
|
+
#else
|
295
380
|
// All the columns are the same, so make a master column and copy it to
|
296
381
|
// each of the "real" columns.
|
297
382
|
master = ALLOC_N(PixelPacket, image->rows);
|
298
383
|
|
299
|
-
for (y = 0; y < image->rows; y++)
|
384
|
+
for (y = 0; y < (ssize_t) image->rows; y++)
|
300
385
|
{
|
301
386
|
double distance = fabs(y1 - y);
|
302
387
|
master[y].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
|
@@ -305,32 +390,32 @@ horizontal_fill(
|
|
305
390
|
master[y].opacity = OpaqueOpacity;
|
306
391
|
}
|
307
392
|
|
308
|
-
for (x = 0; x < image->columns; x++)
|
393
|
+
for (x = 0; x < (ssize_t) image->columns; x++)
|
309
394
|
{
|
310
395
|
PixelPacket *col_pixels;
|
311
396
|
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
397
|
+
col_pixels = QueueAuthenticPixels(image, x, 0, 1, image->rows, exception);
|
398
|
+
if (rm_should_raise_exception(exception, RetainExceptionRetention))
|
399
|
+
{
|
400
|
+
xfree((void *)master);
|
401
|
+
rm_raise_exception(exception);
|
402
|
+
}
|
403
|
+
|
318
404
|
memcpy(col_pixels, master, image->rows * sizeof(PixelPacket));
|
319
405
|
|
320
|
-
|
321
|
-
SyncAuthenticPixels
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
406
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
407
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
408
|
+
if (rm_should_raise_exception(exception, RetainExceptionRetention))
|
409
|
+
{
|
410
|
+
xfree((void *)master);
|
411
|
+
rm_raise_exception(exception);
|
412
|
+
}
|
327
413
|
}
|
328
414
|
|
329
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
330
415
|
DestroyExceptionInfo(exception);
|
331
|
-
#endif
|
332
416
|
|
333
|
-
xfree((
|
417
|
+
xfree((void *) master);
|
418
|
+
#endif
|
334
419
|
}
|
335
420
|
|
336
421
|
/**
|
@@ -354,18 +439,16 @@ v_diagonal_fill(
|
|
354
439
|
double y1,
|
355
440
|
double x2,
|
356
441
|
double y2,
|
357
|
-
|
358
|
-
|
442
|
+
PixelColor *start_color,
|
443
|
+
PixelColor *stop_color)
|
359
444
|
{
|
360
|
-
|
445
|
+
ssize_t x, y;
|
361
446
|
MagickRealType red_step, green_step, blue_step;
|
362
447
|
double m, b, steps = 0.0;
|
363
448
|
double d1, d2;
|
364
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
365
449
|
ExceptionInfo *exception;
|
366
450
|
|
367
451
|
exception = AcquireExceptionInfo();
|
368
|
-
#endif
|
369
452
|
|
370
453
|
// Compute the equation of the line: y=mx+b
|
371
454
|
m = ((double)(y2 - y1))/((double)(x2 - x1));
|
@@ -379,7 +462,7 @@ v_diagonal_fill(
|
|
379
462
|
|
380
463
|
if (d1 < 0 && d2 < 0)
|
381
464
|
{
|
382
|
-
steps += FMAX(fabs(d1),fabs(d2));
|
465
|
+
steps += FMAX(fabs(d1), fabs(d2));
|
383
466
|
}
|
384
467
|
else if (d1 > (double)image->rows && d2 > (double)image->rows)
|
385
468
|
{
|
@@ -393,7 +476,7 @@ v_diagonal_fill(
|
|
393
476
|
// If the line is entirely > image->rows, swap the start & end color
|
394
477
|
if (steps < 0)
|
395
478
|
{
|
396
|
-
|
479
|
+
PixelColor t = *stop_color;
|
397
480
|
*stop_color = *start_color;
|
398
481
|
*start_color = t;
|
399
482
|
steps = -steps;
|
@@ -403,39 +486,41 @@ v_diagonal_fill(
|
|
403
486
|
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
404
487
|
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
405
488
|
|
406
|
-
for (y = 0; y < image->rows; y++)
|
489
|
+
for (y = 0; y < (ssize_t) image->rows; y++)
|
407
490
|
{
|
408
|
-
|
409
|
-
|
410
|
-
#if defined(HAVE_QUEUEAUTHENTICPIXELS)
|
411
|
-
row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
|
412
|
-
CHECK_EXCEPTION()
|
491
|
+
#if defined(IMAGEMAGICK_7)
|
492
|
+
Quantum *row_pixels;
|
413
493
|
#else
|
414
|
-
row_pixels
|
415
|
-
rm_check_image_exception(image, RetainOnError);
|
494
|
+
PixelPacket *row_pixels;
|
416
495
|
#endif
|
417
|
-
|
496
|
+
|
497
|
+
row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
|
498
|
+
CHECK_EXCEPTION();
|
499
|
+
|
500
|
+
for (x = 0; x < (ssize_t) image->columns; x++)
|
418
501
|
{
|
419
502
|
double distance = (double) abs((int)(y-(m * x + b)));
|
503
|
+
#if defined(IMAGEMAGICK_7)
|
504
|
+
SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
|
505
|
+
SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
|
506
|
+
SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
|
507
|
+
SetPixelAlpha(image, OpaqueAlpha, row_pixels);
|
508
|
+
|
509
|
+
row_pixels += GetPixelChannels(image);
|
510
|
+
#else
|
420
511
|
row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
|
421
512
|
row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
|
422
513
|
row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
|
423
514
|
row_pixels[x].opacity = OpaqueOpacity;
|
515
|
+
#endif
|
424
516
|
}
|
425
517
|
|
426
|
-
|
427
|
-
SyncAuthenticPixels
|
428
|
-
CHECK_EXCEPTION()
|
429
|
-
#else
|
430
|
-
SyncImagePixels(image);
|
431
|
-
rm_check_image_exception(image, RetainOnError);
|
432
|
-
#endif
|
518
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
519
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
520
|
+
CHECK_EXCEPTION();
|
433
521
|
}
|
434
522
|
|
435
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
436
523
|
DestroyExceptionInfo(exception);
|
437
|
-
#endif
|
438
|
-
|
439
524
|
}
|
440
525
|
|
441
526
|
/**
|
@@ -459,18 +544,16 @@ h_diagonal_fill(
|
|
459
544
|
double y1,
|
460
545
|
double x2,
|
461
546
|
double y2,
|
462
|
-
|
463
|
-
|
547
|
+
PixelColor *start_color,
|
548
|
+
PixelColor *stop_color)
|
464
549
|
{
|
465
|
-
|
550
|
+
ssize_t x, y;
|
466
551
|
double m, b, steps = 0.0;
|
467
552
|
MagickRealType red_step, green_step, blue_step;
|
468
553
|
double d1, d2;
|
469
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
470
554
|
ExceptionInfo *exception;
|
471
555
|
|
472
556
|
exception = AcquireExceptionInfo();
|
473
|
-
#endif
|
474
557
|
|
475
558
|
// Compute the equation of the line: y=mx+b
|
476
559
|
m = ((double)(y2 - y1))/((double)(x2 - x1));
|
@@ -486,11 +569,11 @@ h_diagonal_fill(
|
|
486
569
|
// the number of steps.
|
487
570
|
if (d1 < 0 && d2 < 0)
|
488
571
|
{
|
489
|
-
steps += FMAX(fabs(d1),fabs(d2));
|
572
|
+
steps += FMAX(fabs(d1), fabs(d2));
|
490
573
|
}
|
491
574
|
else if (d1 > (double)image->columns && d2 > (double)image->columns)
|
492
575
|
{
|
493
|
-
steps += FMAX(abs((int)(image->columns-d1)),abs((int)(image->columns-d2)));
|
576
|
+
steps += FMAX(abs((int)(image->columns-d1)), abs((int)(image->columns-d2)));
|
494
577
|
}
|
495
578
|
|
496
579
|
d1 = FMAX(d1, image->columns-d1);
|
@@ -500,7 +583,7 @@ h_diagonal_fill(
|
|
500
583
|
// If the line is entirely > image->columns, swap the start & end color
|
501
584
|
if (steps < 0)
|
502
585
|
{
|
503
|
-
|
586
|
+
PixelColor t = *stop_color;
|
504
587
|
*stop_color = *start_color;
|
505
588
|
*start_color = t;
|
506
589
|
steps = -steps;
|
@@ -510,60 +593,59 @@ h_diagonal_fill(
|
|
510
593
|
green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
|
511
594
|
blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
|
512
595
|
|
513
|
-
for (y = 0; y < image->rows; y++)
|
596
|
+
for (y = 0; y < (ssize_t) image->rows; y++)
|
514
597
|
{
|
515
|
-
|
516
|
-
|
517
|
-
#if defined(HAVE_QUEUEAUTHENTICPIXELS)
|
518
|
-
row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
|
519
|
-
CHECK_EXCEPTION()
|
598
|
+
#if defined(IMAGEMAGICK_7)
|
599
|
+
Quantum *row_pixels;
|
520
600
|
#else
|
521
|
-
row_pixels
|
522
|
-
rm_check_image_exception(image, RetainOnError);
|
601
|
+
PixelPacket *row_pixels;
|
523
602
|
#endif
|
524
|
-
|
603
|
+
|
604
|
+
row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
|
605
|
+
CHECK_EXCEPTION();
|
606
|
+
|
607
|
+
for (x = 0; x < (ssize_t) image->columns; x++)
|
525
608
|
{
|
526
609
|
double distance = (double) abs((int)(x-((y-b)/m)));
|
610
|
+
#if defined(IMAGEMAGICK_7)
|
611
|
+
SetPixelRed(image, ROUND_TO_QUANTUM(start_color->red + (distance * red_step)), row_pixels);
|
612
|
+
SetPixelGreen(image, ROUND_TO_QUANTUM(start_color->green + (distance * green_step)), row_pixels);
|
613
|
+
SetPixelBlue(image, ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step)), row_pixels);
|
614
|
+
SetPixelAlpha(image, OpaqueAlpha, row_pixels);
|
615
|
+
|
616
|
+
row_pixels += GetPixelChannels(image);
|
617
|
+
#else
|
527
618
|
row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
|
528
619
|
row_pixels[x].green = ROUND_TO_QUANTUM(start_color->green + (distance * green_step));
|
529
620
|
row_pixels[x].blue = ROUND_TO_QUANTUM(start_color->blue + (distance * blue_step));
|
530
621
|
row_pixels[x].opacity = OpaqueOpacity;
|
622
|
+
#endif
|
531
623
|
}
|
532
624
|
|
533
|
-
|
534
|
-
SyncAuthenticPixels
|
535
|
-
CHECK_EXCEPTION()
|
536
|
-
#else
|
537
|
-
SyncImagePixels(image);
|
538
|
-
rm_check_image_exception(image, RetainOnError);
|
539
|
-
#endif
|
625
|
+
GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
|
626
|
+
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
|
627
|
+
CHECK_EXCEPTION();
|
540
628
|
}
|
541
629
|
|
542
|
-
#if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
|
543
630
|
DestroyExceptionInfo(exception);
|
544
|
-
#endif
|
545
631
|
}
|
546
632
|
|
547
633
|
/**
|
548
634
|
* Call GradientFill with the start and stop colors specified when this fill
|
549
635
|
* object was created.
|
550
636
|
*
|
551
|
-
*
|
552
|
-
*
|
553
|
-
*
|
554
|
-
* @param self this object
|
555
|
-
* @param image_obj the image
|
556
|
-
* @return self
|
637
|
+
* @param image_obj [Magick::Image] the image to fill
|
638
|
+
* @return [Magick::GradientFill] self
|
557
639
|
*/
|
558
640
|
VALUE
|
559
641
|
GradientFill_fill(VALUE self, VALUE image_obj)
|
560
642
|
{
|
561
643
|
rm_GradientFill *fill;
|
562
644
|
Image *image;
|
563
|
-
|
645
|
+
PixelColor start_color, stop_color;
|
564
646
|
double x1, y1, x2, y2; // points on the line
|
565
647
|
|
566
|
-
|
648
|
+
TypedData_Get_Struct(self, rm_GradientFill, &rm_gradient_fill_data_type, fill);
|
567
649
|
image = rm_check_destroyed(image_obj);
|
568
650
|
|
569
651
|
x1 = fill->x1;
|
@@ -626,49 +708,51 @@ GradientFill_fill(VALUE self, VALUE image_obj)
|
|
626
708
|
* @param fill_obj the TextureFill
|
627
709
|
*/
|
628
710
|
static void
|
629
|
-
|
711
|
+
TextureFill_free(void *fill_obj)
|
630
712
|
{
|
631
713
|
rm_TextureFill *fill = (rm_TextureFill *)fill_obj;
|
632
714
|
|
633
715
|
// Do not trace destruction
|
634
|
-
|
716
|
+
if (fill->texture)
|
717
|
+
{
|
718
|
+
DestroyImage(fill->texture);
|
719
|
+
}
|
635
720
|
xfree(fill);
|
636
721
|
}
|
637
722
|
|
723
|
+
|
724
|
+
/**
|
725
|
+
* Get TextureFill object size.
|
726
|
+
*
|
727
|
+
* No Ruby usage (internal function)
|
728
|
+
*
|
729
|
+
* @param ptr pointer to the TextureFill object
|
730
|
+
*/
|
731
|
+
static size_t
|
732
|
+
TextureFill_memsize(const void *ptr)
|
733
|
+
{
|
734
|
+
return sizeof(rm_TextureFill);
|
735
|
+
}
|
736
|
+
|
737
|
+
|
638
738
|
/**
|
639
739
|
* Create new TextureFill object.
|
640
740
|
*
|
641
|
-
*
|
642
|
-
*
|
643
|
-
* Notes:
|
644
|
-
* - The texture is an Image or Image *object
|
645
|
-
*
|
646
|
-
* @param class the Ruby class to use
|
647
|
-
* @return a new TextureFill object
|
741
|
+
* @return [Magick::TextureFill] a new TextureFill object
|
648
742
|
*/
|
649
743
|
VALUE
|
650
744
|
TextureFill_alloc(VALUE class)
|
651
745
|
{
|
652
746
|
rm_TextureFill *fill;
|
653
|
-
return
|
654
|
-
, rm_TextureFill
|
655
|
-
, NULL
|
656
|
-
, free_TextureFill
|
657
|
-
, fill);
|
747
|
+
return TypedData_Make_Struct(class, rm_TextureFill, &rm_texture_fill_data_type, fill);
|
658
748
|
}
|
659
749
|
|
660
750
|
/**
|
661
|
-
*
|
662
|
-
*
|
663
|
-
* Ruby usage:
|
664
|
-
* - @verbatim TextureFill#initialize(texture) @endverbatim
|
665
|
-
*
|
666
|
-
* Notes:
|
667
|
-
* - The texture is an Image or Image *object
|
751
|
+
* Initialize TextureFill object.
|
668
752
|
*
|
669
|
-
* @param
|
670
|
-
*
|
671
|
-
* @return self
|
753
|
+
* @param texture_arg [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
|
754
|
+
* imagelist, uses the current image.
|
755
|
+
* @return [Magick::TextureFill] self
|
672
756
|
*/
|
673
757
|
VALUE
|
674
758
|
TextureFill_initialize(VALUE self, VALUE texture_arg)
|
@@ -677,13 +761,13 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
|
|
677
761
|
Image *texture;
|
678
762
|
VALUE texture_image;
|
679
763
|
|
680
|
-
|
764
|
+
TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
|
681
765
|
|
682
766
|
texture_image = rm_cur_image(texture_arg);
|
683
767
|
|
684
768
|
// Bump the reference count on the texture image.
|
685
769
|
texture = rm_check_destroyed(texture_image);
|
686
|
-
|
770
|
+
ReferenceImage(texture);
|
687
771
|
|
688
772
|
fill->texture = texture;
|
689
773
|
|
@@ -696,24 +780,30 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
|
|
696
780
|
* Call TextureFill with the texture specified when this fill object was
|
697
781
|
* created.
|
698
782
|
*
|
699
|
-
*
|
700
|
-
*
|
701
|
-
*
|
702
|
-
* @param self this object
|
703
|
-
* @param image_obj the image
|
704
|
-
* @return self
|
783
|
+
* @param image_obj [Magick::Image] the image to fill
|
784
|
+
* @return [Magick::TextureFill] self
|
705
785
|
*/
|
706
786
|
VALUE
|
707
787
|
TextureFill_fill(VALUE self, VALUE image_obj)
|
708
788
|
{
|
709
789
|
rm_TextureFill *fill;
|
710
790
|
Image *image;
|
791
|
+
#if defined(IMAGEMAGICK_7)
|
792
|
+
ExceptionInfo *exception;
|
793
|
+
#endif
|
711
794
|
|
712
795
|
image = rm_check_destroyed(image_obj);
|
713
|
-
|
796
|
+
TypedData_Get_Struct(self, rm_TextureFill, &rm_texture_fill_data_type, fill);
|
714
797
|
|
715
|
-
|
798
|
+
#if defined(IMAGEMAGICK_7)
|
799
|
+
exception = AcquireExceptionInfo();
|
800
|
+
TextureImage(image, fill->texture, exception);
|
801
|
+
CHECK_EXCEPTION();
|
802
|
+
DestroyExceptionInfo(exception);
|
803
|
+
#else
|
804
|
+
TextureImage(image, fill->texture);
|
716
805
|
rm_check_image_exception(image, RetainOnError);
|
806
|
+
#endif
|
717
807
|
|
718
808
|
return self;
|
719
809
|
}
|