gd2-ffij 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/test/image_tests.rb CHANGED
@@ -1,149 +1,144 @@
1
- require 'test/unit'
2
- require 'tmpdir'
3
-
4
- require 'rubygems'
5
- require 'gd2-ffij'
6
1
 
7
2
  require './test/test_helper'
8
3
 
9
4
  class ImageTest < Test::Unit::TestCase
10
- include TestHelper
11
-
12
- def test_image_new_and_release
13
- img = GD2::Image.new(50, 50)
14
- end
15
-
16
- def test_image_true_color_new_and_release
17
- img = GD2::Image::TrueColor.new(50, 50)
18
- end
19
-
20
- def test_image_indexed_color_new_and_release
21
- img = GD2::Image::IndexedColor.new(50, 50)
22
- end
23
-
24
- [ :png, :gif, :jpg, :wbmp, :gd2 ].each do |ext|
25
- self.class_eval(<<-EOF)
26
- def test_load_#{ext}_from_file
27
- img = GD2::Image.load(File.open(File.join(PATH_TO_IMAGES, 'test.#{ext}')))
28
- end
29
-
30
- def test_load_#{ext}_from_string
31
- img = GD2::Image.load(File.read(File.join(PATH_TO_IMAGES, 'test.#{ext}')))
32
- end
33
- EOF
34
- end
35
-
36
- # TODO: add xbm, xpm and wbmp tests
37
- [ :png, :gif, :jpg, :gd, :gd2 ].each do |ext|
38
- self.class_eval(<<-EOF)
39
- def test_import_#{ext}_from_file
40
- img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
41
- end
42
-
43
- def test_export_#{ext}
44
- img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2'))
45
- out = File.join(Dir.tmpdir, 'test.#{ext}')
46
- img.export(out)
47
-
48
- assert(File.exists?(out))
49
-
50
- imgA = GD2::Image.import(out)
51
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
52
-
53
- assert(imgA == imgB)
54
-
55
- File.unlink(out)
56
- end
57
-
58
- def test_compare_#{ext}
59
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
60
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
61
- assert_equal(imgA.compare(imgB), 0)
62
- assert_equal(imgA.compare(imgA.dup), 0)
63
- end
64
-
65
- def test_eqeq_#{ext}
66
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
67
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
68
- assert(imgA == imgB)
69
- assert(imgA == imgA.dup)
70
- end
71
-
72
- def test_height_#{ext}
73
- img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
74
- assert_equal(img.height, 256)
75
- end
76
-
77
- def test_width_#{ext}
78
- img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
79
- assert_equal(img.width, 256)
80
- end
81
-
82
- def test_size_#{ext}
83
- img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
84
- assert_equal(img.size, [ 256, 256 ])
85
- end
86
-
87
- def test_aspect_#{ext}
88
- img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
89
- assert_in_delta(img.aspect, 1.0, 0.00000001)
90
- end
91
- EOF
92
- end
93
-
94
- def test_rotate
95
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).rotate!(Math::PI)
96
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_rotated_180.gd2'))
97
-
98
- assert(imgA == imgB)
99
- end
100
-
101
- def test_crop
102
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).crop!(64, 64, 128, 128)
103
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_cropped.gd2'))
104
-
105
- assert(imgA == imgB)
106
- end
107
-
108
- def test_uncrop
109
- img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).crop!(64, 64, 128, 128)
110
- img.uncrop!(64)
111
-
112
- assert_equal(img.size, [ 256, 256 ])
113
- end
114
-
115
- def test_resize
116
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).resize!(512, 512)
117
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_resized.gd2'))
118
-
119
- assert(imgA == imgB)
120
- end
121
-
122
- def test_resampled
123
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).resize!(512, 512, true)
124
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_resampled.gd2'))
125
-
126
- assert(imgA == imgB)
127
- end
128
-
129
- def test_polar_transform
130
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).polar_transform!(100)
131
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_polar_transform.gd2'))
132
-
133
- assert(imgA == imgB)
134
- end
5
+ include TestHelper
6
+
7
+ def test_image_new_and_release
8
+ GD2::Image.new(50, 50)
9
+ end
10
+
11
+ def test_image_true_color_new_and_release
12
+ GD2::Image::TrueColor.new(50, 50)
13
+ end
14
+
15
+ def test_image_indexed_color_new_and_release
16
+ GD2::Image::IndexedColor.new(50, 50)
17
+ end
18
+
19
+ [ :png, :gif, :jpg, :wbmp, :gd2 ].each do |ext|
20
+ self.class_eval(<<-EOF)
21
+ def test_load_#{ext}_from_file
22
+ GD2::Image.load(File.open(File.join(PATH_TO_IMAGES, 'test.#{ext}')))
23
+ end
24
+
25
+ def test_load_#{ext}_from_string
26
+ GD2::Image.load(File.read(File.join(PATH_TO_IMAGES, 'test.#{ext}')))
27
+ end
28
+ EOF
29
+ end
30
+
31
+ # TODO: add xbm, xpm and wbmp tests
32
+ [ :png, :gif, :jpg, :gd, :gd2 ].each do |ext|
33
+ self.class_eval(<<-EOF)
34
+ def test_import_#{ext}_from_file
35
+ GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
36
+ end
37
+
38
+ def test_export_#{ext}
39
+ img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2'))
40
+ out = File.join(Dir.tmpdir, 'test.#{ext}')
41
+ img.export(out)
42
+
43
+ assert(File.exists?(out))
44
+
45
+ imgA = GD2::Image.import(out)
46
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
47
+
48
+ assert(imgA == imgB)
49
+
50
+ File.unlink(out)
51
+ end
52
+
53
+ def test_compare_#{ext}
54
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
55
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
56
+ assert_equal(imgA.compare(imgB), 0)
57
+ assert_equal(imgA.compare(imgA.dup), 0)
58
+ end
59
+
60
+ def test_eqeq_#{ext}
61
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
62
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
63
+ assert(imgA == imgB)
64
+ assert(imgA == imgA.dup)
65
+ end
66
+
67
+ def test_height_#{ext}
68
+ img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
69
+ assert_equal(img.height, 256)
70
+ end
71
+
72
+ def test_width_#{ext}
73
+ img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
74
+ assert_equal(img.width, 256)
75
+ end
76
+
77
+ def test_size_#{ext}
78
+ img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
79
+ assert_equal(img.size, [ 256, 256 ])
80
+ end
81
+
82
+ def test_aspect_#{ext}
83
+ img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.#{ext}'))
84
+ assert_in_delta(img.aspect, 1.0, 0.00000001)
85
+ end
86
+ EOF
87
+ end
88
+
89
+ def test_rotate
90
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).rotate!(Math::PI)
91
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_rotated_180.gd2'))
92
+
93
+ assert(imgA == imgB)
94
+ end
95
+
96
+ def test_crop
97
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).crop!(64, 64, 128, 128)
98
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_cropped.gd2'))
99
+
100
+ assert(imgA == imgB)
101
+ end
102
+
103
+ def test_uncrop
104
+ img = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).crop!(64, 64, 128, 128)
105
+ img.uncrop!(64)
106
+
107
+ assert_equal(img.size, [ 256, 256 ])
108
+ end
109
+
110
+ def test_resize
111
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).resize!(512, 512)
112
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_resized.gd2'))
113
+
114
+ assert(imgA == imgB)
115
+ end
116
+
117
+ def test_resampled
118
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).resize!(512, 512, true)
119
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_resampled.gd2'))
120
+
121
+ assert(imgA == imgB)
122
+ end
123
+
124
+ def test_polar_transform
125
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test.gd2')).polar_transform!(100)
126
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_polar_transform.gd2'))
127
+
128
+ assert(imgA == imgB)
129
+ end
135
130
 
136
- def test_color_sharpened
137
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_color.gd2')).sharpen(100)
138
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_color_sharpened.gd2'))
131
+ def test_color_sharpened
132
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_color.gd2')).sharpen(100)
133
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_color_sharpened.gd2'))
139
134
 
140
- assert(imgA == imgB)
141
- end
135
+ assert(imgA == imgB)
136
+ end
142
137
 
143
- def test_resampled
144
- imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_color.gd2')).to_indexed_color
145
- imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_color_indexed.gd2'))
138
+ def test_to_indexed_color
139
+ imgA = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_color.gd2')).to_indexed_color
140
+ imgB = GD2::Image.import(File.join(PATH_TO_IMAGES, 'test_color_indexed.gd2'))
146
141
 
147
- assert(imgA == imgB)
148
- end
142
+ assert(imgA == imgB)
143
+ end
149
144
  end
Binary file
Binary file
data/test/test_helper.rb CHANGED
@@ -1,13 +1,21 @@
1
1
 
2
+ require 'test/unit'
3
+ require 'tmpdir'
4
+
5
+ require 'rubygems'
6
+ require 'gd2-ffij'
7
+
8
+ puts "GD2 version: #{GD2::VERSION}"
9
+
2
10
  module TestHelper
3
- PATH_TO_IMAGES = File.join(File.dirname(__FILE__), 'images')
4
- PATH_TO_FONT = File.join(File.dirname(__FILE__), '..', 'vendor', 'fonts', 'ttf', 'DejaVuSans.ttf')
11
+ PATH_TO_IMAGES = File.join(File.dirname(__FILE__), 'images')
12
+ PATH_TO_FONT = File.join(File.dirname(__FILE__), '..', 'vendor', 'fonts', 'ttf', 'DejaVuSans.ttf')
5
13
 
6
- def new_image
7
- GD2::Image.new(256, 256)
8
- end
14
+ def new_image
15
+ GD2::Image.new(256, 256)
16
+ end
9
17
 
10
- def load_image(file_name)
11
- GD2::Image.load(File.read(File.join(PATH_TO_IMAGES, file_name)))
12
- end
18
+ def load_image(file_name)
19
+ GD2::Image.load(File.read(File.join(PATH_TO_IMAGES, file_name)))
20
+ end
13
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gd2-ffij
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-03 00:00:00.000000000 Z
12
+ date: 2012-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
16
- requirement: &70147998478480 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,19 +21,57 @@ dependencies:
21
21
  version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70147998478480
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.9'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
25
62
  description: gd2-ffij is a refactoring of the Ruby/GD2 library implemented with FFI
26
63
  email: dark.panda@gmail.com
27
64
  executables: []
28
65
  extensions: []
29
66
  extra_rdoc_files:
30
- - README
67
+ - README.rdoc
31
68
  files:
69
+ - .gitignore
32
70
  - COPYING
33
71
  - COPYRIGHT
34
- - README
72
+ - Gemfile
73
+ - README.rdoc
35
74
  - Rakefile
36
- - VERSION
37
75
  - gd2-ffij.gemspec
38
76
  - lib/gd2-ffij.rb
39
77
  - lib/gd2/canvas.rb
@@ -42,6 +80,7 @@ files:
42
80
  - lib/gd2/font.rb
43
81
  - lib/gd2/image.rb
44
82
  - lib/gd2/palette.rb
83
+ - lib/gd2/version.rb
45
84
  - test/canvas_tests.rb
46
85
  - test/image_tests.rb
47
86
  - test/images/test.bmp
@@ -104,8 +143,48 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
143
  version: '0'
105
144
  requirements: []
106
145
  rubyforge_project:
107
- rubygems_version: 1.8.10
146
+ rubygems_version: 1.8.23
108
147
  signing_key:
109
148
  specification_version: 3
110
149
  summary: gd2-ffij is a refactoring of the Ruby/GD2 library implemented with FFI
111
- test_files: []
150
+ test_files:
151
+ - test/canvas_tests.rb
152
+ - test/image_tests.rb
153
+ - test/images/test.bmp
154
+ - test/images/test.gd
155
+ - test/images/test.gd2
156
+ - test/images/test.gif
157
+ - test/images/test.jpg
158
+ - test/images/test.png
159
+ - test/images/test.wbmp
160
+ - test/images/test.xbm
161
+ - test/images/test.xcf
162
+ - test/images/test.xpm
163
+ - test/images/test_arc.gd2
164
+ - test/images/test_canvas_filled_polygon.gd2
165
+ - test/images/test_canvas_filled_rectangle.gd2
166
+ - test/images/test_canvas_line.gd2
167
+ - test/images/test_canvas_move_to_and_line_to.gd2
168
+ - test/images/test_canvas_polygon.gd2
169
+ - test/images/test_canvas_rectangle.gd2
170
+ - test/images/test_circle.gd2
171
+ - test/images/test_color.gd2
172
+ - test/images/test_color.png
173
+ - test/images/test_color.xcf
174
+ - test/images/test_color_indexed.gd2
175
+ - test/images/test_color_sharpened.gd2
176
+ - test/images/test_cropped.gd2
177
+ - test/images/test_ellipse.gd2
178
+ - test/images/test_fill.gd2
179
+ - test/images/test_fill_to.gd2
180
+ - test/images/test_filled_circle.gd2
181
+ - test/images/test_filled_ellipse.gd2
182
+ - test/images/test_filled_wedge.gd2
183
+ - test/images/test_polar_transform.gd2
184
+ - test/images/test_resampled.gd2
185
+ - test/images/test_resized.gd2
186
+ - test/images/test_rotated_180.gd2
187
+ - test/images/test_text.gd2
188
+ - test/images/test_text_circle.gd2
189
+ - test/images/test_wedge.gd2
190
+ - test/test_helper.rb