rmagick 2.1.0 → 2.2.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.

@@ -6,7 +6,7 @@
6
6
  <meta name="generator" content=
7
7
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
8
8
 
9
- <title>RMagick 2.1.0: RVG Reference: Styles</title>
9
+ <title>RMagick 2.2.0: RVG Reference: Styles</title>
10
10
  <meta http-equiv="Content-Type" content=
11
11
  "text/html; charset=us-ascii" />
12
12
  <meta name="GENERATOR" content="Quanta Plus" />
@@ -27,7 +27,7 @@
27
27
  </head>
28
28
 
29
29
  <body>
30
- <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6>
30
+ <h6 id="header">RMagick 2.2.0 User's Guide and Reference</h6>
31
31
 
32
32
  <div class="nav">
33
33
  &laquo;&nbsp;<a href="rvguse.html">Prev</a> | <a href=
@@ -6,7 +6,7 @@
6
6
  <meta name="generator" content=
7
7
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
8
8
 
9
- <title>RMagick 2.1.0: RVG Reference: RVG::Text Class</title>
9
+ <title>RMagick 2.2.0: RVG Reference: RVG::Text Class</title>
10
10
  <meta http-equiv="Content-Type" content=
11
11
  "text/html; charset=us-ascii" />
12
12
  <meta name="GENERATOR" content="Quanta Plus" />
@@ -33,7 +33,7 @@
33
33
  </head>
34
34
 
35
35
  <body>
36
- <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6>
36
+ <h6 id="header">RMagick 2.2.0 User's Guide and Reference</h6>
37
37
 
38
38
  <div class="nav">
39
39
  &laquo;&nbsp;<a href="rvgclip.html">Prev</a> | <a href=
@@ -6,7 +6,7 @@
6
6
  <meta name="generator" content=
7
7
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
8
8
 
9
- <title>RMagick 2.1.0: RVG Reference: RVG::Tspan Class</title>
9
+ <title>RMagick 2.2.0: RVG Reference: RVG::Tspan Class</title>
10
10
  <meta http-equiv="Content-Type" content=
11
11
  "text/html; charset=us-ascii" />
12
12
  <meta name="GENERATOR" content="Quanta Plus" />
@@ -27,7 +27,7 @@
27
27
  </head>
28
28
 
29
29
  <body>
30
- <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6>
30
+ <h6 id="header">RMagick 2.2.0 User's Guide and Reference</h6>
31
31
 
32
32
  <div class="nav">
33
33
  &laquo;&nbsp;<a href="rvgtext.html">Prev</a> | <a href=
@@ -9,7 +9,7 @@
9
9
  <meta name="generator" content=
10
10
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
11
11
 
12
- <title>RMagick 2.1.0: RVG Tutorial</title>
12
+ <title>RMagick 2.2.0: RVG Tutorial</title>
13
13
  <meta name="GENERATOR" content="Quanta Plus" />
14
14
  <link rel="stylesheet" type="text/css" href="css/doc.css" />
15
15
  <style type="text/css">
@@ -23,7 +23,7 @@
23
23
  </head>
24
24
 
25
25
  <body>
26
- <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6>
26
+ <h6 id="header">RMagick 2.2.0 User's Guide and Reference</h6>
27
27
 
28
28
  <div class="nav">
29
29
  &laquo;&nbsp;<a href="constants.html">Prev</a> | <a href=
@@ -6,7 +6,7 @@
6
6
  <meta name="generator" content=
7
7
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
8
8
 
9
- <title>RMagick 2.1.0: RVG Reference: RVG::Use Class</title>
9
+ <title>RMagick 2.2.0: RVG Reference: RVG::Use Class</title>
10
10
  <meta http-equiv="Content-Type" content=
11
11
  "text/html; charset=us-ascii" />
12
12
  <meta name="GENERATOR" content="Quanta Plus" />
@@ -27,7 +27,7 @@
27
27
  </head>
28
28
 
29
29
  <body>
30
- <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6>
30
+ <h6 id="header">RMagick 2.2.0 User's Guide and Reference</h6>
31
31
 
32
32
  <div class="nav">
33
33
  &laquo;&nbsp;<a href="rvgtspan.html">Prev</a> | <a href=
@@ -6,7 +6,7 @@
6
6
  <meta name="generator" content=
7
7
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
8
8
 
9
- <title>RMagick 2.1.0: RVG Reference: Transforms</title>
9
+ <title>RMagick 2.2.0: RVG Reference: Transforms</title>
10
10
  <meta http-equiv="Content-Type" content=
11
11
  "text/html; charset=us-ascii" />
12
12
  <meta name="GENERATOR" content="Quanta Plus" />
@@ -28,7 +28,7 @@
28
28
  </head>
29
29
 
30
30
  <body>
31
- <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6>
31
+ <h6 id="header">RMagick 2.2.0 User's Guide and Reference</h6>
32
32
 
33
33
  <div class="nav">
34
34
  &laquo;&nbsp;<a href="rvgshape.html">Prev</a> | <a href=
@@ -6,7 +6,7 @@
6
6
  <meta name="generator" content=
7
7
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
8
8
 
9
- <title>RMagick 2.1.0: Miscellaneous classes</title>
9
+ <title>RMagick 2.2.0: Miscellaneous classes</title>
10
10
  <meta http-equiv="Content-Type" content=
11
11
  "text/html; charset=us-ascii" />
12
12
  <meta name="GENERATOR" content="Quanta Plus" />
@@ -27,7 +27,7 @@
27
27
  </head>
28
28
 
29
29
  <body>
30
- <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6>
30
+ <h6 id="header">RMagick 2.2.0 User's Guide and Reference</h6>
31
31
 
32
32
  <div class="nav">
33
33
  &laquo;&nbsp;<a href="draw.html">Prev</a> | <a href=
@@ -6,7 +6,7 @@
6
6
  <meta name="generator" content=
7
7
  "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org" />
8
8
 
9
- <title>RMagick 2.1.0: How to use RMagick</title>
9
+ <title>RMagick 2.2.0: How to use RMagick</title>
10
10
  <meta http-equiv="Content-Type" content=
11
11
  "text/html; charset=us-ascii" />
12
12
  <meta name="GENERATOR" content="Quanta Plus" />
@@ -90,7 +90,7 @@
90
90
  </head>
91
91
 
92
92
  <body>
93
- <h6 id="header">RMagick 2.1.0 User's Guide and Reference</h6>
93
+ <h6 id="header">RMagick 2.2.0 User's Guide and Reference</h6>
94
94
 
95
95
  <div class="nav">
96
96
  &laquo;&nbsp;<a href="index.html">Prev</a> | <a href=
@@ -658,6 +658,11 @@ exit
658
658
 
659
659
  <dd>Compute a new constrained size for the image</dd>
660
660
 
661
+ <dt><a href=
662
+ "image2.html#liquid_rescale">liquid_rescale</a></dt>
663
+
664
+ <dd>Rescale image with seam-carving</dd>
665
+
661
666
  <dt><a href="image2.html#magnify">magnify</a></dt>
662
667
 
663
668
  <dd>Double the size of the image</dd>
@@ -756,7 +761,8 @@ exit
756
761
 
757
762
  <dd>Make the entire image transparent</dd>
758
763
 
759
- <dt><a href="image2.html#opaque">opaque</a></dt>
764
+ <dt><a href="image2.html#opaque">opaque</a>, <a href=
765
+ "image2.html#opaque_channel">opaque_channel</a></dt>
760
766
 
761
767
  <dd>Change all pixels from the specified color to a new
762
768
  color</dd>
@@ -781,7 +787,9 @@ exit
781
787
  <dd>Replace neighboring pixels that are the same color with
782
788
  pixels from a texture image</dd>
783
789
 
784
- <dt><a href="image3.html#transparent">transparent</a></dt>
790
+ <dt><a href=
791
+ "image3.html#paint_transparent">paint_transparent</a>,
792
+ <a href="image3.html#transparent">transparent</a></dt>
785
793
 
786
794
  <dd>Change the opacity value of pixels having the specified
787
795
  color</dd>
@@ -1,4 +1,4 @@
1
- MANIFEST for RMagick-2.1.0 - 18:13:00 01/09/08
1
+ MANIFEST for RMagick-2.2.0 - 19:19:00 01/30/08
2
2
 
3
3
  doc/ilist.html
4
4
  doc/scripts/stripeTables.js
@@ -1,25 +1,12 @@
1
1
  require "mkmf"
2
2
  require "date"
3
3
 
4
- RMAGICK_VERS = "2.0.0"
4
+ RMAGICK_VERS = "2.2.0"
5
5
  MIN_RUBY_VERS = "1.8.2"
6
6
  MIN_RUBY_VERS_NO = MIN_RUBY_VERS.tr(".","").to_i
7
7
  MIN_IM_VERS = "6.3.0"
8
8
  MIN_IM_VERS_NO = MIN_IM_VERS.tr(".","").to_i
9
9
 
10
- SUMMARY = <<"END_SUMMARY"
11
-
12
-
13
- #{"=" * 70}
14
- #{DateTime.now.strftime("%a %d%b%y %T")}
15
- This installation of RMagick #{RMAGICK_VERS} is configured
16
- for Ruby #{RUBY_VERSION} (#{RUBY_PLATFORM}) and ImageMagick 6.3.7.
17
- #{"=" * 70}
18
-
19
-
20
- END_SUMMARY
21
-
22
-
23
10
 
24
11
 
25
12
  # Test for a specific value in an enum type
@@ -104,6 +91,8 @@ if RUBY_PLATFORM !~ /mswin/
104
91
  exit_failure "Can't install RMagick #{RMAGICK_VERS}. You must have ImageMagick #{MIN_IM_VERS} or later.\n"
105
92
  end
106
93
 
94
+ $magick_version = `Magick-config --version`.chomp
95
+
107
96
  # Ensure ImageMagick is not configured for HDRI
108
97
  unless checking_for("HDRI disabled version of ImageMagick") do
109
98
  not (`Magick-config --version`["HDRI"])
@@ -121,12 +110,13 @@ if RUBY_PLATFORM !~ /mswin/
121
110
 
122
111
  else # mswin
123
112
 
124
- `convert -version` =~ /Version: ImageMagick (\d\.\d\.\d+) /
125
- abort "Unable to get ImageMagick version" unless $1
126
- $CFLAGS = "-W3"
127
- $CPPFLAGS = %Q{-I"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include" -I"C:\\Program Files\\ImageMagick-#{$1}-Q8\\include"}
113
+ `convert -version` =~ /Version: ImageMagick (\d\.\d\.\d+) /
114
+ abort "Unable to get ImageMagick version" unless $1
115
+ $magick_version = $1
116
+ $CFLAGS = "-W3"
117
+ $CPPFLAGS = %Q{-I"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include" -I"C:\\Program Files\\ImageMagick-#{$magick_version}-Q8\\include"}
128
118
  # The /link option is required by the Makefile but causes warnings in the mkmf.log file.
129
- $LDFLAGS = %Q{/link /LIBPATH:"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib" /LIBPATH:"C:\\Program Files\\ImageMagick-#{$1}-Q8\\lib" /LIBPATH:"C:\\ruby\\lib"}
119
+ $LDFLAGS = %Q{/link /LIBPATH:"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib" /LIBPATH:"C:\\Program Files\\ImageMagick-#{$magick_version}-Q8\\lib" /LIBPATH:"C:\\ruby\\lib"}
130
120
  $LOCAL_LIBS = 'CORE_RL_magick_.lib X11.lib'
131
121
 
132
122
  end
@@ -172,7 +162,9 @@ have_func("snprintf", headers)
172
162
  "GetNextImageProperty", # 6.3.1
173
163
  "IsHistogramImage", # 6.3.5
174
164
  "LinearStretchImage", # 6.3.1
165
+ "LiquidRescaleImage", # 6.3.8-2
175
166
  "MagickCoreGenesis", # 6.3.4
167
+ "OpaquePaintImageChannel", # 6.3.7-10
176
168
  "PolaroidImage", # 6.3.1-6
177
169
  "RecolorImage", # 6.3.1-3
178
170
  "ResetImagePage", # 6.3.3
@@ -181,6 +173,7 @@ have_func("snprintf", headers)
181
173
  "SetImageProperty", # 6.3.1
182
174
  "SetImageRegistry", # 6.3.4-?
183
175
  "SyncImageProfiles", # 6.3.2
176
+ "TransparentPaintImage", # 6.3.7-10
184
177
  ].each do |func|
185
178
  have_func(func, headers)
186
179
  end
@@ -197,18 +190,19 @@ check_sizeof("unsigned long", headers)
197
190
  check_sizeof("Image *", headers)
198
191
 
199
192
 
193
+ have_enum_value("ColorspaceType", "CMYColorspace", headers) # 6.3.5
200
194
  have_enum_values("CompositeOperator", ["ChangeMaskCompositeOp", # 6.3.3
201
195
  "LinearLightCompositeOp", # 6.3.5
202
196
  "DivideCompositeOp"], headers) # 6.3.5
203
197
  have_enum_values("DistortImageMethod", ["ArcDistortion", # 6.3.5-5
204
198
  "PerspectiveProjectionDistortion"], headers) # 6.3.5-9
205
199
  have_enum_values("FilterTypes", ["KaiserFilter", # 6.3.6
206
- "SentinelFilter", # 6.3.6
207
200
  "WelshFilter", # 6.3.6-4
208
201
  "ParzenFilter", # 6.3.6-4
209
202
  "LagrangeFilter", # 6.3.7-2
210
203
  "BohmanFilter", # 6.3.7-2
211
- "BartlettFilter"], headers) # 6.3.7-2
204
+ "BartlettFilter", # 6.3.7-2
205
+ "SentinelFilter"], headers) # 6.3.7-2
212
206
  have_enum_value("InterpolatePixelMethod", "SplineInterpolatePixel", headers) # 6.3.5
213
207
  have_enum_values("InterlaceType", ["GIFInterlace", # 6.3.4
214
208
  "JPEGInterlace", # 6.3.4
@@ -250,5 +244,18 @@ $config_h = "Makefile rmagick.h"
250
244
 
251
245
  create_makefile("RMagick2")
252
246
 
247
+
248
+ SUMMARY = <<"END_SUMMARY"
249
+
250
+
251
+ #{"=" * 70}
252
+ #{DateTime.now.strftime("%a %d%b%y %T")}
253
+ This installation of RMagick #{RMAGICK_VERS} is configured for
254
+ Ruby #{RUBY_VERSION} (#{RUBY_PLATFORM}) and ImageMagick #{$magick_version}
255
+ #{"=" * 70}
256
+
257
+
258
+ END_SUMMARY
259
+
253
260
  Logging::message SUMMARY
254
261
  message SUMMARY
@@ -1,4 +1,4 @@
1
- /* $Id: rmagick.h,v 1.220 2008/01/05 19:24:22 rmagick Exp $ */
1
+ /* $Id: rmagick.h,v 1.223 2008/01/28 22:31:50 rmagick Exp $ */
2
2
  /*=============================================================================
3
3
  | Copyright (C) 2008 by Timothy P. Hunter
4
4
  | Name: rmagick.h
@@ -42,7 +42,7 @@
42
42
  #undef PACKAGE_STRING
43
43
 
44
44
 
45
- #include RUBY_EXTCONF_H
45
+ #include "extconf.h"
46
46
 
47
47
 
48
48
  // For quoting preprocessor symbols
@@ -107,18 +107,18 @@
107
107
 
108
108
  // These macros are needed in 1.9.0 but aren't defined prior to 1.8.6.
109
109
  #if !defined(RSTRING_LEN)
110
- #define RSTRING_LEN(s) (RSTRING(s)->len)
110
+ #define RSTRING_LEN(s) (RSTRING((s))->len)
111
111
  #endif
112
112
  #if !defined(RSTRING_PTR)
113
- #define RSTRING_PTR(s) (RSTRING(s)->ptr)
113
+ #define RSTRING_PTR(s) (RSTRING((s))->ptr)
114
114
  #endif
115
115
 
116
116
  // Backport these two macros to 1.8
117
117
  #if !defined(RARRAY_LEN)
118
- #define RARRAY_LEN(a) RARRAY(a)->len
118
+ #define RARRAY_LEN(a) RARRAY((a))->len
119
119
  #endif
120
120
  #if !defined(RARRAY_PTR)
121
- #define RARRAY_PTR(a) RARRAY(a)->ptr
121
+ #define RARRAY_PTR(a) RARRAY((a))->ptr
122
122
  #endif
123
123
 
124
124
  // ImageLayerMethod replaced MagickLayerMethod starting with 6.3.6
@@ -860,6 +860,7 @@ extern VALUE Image_inspect(VALUE);
860
860
  extern VALUE Image_level2(int, VALUE *, VALUE);
861
861
  extern VALUE Image_level_channel(int, VALUE *, VALUE);
862
862
  extern VALUE Image_linear_stretch(int, VALUE *, VALUE);
863
+ extern VALUE Image_liquid_rescale(int, VALUE *, VALUE);
863
864
  extern VALUE Image__load(VALUE, VALUE);
864
865
  extern VALUE Image_magnify(VALUE);
865
866
  extern VALUE Image_magnify_bang(VALUE);
@@ -877,8 +878,10 @@ extern VALUE Image_normalize(VALUE);
877
878
  extern VALUE Image_normalize_channel(int, VALUE *, VALUE);
878
879
  extern VALUE Image_oil_paint(int, VALUE *, VALUE);
879
880
  extern VALUE Image_opaque(VALUE, VALUE, VALUE);
881
+ extern VALUE Image_opaque_channel(int, VALUE *, VALUE);
880
882
  extern VALUE Image_opaque_q(VALUE);
881
883
  extern VALUE Image_ordered_dither(int, VALUE *, VALUE);
884
+ extern VALUE Image_paint_transparent(int, VALUE *, VALUE);
882
885
  extern VALUE Image_palette_q(VALUE);
883
886
  extern VALUE Image_ping(VALUE, VALUE);
884
887
  extern VALUE Image_pixel_color(int, VALUE *, VALUE);
@@ -1,4 +1,4 @@
1
- /* $Id: rmimage.c,v 1.277 2008/01/08 23:47:33 rmagick Exp $ */
1
+ /* $Id: rmimage.c,v 1.279 2008/01/28 22:31:50 rmagick Exp $ */
2
2
  /*============================================================================\
3
3
  | Copyright (C) 2008 by Timothy P. Hunter
4
4
  | Name: rmimage.c
@@ -5455,6 +5455,54 @@ Image_linear_stretch(int argc, VALUE *argv, VALUE self)
5455
5455
  #endif
5456
5456
  }
5457
5457
 
5458
+
5459
+ /*
5460
+ Method: Image#liquid_rescale(columns, rows, delta_x=0.0, rigidity=0.0)
5461
+ Purpose: Call the LiquidRescaleImage API
5462
+ */
5463
+ VALUE
5464
+ Image_liquid_rescale(int argc, VALUE *argv, VALUE self)
5465
+ {
5466
+ #if defined(HAVE_LIQUIDRESCALEIMAGE)
5467
+ Image *image, *new_image;
5468
+ unsigned long cols, rows;
5469
+ double delta_x = 0.0;
5470
+ double rigidity = 0.0;
5471
+ ExceptionInfo exception;
5472
+
5473
+ image = rm_check_destroyed(self);
5474
+
5475
+ switch (argc)
5476
+ {
5477
+ case 4:
5478
+ rigidity = NUM2DBL(argv[3]);
5479
+ case 3:
5480
+ delta_x = NUM2DBL(argv[2]);
5481
+ case 2:
5482
+ rows = NUM2ULONG(argv[1]);
5483
+ cols = NUM2ULONG(argv[0]);
5484
+ break;
5485
+ default:
5486
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 to 4)", argc);
5487
+ break;
5488
+ }
5489
+
5490
+ GetExceptionInfo(&exception);
5491
+ new_image = LiquidRescaleImage(image, cols, rows, delta_x, rigidity, &exception);
5492
+ rm_check_exception(&exception, new_image, DestroyOnError);
5493
+ DestroyExceptionInfo(&exception);
5494
+ rm_ensure_result(new_image);
5495
+
5496
+ return rm_image_new(new_image);
5497
+ #else
5498
+ argc = argc; // defeat "unused parameter" messages
5499
+ argv = argv;
5500
+ self = self;
5501
+ rm_not_implemented();
5502
+ return(VALUE)0;
5503
+ #endif
5504
+ }
5505
+
5458
5506
  /*
5459
5507
  Method: Image._load
5460
5508
  Purpose: implement marshalling
@@ -6373,6 +6421,7 @@ Image_opaque(VALUE self, VALUE target, VALUE fill)
6373
6421
  Image *image, *new_image;
6374
6422
  MagickPixelPacket target_pp;
6375
6423
  MagickPixelPacket fill_pp;
6424
+ MagickBooleanType okay;
6376
6425
 
6377
6426
  image = rm_check_destroyed(self);
6378
6427
  new_image = rm_clone_image(image);
@@ -6381,12 +6430,99 @@ Image_opaque(VALUE self, VALUE target, VALUE fill)
6381
6430
  Color_to_MagickPixelPacket(image, &target_pp, target);
6382
6431
  Color_to_MagickPixelPacket(image, &fill_pp, fill);
6383
6432
 
6384
- (void) PaintOpaqueImage(new_image, &target_pp, &fill_pp);
6433
+ #if defined(HAVE_OPAQUEPAINTIMAGECHANNEL)
6434
+ okay = OpaquePaintImageChannel(new_image, DefaultChannels, &target_pp, &fill_pp, MagickFalse);
6435
+ #else
6436
+ okay = PaintOpaqueImageChannel(new_image, DefaultChannels, &target_pp, &fill_pp);
6437
+ #endif
6385
6438
  rm_check_image_exception(new_image, DestroyOnError);
6386
6439
 
6440
+ if (!okay)
6441
+ {
6442
+ // Force exception
6443
+ DestroyImage(new_image);
6444
+ rm_ensure_result(NULL);
6445
+ }
6446
+
6387
6447
  return rm_image_new(new_image);
6388
6448
  }
6389
6449
 
6450
+
6451
+ /*
6452
+ Method: Image#opaque_channel
6453
+ Purpose: Improved Image#opaque available in 6.3.7-10
6454
+ Notes: opaque_channel(target, fill, invert=false, fuzz=img.fuzz [, channel...])
6455
+ */
6456
+ VALUE
6457
+ Image_opaque_channel(int argc, VALUE *argv, VALUE self)
6458
+ {
6459
+ #if defined(HAVE_OPAQUEPAINTIMAGECHANNEL)
6460
+ Image *image, *new_image;
6461
+ MagickPixelPacket target_pp, fill_pp;
6462
+ ChannelType channels;
6463
+ double keep, fuzz;
6464
+ MagickBooleanType okay, invert = MagickFalse;
6465
+
6466
+ image = rm_check_destroyed(self);
6467
+ channels = extract_channels(&argc, argv);
6468
+ if (argc > 4)
6469
+ {
6470
+ raise_ChannelType_error(argv[argc-1]);
6471
+ }
6472
+
6473
+ // Default fuzz value is image's fuzz attribute.
6474
+ fuzz = image->fuzz;
6475
+
6476
+ switch (argc)
6477
+ {
6478
+ case 4:
6479
+ fuzz = NUM2DBL(argv[3]);
6480
+ if (fuzz < 0.0)
6481
+ {
6482
+ rb_raise(rb_eArgError, "fuzz must be >= 0.0", fuzz);
6483
+ }
6484
+ case 3:
6485
+ invert = RTEST(argv[2]);
6486
+ case 2:
6487
+ // Allow color name or Pixel
6488
+ Color_to_MagickPixelPacket(image, &fill_pp, argv[1]);
6489
+ Color_to_MagickPixelPacket(image, &target_pp, argv[0]);
6490
+ break;
6491
+ default:
6492
+ rb_raise(rb_eArgError, "wrong number of arguments (got %d, expected 2 or more)", argc);
6493
+ break;
6494
+ }
6495
+
6496
+ new_image = rm_clone_image(image);
6497
+ keep = new_image->fuzz;
6498
+ new_image->fuzz = fuzz;
6499
+
6500
+ okay = OpaquePaintImageChannel(new_image, channels, &target_pp, &fill_pp, invert);
6501
+
6502
+ // Restore saved fuzz value
6503
+ new_image->fuzz = keep;
6504
+ rm_check_image_exception(new_image, DestroyOnError);
6505
+
6506
+ if (!okay)
6507
+ {
6508
+ // Force exception
6509
+ DestroyImage(new_image);
6510
+ rm_ensure_result(NULL);
6511
+ }
6512
+
6513
+ return rm_image_new(new_image);
6514
+
6515
+ #else
6516
+ argc = argc; // defeat "unused parameter" messages
6517
+ argv = argv;
6518
+ self = self;
6519
+ rm_not_implemented();
6520
+ return (VALUE)0;
6521
+ #endif
6522
+ }
6523
+
6524
+
6525
+
6390
6526
  /*
6391
6527
  Method: Image#opaque?
6392
6528
  Purpose: return true if any of the pixels in the image have an opacity
@@ -6509,6 +6645,71 @@ Image_page_eq(VALUE self, VALUE rect)
6509
6645
  return self;
6510
6646
  }
6511
6647
 
6648
+
6649
+ /*
6650
+ Method: Image#paint_transparent(target, opacity=TransparentOpacity, invert=false, fuzz=img.fuzz)
6651
+ Purpose: Improved version of Image#transparent available in 6.3.7-10
6652
+ */
6653
+ VALUE
6654
+ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
6655
+ {
6656
+ #if defined(HAVE_TRANSPARENTPAINTIMAGE)
6657
+ Image *image, *new_image;
6658
+ MagickPixelPacket color;
6659
+ Quantum opacity = TransparentOpacity;
6660
+ double keep, fuzz;
6661
+ MagickBooleanType okay, invert = MagickFalse;
6662
+
6663
+ image = rm_check_destroyed(self);
6664
+
6665
+ // Default fuzz value is image's fuzz attribute.
6666
+ fuzz = image->fuzz;
6667
+
6668
+ switch (argc)
6669
+ {
6670
+ case 4:
6671
+ fuzz = NUM2DBL(argv[3]);
6672
+ case 3:
6673
+ invert = RTEST(argv[2]);
6674
+ case 2:
6675
+ opacity = APP2QUANTUM(argv[1]);
6676
+ case 1:
6677
+ Color_to_MagickPixelPacket(image, &color, argv[0]);
6678
+ break;
6679
+ default:
6680
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 to 4)", argc);
6681
+ break;
6682
+ }
6683
+
6684
+ new_image = rm_clone_image(image);
6685
+
6686
+ // Use fuzz value from caller
6687
+ keep = new_image->fuzz;
6688
+ new_image->fuzz = fuzz;
6689
+
6690
+ okay = TransparentPaintImage(new_image, &color, opacity, invert);
6691
+ new_image->fuzz = keep;
6692
+
6693
+ // Is it possible for TransparentPaintImage to silently fail?
6694
+ rm_check_image_exception(new_image, DestroyOnError);
6695
+ if (!okay)
6696
+ {
6697
+ // Force exception
6698
+ DestroyImage(new_image);
6699
+ rm_ensure_result(NULL);
6700
+ }
6701
+
6702
+ return rm_image_new(new_image);
6703
+ #else
6704
+ argc = argc; // defeat "unused parameter" messages
6705
+ argv = argv;
6706
+ self = self;
6707
+ rm_not_implemented();
6708
+ return (VALUE)0;
6709
+ #endif
6710
+ }
6711
+
6712
+
6512
6713
  /*
6513
6714
  Method: Image#palette?
6514
6715
  Purpose: return true if the image is PseudoClass and has 256 unique
@@ -9095,6 +9296,7 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
9095
9296
  Image *image, *new_image;
9096
9297
  MagickPixelPacket color;
9097
9298
  Quantum opacity = TransparentOpacity;
9299
+ MagickBooleanType okay;
9098
9300
 
9099
9301
  image = rm_check_destroyed(self);
9100
9302
 
@@ -9112,8 +9314,18 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
9112
9314
 
9113
9315
  new_image = rm_clone_image(image);
9114
9316
 
9115
- (void) PaintTransparentImage(new_image, &color, opacity);
9317
+ #if defined(HAVE_TRANSPARENTPAINTIMAGE)
9318
+ okay = TransparentPaintImage(new_image, &color, opacity, MagickFalse);
9319
+ #else
9320
+ okay = PaintTransparentImage(new_image, &color, opacity);
9321
+ #endif
9116
9322
  rm_check_image_exception(new_image, DestroyOnError);
9323
+ if (!okay)
9324
+ {
9325
+ // Force exception
9326
+ DestroyImage(new_image);
9327
+ rm_ensure_result(NULL);
9328
+ }
9117
9329
 
9118
9330
  return rm_image_new(new_image);
9119
9331
  }
@@ -10186,7 +10398,7 @@ ChannelType extract_channels(
10186
10398
  void
10187
10399
  raise_ChannelType_error(VALUE arg)
10188
10400
  {
10189
- rb_raise(rb_eTypeError, "argument needs to be a ChannelType (%s given)"
10401
+ rb_raise(rb_eTypeError, "argument must be a ChannelType value (%s given)"
10190
10402
  , rb_class2name(CLASS_OF(arg)));
10191
10403
  }
10192
10404