rmagick 5.0.0 → 5.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.
- checksums.yaml +4 -4
- data/.devcontainer/devcontainer.json +1 -1
- data/.github/workflows/ci.yml +8 -6
- data/CHANGELOG.md +16 -0
- data/README.md +5 -14
- data/Rakefile +53 -81
- data/before_install_linux.sh +1 -1
- data/before_install_osx.sh +4 -3
- data/ext/RMagick/extconf.rb +21 -21
- data/ext/RMagick/rmagick.h +23 -11
- data/ext/RMagick/rmagick_gvl.h +224 -0
- data/ext/RMagick/rmdraw.c +101 -69
- data/ext/RMagick/rmenum.c +34 -15
- data/ext/RMagick/rmfill.c +77 -16
- data/ext/RMagick/rmilist.c +156 -58
- data/ext/RMagick/rmimage.c +1073 -486
- data/ext/RMagick/rminfo.c +107 -85
- data/ext/RMagick/rmkinfo.c +43 -13
- data/ext/RMagick/rmmain.c +11 -0
- data/ext/RMagick/rmmontage.c +41 -20
- data/ext/RMagick/rmpixel.c +64 -40
- data/ext/RMagick/rmutil.c +7 -3
- data/lib/rmagick/version.rb +3 -1
- data/lib/rmagick.rb +2 -0
- data/lib/rmagick_internal.rb +8 -13
- data/rmagick.gemspec +2 -0
- metadata +21 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63297d93ba6355721cf93286469d8f1d278d553ca80b1c85fa5cefbc50f4217f
|
4
|
+
data.tar.gz: 7d416384fa378aa68c2f16c980e41c63d932a805e488c7cb2bc987c974262736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f03de2614b1b8321b6a26a01e47cbf625455c4bfc5e88c9ae3354bf933d66a63fee9b9205c8a7d72893672e15bb8933bcb2cb8915074e702d74876c4c1c742f
|
7
|
+
data.tar.gz: f9fa937f718148d007962a0b6e2f6588cc157d9a4998fccd942a5c8ac3066ca04bf8e60b79067abe5ee0c2402621cdb571287dca72ecdc6bc45625303ec71dfc
|
data/.github/workflows/ci.yml
CHANGED
@@ -30,12 +30,13 @@ jobs:
|
|
30
30
|
timeout-minutes: 20
|
31
31
|
strategy:
|
32
32
|
matrix:
|
33
|
-
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1']
|
33
|
+
ruby-version: ['2.3', '2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']
|
34
34
|
imagemagick-version:
|
35
35
|
- { full: 6.7.7-10, major-minor: '6.7' }
|
36
36
|
- { full: 6.8.9-10, major-minor: '6.8' }
|
37
|
-
- { full: 6.9.12-
|
38
|
-
- { full: 7.
|
37
|
+
- { full: 6.9.12-70, major-minor: '6.9' }
|
38
|
+
- { full: 7.0.11-14, major-minor: '7.0' }
|
39
|
+
- { full: 7.1.0-55, major-minor: '7.1' }
|
39
40
|
|
40
41
|
name: Linux, Ruby ${{ matrix.ruby-version }}, IM ${{ matrix.imagemagick-version.major-minor }}
|
41
42
|
steps:
|
@@ -58,10 +59,11 @@ jobs:
|
|
58
59
|
timeout-minutes: 20
|
59
60
|
strategy:
|
60
61
|
matrix:
|
61
|
-
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
62
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2']
|
62
63
|
imagemagick-version:
|
63
|
-
- { full: 6.9.12-
|
64
|
-
- { full: 7.
|
64
|
+
- { full: 6.9.12-70, major-minor: '6.9' }
|
65
|
+
- { full: 7.0.11-14, major-minor: '7.0' }
|
66
|
+
- { full: 7.1.0-55, major-minor: '7.1' }
|
65
67
|
|
66
68
|
name: macOS, Ruby ${{ matrix.ruby-version }}, IM ${{ matrix.imagemagick-version.major-minor }}
|
67
69
|
steps:
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,22 @@
|
|
3
3
|
All notable changes to this project are documented in this file.
|
4
4
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
5
5
|
|
6
|
+
## RMagick 5.2.0
|
7
|
+
|
8
|
+
Improvements
|
9
|
+
|
10
|
+
- Add OnAlphaChannel and OffAlphaChannel to the AlphaChannelOption enumeration. (#1377)
|
11
|
+
- Add Ruby 3.2 support (#1370)
|
12
|
+
|
13
|
+
## RMagick 5.1.0
|
14
|
+
|
15
|
+
Improvements
|
16
|
+
|
17
|
+
- Improve multi-thread performance by releasing GVL (#1352)
|
18
|
+
- Add Ractor support (#1349)
|
19
|
+
- Avoid overriding compilation variables (#1365)
|
20
|
+
- Remove pkg-config command dependency (#1366)
|
21
|
+
|
6
22
|
## RMagick 5.0.0
|
7
23
|
|
8
24
|
Improvements
|
data/README.md
CHANGED
@@ -71,33 +71,33 @@ sudo yum install gcc ImageMagick-devel make which
|
|
71
71
|
On Arch Linux, you can run:
|
72
72
|
|
73
73
|
```sh
|
74
|
-
pacman -Syy
|
74
|
+
pacman -Syy imagemagick
|
75
75
|
```
|
76
76
|
|
77
77
|
#### Alpine Linux
|
78
78
|
On Alpine Linux, you can run:
|
79
79
|
|
80
80
|
```
|
81
|
-
apk add
|
81
|
+
apk add imagemagick imagemagick-dev imagemagick-libs
|
82
82
|
```
|
83
83
|
|
84
84
|
or you can run if you would like to use ImageMagick 6:
|
85
85
|
|
86
86
|
```
|
87
|
-
apk add
|
87
|
+
apk add imagemagick6 imagemagick6-dev imagemagick6-libs
|
88
88
|
```
|
89
89
|
|
90
90
|
### macOS
|
91
91
|
On macOS, you can run:
|
92
92
|
|
93
93
|
```sh
|
94
|
-
brew install
|
94
|
+
brew install imagemagick
|
95
95
|
```
|
96
96
|
|
97
97
|
or you can run if you would like to use ImageMagick 6:
|
98
98
|
|
99
99
|
```sh
|
100
|
-
brew install
|
100
|
+
brew install imagemagick@6
|
101
101
|
```
|
102
102
|
|
103
103
|
### Windows
|
@@ -164,15 +164,6 @@ subdirectory of the installation directory for any error messages. These
|
|
164
164
|
messages typically contain enough additional information for you to be able to
|
165
165
|
diagnose the problem. Also see [this FAQ][libmagick-faq].
|
166
166
|
|
167
|
-
On OS X with Homebrew, try (re)installing pkg-config:
|
168
|
-
|
169
|
-
```sh
|
170
|
-
brew uninstall pkg-config
|
171
|
-
brew install pkg-config
|
172
|
-
brew unlink pkg-config
|
173
|
-
brew link pkg-config
|
174
|
-
```
|
175
|
-
|
176
167
|
### Cannot open shared object file
|
177
168
|
|
178
169
|
If you get a message like this:
|
data/Rakefile
CHANGED
@@ -63,26 +63,13 @@ end
|
|
63
63
|
desc 'Release'
|
64
64
|
task release: %i[assert_clean_repo push_and_tag]
|
65
65
|
|
66
|
-
|
67
|
-
|
66
|
+
namespace :website do
|
67
|
+
PATH_TO_LOCAL_WEBSITE_REPOSITORY = File.expand_path('../rmagick.github.io')
|
68
68
|
|
69
|
-
|
70
|
-
require 'find'
|
71
|
-
|
72
|
-
task :redcloth do
|
73
|
-
require 'redcloth'
|
74
|
-
end
|
75
|
-
|
76
|
-
README = 'README.html'
|
77
|
-
MANIFEST = 'ext/RMagick/MANIFEST'
|
78
|
-
|
79
|
-
# Change the version number placeholders in a file.
|
80
|
-
# Returns an array of lines from the file.
|
81
|
-
def reversion(name)
|
69
|
+
def replace_reversion(lines)
|
82
70
|
now = Time.new
|
83
71
|
now = now.strftime('%m/%d/%y')
|
84
72
|
|
85
|
-
lines = File.readlines name
|
86
73
|
lines.each do |line|
|
87
74
|
line.gsub!(/0\.0\.0/, Magick::VERSION)
|
88
75
|
line.gsub!(%r{YY/MM/DD}, now)
|
@@ -90,83 +77,68 @@ namespace :legacy do
|
|
90
77
|
lines
|
91
78
|
end
|
92
79
|
|
93
|
-
|
94
|
-
|
95
|
-
lines =
|
96
|
-
|
97
|
-
mv name, tmp_name
|
98
|
-
begin
|
99
|
-
File.open(name, 'w') { |f| lines.each { |line| f.write line } }
|
100
|
-
rescue StandardError
|
101
|
-
mv tmp_name, name
|
102
|
-
ensure
|
103
|
-
rm tmp_name
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
desc 'Update version in extconf'
|
108
|
-
task :extconf do
|
109
|
-
reversion_file 'ext/RMagick/extconf.rb'
|
110
|
-
end
|
111
|
-
|
112
|
-
desc 'Build README.txt from README.textile using RedCloth'
|
113
|
-
task 'README.txt' => [:redcloth] do
|
114
|
-
reversion_file 'README.textile'
|
115
|
-
body = File.readlines 'README.textile'
|
116
|
-
body = RedCloth.new(body.join).to_html + "\n"
|
117
|
-
File.open('README.txt', 'w') { |f| f.write body }
|
80
|
+
def update_html(input_dir, output_dir, file_name)
|
81
|
+
lines = File.readlines(File.join(input_dir, file_name))
|
82
|
+
lines = replace_reversion(lines)
|
83
|
+
File.open(File.join(output_dir, file_name), 'w') { |f| lines.each { |line| f.write line } }
|
118
84
|
end
|
119
85
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
86
|
+
ENTITY = {
|
87
|
+
'&' => '&',
|
88
|
+
'>' => '>',
|
89
|
+
'<' => '<'
|
90
|
+
}.freeze
|
91
|
+
|
92
|
+
def file_to_html(input_dir, input_file_name, output_dir, output_file_name)
|
93
|
+
File.open(File.join(input_dir, input_file_name)) do |src|
|
94
|
+
File.open(File.join(output_dir, output_file_name), 'w') do |dest|
|
95
|
+
dest.puts <<~END_EXHTMLHEAD
|
96
|
+
<!DOCTYPE public PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
97
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
127
98
|
<head>
|
128
|
-
<
|
129
|
-
<meta http-equiv="Content-Type" content="text/html; charset=
|
130
|
-
<
|
99
|
+
<meta name="generator" content="ex2html.rb" />
|
100
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
101
|
+
<link rel="stylesheet" type="text/css" href="css/popup.css" />
|
102
|
+
<title>RMagick example: #{input_file_name}</title>
|
131
103
|
</head>
|
132
104
|
<body>
|
133
|
-
|
134
|
-
|
135
|
-
|
105
|
+
<h1>#{input_file_name}</h1>
|
106
|
+
<div class="bodybox">
|
107
|
+
<div class="bodyfloat">
|
108
|
+
<pre>
|
109
|
+
END_EXHTMLHEAD
|
110
|
+
|
111
|
+
src.each do |line|
|
112
|
+
line.gsub!(/[&><]/) { |s| ENTITY[s] }
|
113
|
+
dest.puts(line)
|
114
|
+
end
|
115
|
+
|
116
|
+
dest.puts <<~END_EXHTMLTAIL
|
117
|
+
</pre>
|
118
|
+
</div>
|
119
|
+
</div>
|
120
|
+
<div id="close"><a href="javascript:window.close();">Close window</a></div>
|
136
121
|
</body>
|
137
|
-
|
138
|
-
|
122
|
+
</html>
|
123
|
+
END_EXHTMLTAIL
|
124
|
+
end
|
139
125
|
end
|
140
126
|
end
|
141
127
|
|
142
|
-
desc 'Update
|
143
|
-
task :
|
144
|
-
|
145
|
-
|
128
|
+
desc 'Update RMagick website'
|
129
|
+
task :update do
|
130
|
+
unless File.exist?(PATH_TO_LOCAL_WEBSITE_REPOSITORY)
|
131
|
+
puts "Please clone the rmagick.github.io repository to #{PATH_TO_LOCAL_WEBSITE_REPOSITORY}"
|
132
|
+
exit 1
|
146
133
|
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# Remove files we don't want in the tarball.
|
150
|
-
# Ensure files are not executable. (ref: bug #10080)
|
151
|
-
desc "Remove files we don't want in the .gem; ensure files are not executable"
|
152
|
-
task :fix_files do
|
153
|
-
rm 'README.txt', verbose: true
|
154
|
-
chmod 0o644, FileList['doc/*.html', 'doc/ex/*.rb', 'doc/ex/images/*', 'examples/*.rb']
|
155
|
-
end
|
156
134
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
now = now.strftime('%H:%M:%S %m/%d/%y')
|
161
|
-
puts "generating #{MANIFEST}"
|
162
|
-
|
163
|
-
File.open(MANIFEST, 'w') do |f|
|
164
|
-
f.puts "MANIFEST for #{Magick::VERSION} - #{now}\n\n"
|
165
|
-
Find.find('.') do |name|
|
166
|
-
next if File.directory? name
|
135
|
+
Dir.glob('doc/*.html') do |file|
|
136
|
+
update_html('doc', PATH_TO_LOCAL_WEBSITE_REPOSITORY, File.basename(file))
|
137
|
+
end
|
167
138
|
|
168
|
-
|
169
|
-
|
139
|
+
Dir.glob('doc/ex/*.rb') do |file|
|
140
|
+
file_name = File.basename(file)
|
141
|
+
file_to_html('doc/ex', file_name, PATH_TO_LOCAL_WEBSITE_REPOSITORY, "#{file_name}.html")
|
170
142
|
end
|
171
143
|
end
|
172
144
|
end
|
data/before_install_linux.sh
CHANGED
data/before_install_osx.sh
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
set -euox pipefail
|
4
4
|
|
5
|
-
gem install bundler
|
5
|
+
gem install bundler -v 2.3.26 # Bundler 2.4.x has dropped support for Ruby 2.3
|
6
6
|
|
7
7
|
if [ -v STYLE_CHECKS ]; then
|
8
8
|
set +ux
|
@@ -16,7 +16,8 @@ if [ ! -v IMAGEMAGICK_VERSION ]; then
|
|
16
16
|
fi
|
17
17
|
|
18
18
|
export HOMEBREW_NO_AUTO_UPDATE=true
|
19
|
-
brew
|
19
|
+
brew uninstall --force imagemagick imagemagick@6
|
20
|
+
brew install wget ghostscript freetype jpeg little-cms2 libomp libpng libtiff liblqr libtool zlib webp
|
20
21
|
|
21
22
|
export LDFLAGS="-L/usr/local/opt/libxml2/lib -L/usr/local/opt/zlib/lib"
|
22
23
|
export CPPFLAGS="-I/usr/local/opt/libxml2/include -I/usr/local/opt/zlib/include"
|
@@ -42,7 +43,7 @@ build_imagemagick() {
|
|
42
43
|
fi
|
43
44
|
|
44
45
|
cd "${build_dir}"
|
45
|
-
./configure --prefix=/usr/local "${options}"
|
46
|
+
./configure --prefix=/usr/local "${options}" --without-raw
|
46
47
|
make -j
|
47
48
|
}
|
48
49
|
|
data/ext/RMagick/extconf.rb
CHANGED
@@ -2,6 +2,7 @@ lib_dir = File.expand_path('../../lib', File.dirname(__FILE__))
|
|
2
2
|
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
|
3
3
|
require 'rubygems'
|
4
4
|
require 'mkmf'
|
5
|
+
require 'pkg-config'
|
5
6
|
|
6
7
|
module RMagick
|
7
8
|
class Extconf
|
@@ -94,18 +95,20 @@ module RMagick
|
|
94
95
|
check_multiple_imagemagick_versions
|
95
96
|
check_partial_imagemagick_versions
|
96
97
|
|
97
|
-
|
98
|
-
|
98
|
+
original_ldflags = $LDFLAGS.dup
|
99
|
+
|
100
|
+
libdir = PKGConfig.libs_only_L($magick_package).chomp.sub('-L', '')
|
101
|
+
ldflags = "#{ENV['LDFLAGS']} " + PKGConfig.libs($magick_package).chomp
|
99
102
|
rpath = libdir.empty? ? '' : "-Wl,-rpath,#{libdir}"
|
100
103
|
|
101
104
|
# Save flags
|
102
|
-
$CPPFLAGS
|
103
|
-
$LOCAL_LIBS
|
104
|
-
$LDFLAGS
|
105
|
+
$CPPFLAGS += " #{ENV['CPPFLAGS']} " + PKGConfig.cflags($magick_package).chomp
|
106
|
+
$LOCAL_LIBS += " #{ENV['LIBS']} " + PKGConfig.libs($magick_package).chomp
|
107
|
+
$LDFLAGS += " #{ldflags} #{rpath}"
|
105
108
|
|
106
109
|
unless try_link("int main() { }")
|
107
110
|
# if linker does not recognizes '-Wl,-rpath,somewhere' option, it revert to original option
|
108
|
-
$LDFLAGS = ldflags
|
111
|
+
$LDFLAGS = "#{original_ldflags} #{ldflags}"
|
109
112
|
end
|
110
113
|
|
111
114
|
configure_archflags_for_osx($magick_package) if RUBY_PLATFORM =~ /darwin/ # osx
|
@@ -113,8 +116,8 @@ module RMagick
|
|
113
116
|
elsif RUBY_PLATFORM =~ /mingw/ # mingw
|
114
117
|
|
115
118
|
dir_paths = search_paths_for_library_for_windows
|
116
|
-
$CPPFLAGS
|
117
|
-
$LDFLAGS
|
119
|
+
$CPPFLAGS += %( -I"#{dir_paths[:include]}")
|
120
|
+
$LDFLAGS += %( -L"#{dir_paths[:lib]}")
|
118
121
|
$LDFLAGS << ' -lucrt' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.0')
|
119
122
|
|
120
123
|
have_library(im_version_at_least?('7.0.0') ? 'CORE_RL_MagickCore_' : 'CORE_RL_magick_')
|
@@ -126,11 +129,15 @@ module RMagick
|
|
126
129
|
$LDFLAGS << %( -libpath:"#{dir_paths[:lib]}")
|
127
130
|
$LDFLAGS << ' -libpath:ucrt' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.4.0')
|
128
131
|
|
129
|
-
$LOCAL_LIBS
|
132
|
+
$LOCAL_LIBS += ' ' + (im_version_at_least?('7.0.0') ? 'CORE_RL_MagickCore_.lib' : 'CORE_RL_magick_.lib')
|
130
133
|
|
131
134
|
end
|
132
135
|
|
133
|
-
$CPPFLAGS <<
|
136
|
+
$CPPFLAGS << if have_macro('__GNUC__')
|
137
|
+
' -std=gnu99 -Wno-void-pointer-to-int-cast -Wno-void-pointer-to-enum-cast -Wno-pointer-to-int-cast'
|
138
|
+
else
|
139
|
+
' -std=c99'
|
140
|
+
end
|
134
141
|
end
|
135
142
|
|
136
143
|
def exit_failure(msg)
|
@@ -152,7 +159,7 @@ module RMagick
|
|
152
159
|
|
153
160
|
def detect_imagemagick_packages(packages)
|
154
161
|
packages.select do |package|
|
155
|
-
|
162
|
+
PKGConfig.exist?(package)
|
156
163
|
end
|
157
164
|
end
|
158
165
|
|
@@ -255,7 +262,7 @@ module RMagick
|
|
255
262
|
# issue #169
|
256
263
|
# set ARCHFLAGS appropriately for OSX
|
257
264
|
def configure_archflags_for_osx(magick_package)
|
258
|
-
return unless
|
265
|
+
return unless PKGConfig.libs_only_L(magick_package).match(%r{-L(.+)/lib})
|
259
266
|
|
260
267
|
imagemagick_dir = Regexp.last_match(1)
|
261
268
|
command = Dir.glob(File.join(imagemagick_dir, "bin/*")).select { |file| File.executable? file }.first
|
@@ -330,16 +337,12 @@ module RMagick
|
|
330
337
|
END_FAILURE
|
331
338
|
|
332
339
|
if RUBY_PLATFORM !~ /mswin|mingw/
|
333
|
-
unless
|
334
|
-
exit_failure "Can't install RMagick #{RMAGICK_VERS}. Can't find pkg-config in #{ENV['PATH']}\n"
|
335
|
-
end
|
336
|
-
|
337
|
-
unless `pkg-config --libs MagickCore`[/\bl\s*(MagickCore|Magick)6?\b/]
|
340
|
+
unless PKGConfig.libs('MagickCore')[/\bl\s*(MagickCore|Magick)6?\b/]
|
338
341
|
exit_failure failure_message
|
339
342
|
end
|
340
343
|
|
341
344
|
$magick_package = determine_imagemagick_package
|
342
|
-
$magick_version =
|
345
|
+
$magick_version = PKGConfig.modversion($magick_package)[/^(\d+\.\d+\.\d+)/]
|
343
346
|
else
|
344
347
|
`#{magick_command} -version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-+\d+ /
|
345
348
|
$magick_version = Regexp.last_match(1)
|
@@ -396,9 +399,6 @@ module RMagick
|
|
396
399
|
|
397
400
|
def create_makefile_file
|
398
401
|
create_header_file
|
399
|
-
# Prior to 1.8.5 mkmf duplicated the symbols on the command line and in the
|
400
|
-
# extconf.h header. Suppress that behavior by removing the symbol array.
|
401
|
-
$defs = []
|
402
402
|
|
403
403
|
# Force re-compilation if the generated Makefile changed.
|
404
404
|
$config_h = 'Makefile'
|
data/ext/RMagick/rmagick.h
CHANGED
@@ -24,6 +24,7 @@
|
|
24
24
|
#include <sys/types.h>
|
25
25
|
#include "ruby.h"
|
26
26
|
#include "ruby/io.h"
|
27
|
+
#include "rmagick_gvl.h"
|
27
28
|
|
28
29
|
#if defined(__MINGW32__)
|
29
30
|
// Ruby defines wrong format specifiers for MinGW. So this defines original macro in here.
|
@@ -61,6 +62,11 @@
|
|
61
62
|
#undef PACKAGE_TARNAME
|
62
63
|
#undef WORDS_BIGENDIAN
|
63
64
|
|
65
|
+
#ifndef HAVE_RB_EXT_RACTOR_SAFE
|
66
|
+
#undef RUBY_TYPED_FROZEN_SHAREABLE
|
67
|
+
#define RUBY_TYPED_FROZEN_SHAREABLE 0
|
68
|
+
#endif
|
69
|
+
|
64
70
|
#include "extconf.h"
|
65
71
|
|
66
72
|
#if defined(IMAGEMAGICK_7)
|
@@ -410,6 +416,14 @@ EXTERN ID rm_ID_push; /**< "push" */
|
|
410
416
|
EXTERN ID rm_ID_values; /**< "values" */
|
411
417
|
EXTERN ID rm_ID_width; /**< "width" */
|
412
418
|
|
419
|
+
extern const rb_data_type_t rm_enum_data_type;
|
420
|
+
extern const rb_data_type_t rm_info_data_type;
|
421
|
+
extern const rb_data_type_t rm_image_data_type;
|
422
|
+
extern const rb_data_type_t rm_draw_data_type;
|
423
|
+
extern const rb_data_type_t rm_pixel_data_type;
|
424
|
+
extern const rb_data_type_t rm_montage_data_type;
|
425
|
+
extern const rb_data_type_t rm_kernel_info_data_type;
|
426
|
+
|
413
427
|
#if !defined(min)
|
414
428
|
#define min(a, b) ((a)<(b)?(a):(b)) /**< min of two values */
|
415
429
|
#endif
|
@@ -440,47 +454,47 @@ EXTERN ID rm_ID_width; /**< "width" */
|
|
440
454
|
#define R_dbl_to_C_dbl(attr) NUM2DBL(attr) /**< C double <- Ruby double */
|
441
455
|
|
442
456
|
//! define attribute reader
|
443
|
-
#define
|
457
|
+
#define IMPLEMENT_TYPED_ATTR_READER(class, attr, type, data_type) \
|
444
458
|
{\
|
445
459
|
class *ptr;\
|
446
460
|
if (rb_obj_is_kind_of(self, Class_Image) == Qtrue) {\
|
447
461
|
rm_check_destroyed(self); \
|
448
462
|
}\
|
449
|
-
|
463
|
+
TypedData_Get_Struct(self, class, data_type, ptr);\
|
450
464
|
return C_##type##_to_R_##type(ptr->attr);\
|
451
465
|
}
|
452
466
|
|
453
467
|
//! define attribute reader when attribute name is different from the field name
|
454
|
-
#define
|
468
|
+
#define IMPLEMENT_TYPED_ATTR_READERF(class, attr, field, type, data_type) \
|
455
469
|
{\
|
456
470
|
class *ptr;\
|
457
471
|
rm_check_destroyed(self); \
|
458
|
-
|
472
|
+
TypedData_Get_Struct(self, class, data_type, ptr);\
|
459
473
|
return C_##type##_to_R_##type(ptr->field);\
|
460
474
|
}
|
461
475
|
|
462
476
|
//! define attribute writer
|
463
|
-
#define
|
477
|
+
#define IMPLEMENT_TYPED_ATTR_WRITER(class, attr, type, data_type) \
|
464
478
|
{\
|
465
479
|
class *ptr;\
|
466
480
|
if (rb_obj_is_kind_of(self, Class_Image) == Qtrue) {\
|
467
481
|
rm_check_destroyed(self); \
|
468
482
|
}\
|
469
483
|
rb_check_frozen(self);\
|
470
|
-
|
484
|
+
TypedData_Get_Struct(self, class, data_type, ptr);\
|
471
485
|
ptr->attr = R_##type##_to_C_##type(val);\
|
472
486
|
return val;\
|
473
487
|
}
|
474
488
|
|
475
489
|
//! define attribute writer when attribute name is different from the field name
|
476
|
-
#define
|
490
|
+
#define IMPLEMENT_TYPED_ATTR_WRITERF(class, attr, field, type, data_type) \
|
477
491
|
{\
|
478
492
|
class *ptr;\
|
479
493
|
if (rb_obj_is_kind_of(self, Class_Image) == Qtrue) {\
|
480
494
|
rm_check_destroyed(self); \
|
481
495
|
}\
|
482
496
|
rb_check_frozen(self);\
|
483
|
-
|
497
|
+
TypedData_Get_Struct(self, class, data_type, ptr);\
|
484
498
|
ptr->field = R_##type##_to_C_##type(val);\
|
485
499
|
return self;\
|
486
500
|
}
|
@@ -510,7 +524,6 @@ EXTERN ID rm_ID_width; /**< "width" */
|
|
510
524
|
#define DEF_CONSTV(constant, val) rb_define_const(Module_Magick, #constant, UINT2NUM(val))
|
511
525
|
#endif
|
512
526
|
|
513
|
-
|
514
527
|
//! Convert a Ruby enum constant back to a C enum member.
|
515
528
|
#define VALUE_TO_ENUM(value, e, type) \
|
516
529
|
do {\
|
@@ -518,7 +531,7 @@ EXTERN ID rm_ID_width; /**< "width" */
|
|
518
531
|
if (CLASS_OF(value) != Class_##type)\
|
519
532
|
rb_raise(rb_eTypeError, "wrong enumeration type - expected %s, got %s", \
|
520
533
|
rb_class2name(Class_##type), rb_class2name(CLASS_OF(value)));\
|
521
|
-
|
534
|
+
TypedData_Get_Struct(value, MagickEnum, &rm_enum_data_type, magick_enum);\
|
522
535
|
e = (type)(magick_enum->val);\
|
523
536
|
} while(0)
|
524
537
|
|
@@ -1039,7 +1052,6 @@ ATTR_ACCESSOR(Pixel, cyan)
|
|
1039
1052
|
ATTR_ACCESSOR(Pixel, magenta)
|
1040
1053
|
ATTR_ACCESSOR(Pixel, yellow)
|
1041
1054
|
ATTR_ACCESSOR(Pixel, black)
|
1042
|
-
extern void destroy_Pixel(Pixel *);
|
1043
1055
|
extern VALUE Pixel_alloc(VALUE);
|
1044
1056
|
extern VALUE Pixel_case_eq(VALUE, VALUE);
|
1045
1057
|
extern VALUE Pixel_clone(VALUE);
|