rmagick 2.7.2 → 2.8.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.
- data/ChangeLog +12 -0
- data/README.html +7 -7
- data/doc/comtasks.html +2 -2
- data/doc/constants.html +2 -2
- data/doc/draw.html +2 -2
- data/doc/ex/sparse_color.rb +55 -0
- data/doc/ilist.html +2 -2
- data/doc/image1.html +2 -2
- data/doc/image2.html +2 -2
- data/doc/image3.html +92 -22
- data/doc/imageattrs.html +5 -33
- data/doc/imusage.html +2 -2
- data/doc/index.html +3 -3
- data/doc/info.html +75 -4
- data/doc/magick.html +2 -2
- data/doc/optequiv.html +37 -7
- data/doc/rvg.html +2 -2
- data/doc/rvgclip.html +2 -2
- data/doc/rvggroup.html +2 -2
- data/doc/rvgimage.html +2 -2
- data/doc/rvgpattern.html +2 -2
- data/doc/rvgshape.html +2 -2
- data/doc/rvgstyle.html +2 -2
- data/doc/rvgtext.html +2 -2
- data/doc/rvgtspan.html +2 -2
- data/doc/rvgtut.html +2 -2
- data/doc/rvguse.html +2 -2
- data/doc/rvgxform.html +2 -2
- data/doc/struct.html +2 -2
- data/doc/usage.html +8 -2
- data/ext/RMagick/MANIFEST +2 -1
- data/ext/RMagick/extconf.rb +68 -4
- data/ext/RMagick/rmagick.h +9 -3
- data/ext/RMagick/rmimage.c +173 -48
- data/ext/RMagick/rminfo.c +103 -2
- data/ext/RMagick/rmmain.c +10 -7
- data/ext/RMagick/rmutil.c +8 -7
- data/rmagick.gemspec +1 -1
- metadata +3 -2
data/doc/rvgtut.html
CHANGED
@@ -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.
|
12
|
+
<title>RMagick 2.8.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.
|
26
|
+
<h6 id="header">RMagick 2.8.0 User's Guide and Reference</h6>
|
27
27
|
|
28
28
|
<div class="nav">
|
29
29
|
« <a href="constants.html">Prev</a> | <a href=
|
data/doc/rvguse.html
CHANGED
@@ -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.
|
9
|
+
<title>RMagick 2.8.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.
|
30
|
+
<h6 id="header">RMagick 2.8.0 User's Guide and Reference</h6>
|
31
31
|
|
32
32
|
<div class="nav">
|
33
33
|
« <a href="rvgtspan.html">Prev</a> | <a href=
|
data/doc/rvgxform.html
CHANGED
@@ -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.
|
9
|
+
<title>RMagick 2.8.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.
|
31
|
+
<h6 id="header">RMagick 2.8.0 User's Guide and Reference</h6>
|
32
32
|
|
33
33
|
<div class="nav">
|
34
34
|
« <a href="rvgshape.html">Prev</a> | <a href=
|
data/doc/struct.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<meta name="generator" content=
|
7
7
|
"HTML Tidy for Linux/x86 (vers 6 November 2007), see www.w3.org" />
|
8
8
|
|
9
|
-
<title>RMagick 2.
|
9
|
+
<title>RMagick 2.8.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.
|
30
|
+
<h6 id="header">RMagick 2.8.0 User's Guide and Reference</h6>
|
31
31
|
|
32
32
|
<div class="nav">
|
33
33
|
« <a href="draw.html">Prev</a> | <a href=
|
data/doc/usage.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<meta name="generator" content=
|
7
7
|
"HTML Tidy for Linux/x86 (vers 6 November 2007), see www.w3.org" />
|
8
8
|
|
9
|
-
<title>RMagick 2.
|
9
|
+
<title>RMagick 2.8.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.
|
93
|
+
<h6 id="header">RMagick 2.8.0 User's Guide and Reference</h6>
|
94
94
|
|
95
95
|
<div class="nav">
|
96
96
|
« <a href="index.html">Prev</a> | <a href=
|
@@ -793,6 +793,12 @@ exit
|
|
793
793
|
|
794
794
|
<dd>Change the opacity value of pixels having the specified
|
795
795
|
color</dd>
|
796
|
+
|
797
|
+
<dt><a href=
|
798
|
+
"image3.html#transparent_chroma">transparent_chroma</a></dt>
|
799
|
+
|
800
|
+
<dd>Change the opacity value of pixels within the specified
|
801
|
+
range</dd>
|
796
802
|
</dl>
|
797
803
|
|
798
804
|
<h4>Rotate, flip, or shear</h4>
|
data/ext/RMagick/MANIFEST
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
MANIFEST for RMagick-2.
|
1
|
+
MANIFEST for RMagick-2.8.0 - 18:54:01 12/04/08
|
2
2
|
|
3
3
|
doc/ilist.html
|
4
4
|
doc/scripts/stripeTables.js
|
@@ -259,6 +259,7 @@ doc/ex/rectangle.rb
|
|
259
259
|
doc/ex/watermark.rb
|
260
260
|
doc/ex/nonzero.rb
|
261
261
|
doc/ex/Use02.rb
|
262
|
+
doc/ex/sparse_color.rb
|
262
263
|
doc/ex/wet_floor.rb
|
263
264
|
doc/ex/roundrect.rb
|
264
265
|
doc/ex/stegano.rb
|
data/ext/RMagick/extconf.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "mkmf"
|
2
2
|
require "date"
|
3
3
|
|
4
|
-
RMAGICK_VERS = "2.
|
4
|
+
RMAGICK_VERS = "2.8.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"
|
@@ -48,10 +48,43 @@ end
|
|
48
48
|
|
49
49
|
|
50
50
|
|
51
|
+
# Seems like lots of people have multiple versions of ImageMagick installed.
|
52
|
+
def check_multiple_imagemagick_versions()
|
53
|
+
versions = []
|
54
|
+
path = ENV['PATH'].split(File::PATH_SEPARATOR)
|
55
|
+
path.each do |dir|
|
56
|
+
file = File.join(dir, "Magick-config")
|
57
|
+
if File.executable? file
|
58
|
+
vers = `#{file} --version`.chomp.strip
|
59
|
+
prefix = `#{file} --prefix`.chomp.strip
|
60
|
+
versions << [vers, prefix, dir]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
versions.uniq!
|
64
|
+
if versions.size > 1
|
65
|
+
msg = "\nWarning: Found more than one ImageMagick installation. This could cause problems at runtime.\n"
|
66
|
+
versions.each do |vers, prefix, dir|
|
67
|
+
msg << " #{dir}/Magick-config reports version #{vers} is installed in #{prefix}\n"
|
68
|
+
end
|
69
|
+
msg << "Using #{versions[0][0]} from #{versions[0][1]}.\n\n"
|
70
|
+
Logging::message msg
|
71
|
+
message msg
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
51
78
|
if RUBY_PLATFORM =~ /mswin/
|
52
|
-
abort
|
53
|
-
|
54
|
-
|
79
|
+
abort <<END_MSWIN
|
80
|
+
+----------------------------------------------------------------------------+
|
81
|
+
| This rmagick gem is for use only on Linux, BSD, OS X, and similar systems |
|
82
|
+
| that have a gnu or similar toolchain installed. The rmagick-win32 gem is a |
|
83
|
+
| pre-compiled version of RMagick bundled with ImageMagick for use on |
|
84
|
+
| Microsoft Windows systems. The rmagick-win32 gem is available on RubyForge.|
|
85
|
+
| See http://rmagick.rubyforge.org/install-faq.html for more information. |
|
86
|
+
+----------------------------------------------------------------------------+
|
87
|
+
END_MSWIN
|
55
88
|
end
|
56
89
|
|
57
90
|
|
@@ -81,6 +114,8 @@ if RUBY_PLATFORM !~ /mswin/
|
|
81
114
|
exit_failure "Can't install RMagick #{RMAGICK_VERS}. Can't find Magick-config in #{ENV['PATH']}\n"
|
82
115
|
end
|
83
116
|
|
117
|
+
check_multiple_imagemagick_versions()
|
118
|
+
|
84
119
|
# Ensure minimum ImageMagick version
|
85
120
|
unless checking_for("ImageMagick version >= #{MIN_IM_VERS}") do
|
86
121
|
version = `Magick-config --version`.chomp.tr(".","").to_i
|
@@ -162,10 +197,12 @@ have_func("snprintf", headers)
|
|
162
197
|
"ExcerptImage", # 6.3.5-8
|
163
198
|
"ExtentImage", # 6.3.1
|
164
199
|
"FloodfillPaintImage", # 6.3.7
|
200
|
+
"GetAuthenticPixels", # 6.4.5-6
|
165
201
|
"GetImageAlphaChannel", # 6.3.9-2
|
166
202
|
"GetImageProperty", # 6.3.1
|
167
203
|
"GetNextImageProperty", # 6.3.1
|
168
204
|
"GetStringInfoDatum", # 6.3.2
|
205
|
+
"GetVirtualPixels", # 6.4.5-6
|
169
206
|
"InterpretImageProperties", # 6.3.2
|
170
207
|
"IsHistogramImage", # 6.3.5
|
171
208
|
"LevelImageColors", # 6.4.2
|
@@ -187,7 +224,9 @@ have_func("snprintf", headers)
|
|
187
224
|
"SetImageRegistry", # 6.3.4
|
188
225
|
"SparseColorImage", # 6.3.4-?
|
189
226
|
"SyncImageProfiles", # 6.3.2
|
227
|
+
"SyncAuthenticPixels", # 6.4.5-6
|
190
228
|
"TransparentPaintImage", # 6.3.7-10
|
229
|
+
"TransparentPaintImageChroma" # 6.4.5-6
|
191
230
|
].each do |func|
|
192
231
|
have_func(func, headers)
|
193
232
|
end
|
@@ -219,6 +258,31 @@ end
|
|
219
258
|
|
220
259
|
|
221
260
|
|
261
|
+
# 6.4.6-9 or so
|
262
|
+
checking_for("ParseSizeGeometry() new signature") do
|
263
|
+
if try_compile(<<"SRC")
|
264
|
+
#{COMMON_HEADERS}
|
265
|
+
#{cpp_include(headers)}
|
266
|
+
/*top*/
|
267
|
+
int main() {
|
268
|
+
MagickStatusType okay;
|
269
|
+
Image *image;
|
270
|
+
const char *geometry;
|
271
|
+
RectangleInfo *rectangle;
|
272
|
+
ExceptionInfo *exception;
|
273
|
+
okay = ParseSizeGeometry(image, geometry, rectangle, exception);
|
274
|
+
return 0;
|
275
|
+
}
|
276
|
+
SRC
|
277
|
+
$defs.push("-DHAVE_NEWPARSESIZEGEOMETRY")
|
278
|
+
true
|
279
|
+
else
|
280
|
+
false
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
|
285
|
+
|
222
286
|
|
223
287
|
have_struct_member("ImageInfo", "profile", headers) # 6.3.2
|
224
288
|
have_struct_member("Image", "tile_offset", headers) # 6.3.4
|
data/ext/RMagick/rmagick.h
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmagick.h,v 1.
|
1
|
+
/* $Id: rmagick.h,v 1.260 2008/11/23 15:57:15 rmagick Exp $ */
|
2
2
|
/*=============================================================================
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmagick.h
|
@@ -132,6 +132,8 @@
|
|
132
132
|
#define GetStringInfoLength(p) (size_t)((p)->length)
|
133
133
|
#endif
|
134
134
|
|
135
|
+
// IM 6.4.1 replaced AllocateImage with AcquireImage.
|
136
|
+
// Both have the same signature.
|
135
137
|
#if !defined(HAVE_ACQUIREIMAGE)
|
136
138
|
#define AcquireImage(info) AllocateImage(info)
|
137
139
|
#endif
|
@@ -322,8 +324,8 @@ EXTERN VALUE Class_PaintMethod;
|
|
322
324
|
EXTERN VALUE Class_PreviewType;
|
323
325
|
EXTERN VALUE Class_RenderingIntent;
|
324
326
|
EXTERN VALUE Class_ResolutionType;
|
325
|
-
#if defined(
|
326
|
-
EXTERN VALUE
|
327
|
+
#if defined(HAVE_SPARSECOLORIMAGE)
|
328
|
+
EXTERN VALUE Class_SparseColorMethod;
|
327
329
|
#endif
|
328
330
|
EXTERN VALUE Class_SpreadMethod;
|
329
331
|
EXTERN VALUE Class_StorageType;
|
@@ -670,6 +672,8 @@ ATTR_ACCESSOR(Info, density)
|
|
670
672
|
ATTR_ACCESSOR(Info, depth)
|
671
673
|
ATTR_ACCESSOR(Info, dispose)
|
672
674
|
ATTR_ACCESSOR(Info, dither)
|
675
|
+
ATTR_ACCESSOR(Info, encoding)
|
676
|
+
ATTR_ACCESSOR(Info, endian)
|
673
677
|
ATTR_ACCESSOR(Info, extract)
|
674
678
|
ATTR_ACCESSOR(Info, filename)
|
675
679
|
ATTR_ACCESSOR(Info, fill)
|
@@ -700,6 +704,7 @@ ATTR_ACCESSOR(Info, stroke)
|
|
700
704
|
ATTR_ACCESSOR(Info, stroke_width)
|
701
705
|
ATTR_WRITER(Info, texture)
|
702
706
|
ATTR_ACCESSOR(Info, tile_offset)
|
707
|
+
ATTR_ACCESSOR(Info, transparent_color)
|
703
708
|
ATTR_ACCESSOR(Info, undercolor)
|
704
709
|
ATTR_ACCESSOR(Info, units)
|
705
710
|
ATTR_ACCESSOR(Info, view)
|
@@ -988,6 +993,7 @@ extern VALUE Image_tint(int, VALUE *, VALUE);
|
|
988
993
|
extern VALUE Image_to_blob(VALUE);
|
989
994
|
extern VALUE Image_to_color(VALUE, VALUE);
|
990
995
|
extern VALUE Image_transparent(int, VALUE *, VALUE);
|
996
|
+
extern VALUE Image_transparent_chroma(int, VALUE *, VALUE);
|
991
997
|
extern VALUE Image_transpose(VALUE);
|
992
998
|
extern VALUE Image_transpose_bang(VALUE);
|
993
999
|
extern VALUE Image_transverse(VALUE);
|
data/ext/RMagick/rmimage.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmimage.c,v 1.
|
1
|
+
/* $Id: rmimage.c,v 1.334 2008/12/04 23:50:23 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2008 by Timothy P. Hunter
|
4
4
|
| Name: rmimage.c
|
@@ -1554,7 +1554,13 @@ Image_change_geometry(VALUE self, VALUE geom_arg)
|
|
1554
1554
|
|
1555
1555
|
memset(&rect, 0, sizeof(rect));
|
1556
1556
|
|
1557
|
+
#if defined(HAVE_NEWPARSESIZEGEOMETRY)
|
1558
|
+
flags = ParseSizeGeometry(image, geometry, &rect, &image->exception);
|
1559
|
+
#else
|
1557
1560
|
flags = ParseSizeGeometry(image, geometry, &rect);
|
1561
|
+
#endif
|
1562
|
+
rm_check_image_exception(image, RetainOnError);
|
1563
|
+
|
1558
1564
|
if (flags == NoValue)
|
1559
1565
|
{
|
1560
1566
|
rb_raise(rb_eArgError, "invalid geometry string `%s'", geometry);
|
@@ -6342,6 +6348,7 @@ Image_mask(int argc, VALUE *argv, VALUE self)
|
|
6342
6348
|
for (y = 0; y < (long) clip_mask->rows; y++)
|
6343
6349
|
{
|
6344
6350
|
q = GetImagePixels(clip_mask, 0, y, clip_mask->columns, 1);
|
6351
|
+
rm_check_image_exception(clip_mask, DestroyOnError);
|
6345
6352
|
if (!q)
|
6346
6353
|
{
|
6347
6354
|
break;
|
@@ -6357,18 +6364,12 @@ Image_mask(int argc, VALUE *argv, VALUE self)
|
|
6357
6364
|
q->blue = q->opacity;
|
6358
6365
|
q += 1;
|
6359
6366
|
}
|
6360
|
-
|
6361
|
-
|
6362
|
-
(void) DestroyImage(clip_mask);
|
6363
|
-
rm_magick_error("SyncImagePixels failed", NULL);
|
6364
|
-
}
|
6367
|
+
SyncImagePixels(clip_mask);
|
6368
|
+
rm_check_image_exception(clip_mask, DestroyOnError);
|
6365
6369
|
}
|
6366
6370
|
|
6367
|
-
|
6368
|
-
|
6369
|
-
(void) DestroyImage(clip_mask);
|
6370
|
-
rm_magick_error("SetImageStorageClass failed", NULL);
|
6371
|
-
}
|
6371
|
+
SetImageStorageClass(clip_mask, DirectClass);
|
6372
|
+
rm_check_image_exception(clip_mask, DestroyOnError);
|
6372
6373
|
|
6373
6374
|
clip_mask->matte = MagickTrue;
|
6374
6375
|
|
@@ -7479,12 +7480,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
|
|
7479
7480
|
}
|
7480
7481
|
}
|
7481
7482
|
*pixel = new_color;
|
7482
|
-
|
7483
|
+
SyncImagePixels(image);
|
7483
7484
|
rm_check_image_exception(image, RetainOnError);
|
7484
|
-
if (!okay)
|
7485
|
-
{
|
7486
|
-
rb_raise(Class_ImageMagickError, "image pixels could not be synced");
|
7487
|
-
}
|
7488
7485
|
|
7489
7486
|
return Pixel_from_PixelPacket(&old_color);
|
7490
7487
|
}
|
@@ -9218,46 +9215,127 @@ Image_spaceship(VALUE self, VALUE other)
|
|
9218
9215
|
|
9219
9216
|
|
9220
9217
|
/*
|
9221
|
-
Method: Image#sparse_color(method,
|
9218
|
+
Method: Image#sparse_color(method, x1, y1, color [, xn, yn, color] [, channel...])
|
9222
9219
|
Purpose: Call SparseColorInterpolate
|
9220
|
+
Notes: As usual, 'color' can be either a color name or a pixel
|
9223
9221
|
*/
|
9222
|
+
#if defined(HAVE_SPARSECOLORIMAGE)
|
9223
|
+
static unsigned long
|
9224
|
+
count_channels(Image *image, ChannelType *channels)
|
9225
|
+
{
|
9226
|
+
unsigned long ncolors = 0UL;
|
9227
|
+
|
9228
|
+
if (image->colorspace != CMYKColorspace)
|
9229
|
+
{
|
9230
|
+
*channels = (ChannelType) (*channels & ~IndexChannel); /* remove index channels from count */
|
9231
|
+
}
|
9232
|
+
if ( image->matte == MagickFalse )
|
9233
|
+
{
|
9234
|
+
*channels = (ChannelType) (*channels & ~OpacityChannel); /* remove matte/alpha *channels from count */
|
9235
|
+
}
|
9236
|
+
|
9237
|
+
if (*channels & RedChannel)
|
9238
|
+
{
|
9239
|
+
ncolors += 1;
|
9240
|
+
}
|
9241
|
+
if (*channels & GreenChannel)
|
9242
|
+
{
|
9243
|
+
ncolors += 1;
|
9244
|
+
}
|
9245
|
+
if (*channels & BlueChannel)
|
9246
|
+
{
|
9247
|
+
ncolors += 1;
|
9248
|
+
}
|
9249
|
+
if (*channels & IndexChannel)
|
9250
|
+
{
|
9251
|
+
ncolors += 1;
|
9252
|
+
}
|
9253
|
+
if (*channels & OpacityChannel)
|
9254
|
+
{
|
9255
|
+
ncolors += 1;
|
9256
|
+
}
|
9257
|
+
|
9258
|
+
return ncolors;
|
9259
|
+
}
|
9260
|
+
#endif
|
9261
|
+
|
9262
|
+
|
9224
9263
|
VALUE
|
9225
9264
|
Image_sparse_color(int argc, VALUE *argv, VALUE self)
|
9226
9265
|
{
|
9227
|
-
#if defined(
|
9266
|
+
#if defined(HAVE_SPARSECOLORIMAGE)
|
9228
9267
|
Image *image, *new_image;
|
9229
|
-
unsigned long
|
9230
|
-
|
9231
|
-
|
9268
|
+
unsigned long x, nargs, ncolors;
|
9269
|
+
SparseColorMethod method;
|
9270
|
+
int n, exp;
|
9271
|
+
double * volatile args;
|
9232
9272
|
ChannelType channels;
|
9233
|
-
|
9273
|
+
MagickPixelPacket pp;
|
9234
9274
|
ExceptionInfo exception;
|
9235
9275
|
|
9236
9276
|
image = rm_check_destroyed(self);
|
9277
|
+
|
9278
|
+
n = argc;
|
9237
9279
|
channels = extract_channels(&argc, argv);
|
9280
|
+
n -= argc; // n is now the number of channel arguments
|
9238
9281
|
|
9239
|
-
|
9282
|
+
// After the channel arguments have been removed, and not counting the first
|
9283
|
+
// (method) argument, the number of arguments should be a multiple of 3.
|
9284
|
+
if (argc < 4 || argc % 3 != 1)
|
9240
9285
|
{
|
9241
|
-
|
9286
|
+
exp = argc - 1;
|
9287
|
+
exp = (argc + 2) / 3 * 3;
|
9288
|
+
exp = max(exp, 3);
|
9289
|
+
rb_raise(rb_eArgError, "wrong number of arguments (expected at least %d, got %d)", n+exp+1, n+argc);
|
9242
9290
|
}
|
9243
9291
|
|
9244
|
-
|
9245
|
-
|
9292
|
+
// Get the method from the argument list
|
9293
|
+
VALUE_TO_ENUM(argv[0], method, SparseColorMethod);
|
9294
|
+
argv += 1;
|
9295
|
+
argc -= 1;
|
9246
9296
|
|
9247
|
-
//
|
9248
|
-
|
9249
|
-
|
9297
|
+
// A lot of the following code is based on SparseColorOption, in wand/mogrify.c
|
9298
|
+
ncolors = count_channels(image, &channels);
|
9299
|
+
nargs = (argc / 3) * (2 + ncolors);
|
9250
9300
|
|
9251
|
-
|
9301
|
+
// Allocate args from Ruby's memory so that GC will collect it if one of
|
9302
|
+
// the type conversions below raises an exception.
|
9303
|
+
args = ALLOC_N(double, nargs);
|
9304
|
+
memset(args, 0, nargs * sizeof(double));
|
9305
|
+
|
9306
|
+
x = 0;
|
9307
|
+
n = 0;
|
9308
|
+
while (n < argc)
|
9252
9309
|
{
|
9253
|
-
|
9310
|
+
args[x++] = NUM2DBL(argv[n++]);
|
9311
|
+
args[x++] = NUM2DBL(argv[n++]);
|
9312
|
+
Color_to_MagickPixelPacket(NULL, &pp, argv[n++]);
|
9313
|
+
if (channels & RedChannel)
|
9314
|
+
{
|
9315
|
+
args[x++] = pp.red / QuantumRange;
|
9316
|
+
}
|
9317
|
+
if (channels & GreenChannel)
|
9318
|
+
{
|
9319
|
+
args[x++] = pp.green / QuantumRange;
|
9320
|
+
}
|
9321
|
+
if (channels & BlueChannel)
|
9322
|
+
{
|
9323
|
+
args[x++] = pp.blue / QuantumRange;
|
9324
|
+
}
|
9325
|
+
if (channels & IndexChannel)
|
9326
|
+
{
|
9327
|
+
args[x++] = pp.index / QuantumRange;
|
9328
|
+
}
|
9329
|
+
if (channels & OpacityChannel)
|
9330
|
+
{
|
9331
|
+
args[x++] = pp.opacity / QuantumRange;
|
9332
|
+
}
|
9254
9333
|
}
|
9255
9334
|
|
9256
9335
|
GetExceptionInfo(&exception);
|
9257
|
-
new_image =
|
9258
|
-
xfree(
|
9259
|
-
|
9260
|
-
(void) DestroyExceptionInfo(&exception);
|
9336
|
+
new_image = SparseColorImage(image, channels, method, nargs, args, &exception);
|
9337
|
+
xfree(args);
|
9338
|
+
CHECK_EXCEPTION();
|
9261
9339
|
rm_ensure_result(new_image);
|
9262
9340
|
|
9263
9341
|
return rm_image_new(new_image);
|
@@ -9538,12 +9616,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg
|
|
9538
9616
|
pixels[n] = *pixel;
|
9539
9617
|
}
|
9540
9618
|
|
9541
|
-
|
9619
|
+
SyncImagePixels(image);
|
9542
9620
|
rm_check_image_exception(image, RetainOnError);
|
9543
|
-
if (!okay)
|
9544
|
-
{
|
9545
|
-
rb_raise(Class_ImageMagickError, "SyncImagePixels failed. Can't store pixels.");
|
9546
|
-
}
|
9547
9621
|
}
|
9548
9622
|
|
9549
9623
|
return self;
|
@@ -10136,13 +10210,65 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
|
|
10136
10210
|
{
|
10137
10211
|
// Force exception
|
10138
10212
|
DestroyImage(new_image);
|
10139
|
-
|
10213
|
+
rm_magick_error("TransparentPaintImage failed with no explanation", NULL);
|
10140
10214
|
}
|
10141
10215
|
|
10142
10216
|
return rm_image_new(new_image);
|
10143
10217
|
}
|
10144
10218
|
|
10145
10219
|
|
10220
|
+
/*
|
10221
|
+
Method: Image#transparent_chroma(low, high, opacity=TransparentOpacity, invert=false)
|
10222
|
+
Purpose: Call TransparentPaintImageChroma (>= 6.4.5-6)
|
10223
|
+
*/
|
10224
|
+
VALUE
|
10225
|
+
Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
|
10226
|
+
{
|
10227
|
+
#if defined(HAVE_TRANSPARENTPAINTIMAGECHROMA)
|
10228
|
+
Image *image, *new_image;
|
10229
|
+
Quantum opacity = TransparentOpacity;
|
10230
|
+
MagickPixelPacket low, high;
|
10231
|
+
MagickBooleanType invert = MagickFalse;
|
10232
|
+
MagickBooleanType okay;
|
10233
|
+
|
10234
|
+
image = rm_check_destroyed(self);
|
10235
|
+
|
10236
|
+
switch (argc)
|
10237
|
+
{
|
10238
|
+
case 4:
|
10239
|
+
invert = RTEST(argv[3]);
|
10240
|
+
case 3:
|
10241
|
+
opacity = APP2QUANTUM(argv[2]);
|
10242
|
+
case 2:
|
10243
|
+
Color_to_MagickPixelPacket(image, &high, argv[1]);
|
10244
|
+
Color_to_MagickPixelPacket(image, &low, argv[0]);
|
10245
|
+
break;
|
10246
|
+
default:
|
10247
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2, 3 or 4)", argc);
|
10248
|
+
break;
|
10249
|
+
}
|
10250
|
+
|
10251
|
+
new_image = rm_clone_image(image);
|
10252
|
+
|
10253
|
+
okay = TransparentPaintImageChroma(new_image, &low, &high, opacity, invert);
|
10254
|
+
rm_check_image_exception(new_image, DestroyOnError);
|
10255
|
+
if (!okay)
|
10256
|
+
{
|
10257
|
+
// Force exception
|
10258
|
+
DestroyImage(new_image);
|
10259
|
+
rm_magick_error("TransparentPaintImageChroma failed with no explanation", NULL);
|
10260
|
+
}
|
10261
|
+
|
10262
|
+
return rm_image_new(new_image);
|
10263
|
+
#else
|
10264
|
+
rm_not_implemented();
|
10265
|
+
argc = argc;
|
10266
|
+
argv = argv;
|
10267
|
+
self = self;
|
10268
|
+
#endif
|
10269
|
+
}
|
10270
|
+
|
10271
|
+
|
10146
10272
|
/*
|
10147
10273
|
Method: Image#transparent_color
|
10148
10274
|
Purpose: Return the name of the transparent color as a String.
|
@@ -10757,7 +10883,6 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
|
|
10757
10883
|
double rate = 1.0;
|
10758
10884
|
double opacity, step;
|
10759
10885
|
const char *func;
|
10760
|
-
MagickBooleanType okay;
|
10761
10886
|
ExceptionInfo exception;
|
10762
10887
|
|
10763
10888
|
image = rm_check_destroyed(self);
|
@@ -10831,6 +10956,11 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
|
|
10831
10956
|
|
10832
10957
|
p = AcquireImagePixels(reflection, 0, y, image->columns, 1, &exception);
|
10833
10958
|
rm_check_exception(&exception, reflection, RetainOnError);
|
10959
|
+
if (!p)
|
10960
|
+
{
|
10961
|
+
func = "AcquireImagePixels";
|
10962
|
+
goto error;
|
10963
|
+
}
|
10834
10964
|
|
10835
10965
|
q = SetImagePixels(reflection, 0, y, image->columns, 1);
|
10836
10966
|
rm_check_image_exception(reflection, DestroyOnError);
|
@@ -10847,13 +10977,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
|
|
10847
10977
|
q[x].opacity = max(q[x].opacity, (Quantum)opacity);
|
10848
10978
|
}
|
10849
10979
|
|
10850
|
-
|
10980
|
+
SyncImagePixels(reflection);
|
10851
10981
|
rm_check_image_exception(reflection, DestroyOnError);
|
10852
|
-
if (!okay)
|
10853
|
-
{
|
10854
|
-
func = "SyncImagePixels";
|
10855
|
-
goto error;
|
10856
|
-
}
|
10857
10982
|
|
10858
10983
|
opacity += step;
|
10859
10984
|
}
|