free-image 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +5 -0
- data/LICENSE +21 -0
- data/README.rdoc +99 -0
- data/Rakefile +47 -0
- data/cookbook.rdoc +239 -0
- data/free-image.gemspec +30 -0
- data/lib/free-image.rb +101 -0
- data/lib/free-image/bitmap.rb +154 -0
- data/lib/free-image/enums/color_types.rb +24 -0
- data/lib/free-image/enums/dithers.rb +24 -0
- data/lib/free-image/enums/filters.rb +12 -0
- data/lib/free-image/enums/formats.rb +84 -0
- data/lib/free-image/enums/image_types.rb +36 -0
- data/lib/free-image/errors.rb +44 -0
- data/lib/free-image/modules/conversions.rb +166 -0
- data/lib/free-image/modules/helper.rb +42 -0
- data/lib/free-image/modules/icc.rb +41 -0
- data/lib/free-image/modules/information.rb +305 -0
- data/lib/free-image/modules/modify.rb +261 -0
- data/lib/free-image/modules/pixels.rb +135 -0
- data/lib/free-image/modules/transforms.rb +83 -0
- data/lib/free-image/palette.rb +44 -0
- data/lib/free-image/scanline.rb +151 -0
- data/lib/free-image/sources/abstract_source.rb +172 -0
- data/lib/free-image/sources/file.rb +115 -0
- data/lib/free-image/sources/io.rb +154 -0
- data/lib/free-image/sources/memory.rb +189 -0
- data/lib/free-image/types/boolean.rb +14 -0
- data/lib/free-image/types/complex.rb +9 -0
- data/lib/free-image/types/ffi.rb +14 -0
- data/lib/free-image/types/rgb16.rb +11 -0
- data/lib/free-image/types/rgb_quad.rb +82 -0
- data/lib/free-image/types/rgb_triple.rb +42 -0
- data/lib/free-image/types/rgba16.rb +12 -0
- data/lib/free-image/types/rgbaf.rb +12 -0
- data/lib/free-image/types/rgbf.rb +11 -0
- data/test/cookbook.rb +46 -0
- data/test/images/gradient.png +0 -0
- data/test/images/lena.png +0 -0
- data/test/images/lena.tiff +0 -0
- data/test/images/lena_flipped.png +0 -0
- data/test/images/lena_rescale_bicubic.png +0 -0
- data/test/images/lena_rescale_bilinear.png +0 -0
- data/test/images/lena_rescale_box.png +0 -0
- data/test/images/lena_rescale_bspline.png +0 -0
- data/test/images/lena_rescale_catmullrom.png +0 -0
- data/test/images/lena_rescale_lanczos3.png +0 -0
- data/test/images/lena_rotate_45.png +0 -0
- data/test/images/lena_rotate_ex_45_masked.png +0 -0
- data/test/images/lena_rotate_ex_45_mirrored.png +0 -0
- data/test/images/lena_rotate_ex_45_top_left.png +0 -0
- data/test/images/lena_thumbnail.png +0 -0
- data/test/images/lena_thumbnail_border_enlarge.png +0 -0
- data/test/images/lena_thumbnail_border_paste.png +0 -0
- data/test/images/lena_thumbnail_border_scanline.png +0 -0
- data/test/images/not_an_image.txt +0 -0
- data/test/images/sample.png +0 -0
- data/test/images/sample_composite_color.png +0 -0
- data/test/test_bitmap.rb +43 -0
- data/test/test_conversions.rb +86 -0
- data/test/test_file.rb +51 -0
- data/test/test_free_image.rb +15 -0
- data/test/test_helper.rb +35 -0
- data/test/test_information.rb +118 -0
- data/test/test_io.rb +53 -0
- data/test/test_memory.rb +65 -0
- data/test/test_modify.rb +59 -0
- data/test/test_palette.rb +45 -0
- data/test/test_pixels.rb +62 -0
- data/test/test_rgb_quad.rb +26 -0
- data/test/test_scanline.rb +65 -0
- data/test/test_suite.rb +19 -0
- data/test/test_transforms.rb +30 -0
- metadata +169 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class RGBQuadTest < Test::Unit::TestCase
|
7
|
+
def test_create
|
8
|
+
color = FreeImage::RGBQuad.create(1,2,3,4)
|
9
|
+
assert_equal(color[:red], 1)
|
10
|
+
assert_equal(color[:green], 2)
|
11
|
+
assert_equal(color[:blue], 3)
|
12
|
+
assert_equal(color[:reserved], 4)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_=
|
16
|
+
color1 = FreeImage::RGBQuad.create(1,2,3,4)
|
17
|
+
color2 = FreeImage::RGBQuad.create(1,2,3,4)
|
18
|
+
assert_equal(color1, color2)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_eql
|
22
|
+
color1 = FreeImage::RGBQuad.create(1,2,3,4)
|
23
|
+
color2 = FreeImage::RGBQuad.create(1,2,3,4)
|
24
|
+
assert(color1.eql?(color2))
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class ScanlineTest < Test::Unit::TestCase
|
7
|
+
def scanline(index = 0)
|
8
|
+
image = lena_image
|
9
|
+
image.scanline(index)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_class
|
13
|
+
assert_kind_of(FreeImage::Scanline, scanline)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_bytesize
|
17
|
+
assert_equal(lena_image.pitch, scanline.bytesize)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_pixelsize
|
21
|
+
assert_equal(lena_image.width, scanline.pixelsize)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_color_type
|
25
|
+
assert_equal(FreeImage::RGBTriple, scanline.send(:color_type))
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_color_size
|
29
|
+
assert_equal(3, scanline.send(:color_type).size)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_color
|
33
|
+
expected = lena_image.pixel_color(0, 0)
|
34
|
+
actual = scanline[0]
|
35
|
+
|
36
|
+
assert_equal(expected[:red], actual[:red])
|
37
|
+
assert_equal(expected[:green], actual[:green])
|
38
|
+
assert_equal(expected[:blue], actual[:blue])
|
39
|
+
assert_equal(expected[:reserved], 0)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_invalid_y
|
43
|
+
error = assert_raise(RangeError) do
|
44
|
+
lena_image.scanline(-1)
|
45
|
+
end
|
46
|
+
assert_equal("Index must be between 0 and 511", error.to_s)
|
47
|
+
|
48
|
+
error = assert_raise(RangeError) do
|
49
|
+
lena_image.scanline(1000)
|
50
|
+
end
|
51
|
+
assert_equal("Index must be between 0 and 511", error.to_s)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_invalid_x
|
55
|
+
error = assert_raise(RangeError) do
|
56
|
+
scanline[-1]
|
57
|
+
end
|
58
|
+
assert_equal("Index must be between 0 and 511", error.to_s)
|
59
|
+
|
60
|
+
error = assert_raise(RangeError) do
|
61
|
+
scanline[1000]
|
62
|
+
end
|
63
|
+
assert_equal("Index must be between 0 and 511", error.to_s)
|
64
|
+
end
|
65
|
+
end
|
data/test/test_suite.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
# Change to current directory so relative
|
4
|
+
# requires work.
|
5
|
+
dir = File.dirname(__FILE__)
|
6
|
+
Dir.chdir(dir)
|
7
|
+
|
8
|
+
require './test_bitmap'
|
9
|
+
require './test_conversions'
|
10
|
+
require './test_file'
|
11
|
+
require './test_free_image'
|
12
|
+
require './test_information'
|
13
|
+
require './test_io'
|
14
|
+
require './test_memory'
|
15
|
+
require './test_modify'
|
16
|
+
require './test_palette'
|
17
|
+
require './test_pixels'
|
18
|
+
require './test_rgb_quad'
|
19
|
+
require './test_transforms'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require './test_helper'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class TrasformsTest < Test::Unit::TestCase
|
7
|
+
def test_rotate
|
8
|
+
bitmap1 = FreeImage::Bitmap.open(image_path('sample.png'))
|
9
|
+
bitmap2 = bitmap1.rotate(45)
|
10
|
+
assert_kind_of(FreeImage::Bitmap, bitmap2)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_rotate_ex
|
14
|
+
bitmap1 = FreeImage::Bitmap.open(image_path('sample.png'))
|
15
|
+
bitmap2 = bitmap1.rotate_ex(45, 0, 0, 0, 0)
|
16
|
+
assert_kind_of(FreeImage::Bitmap, bitmap2)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_flip_horizontal
|
20
|
+
bitmap1 = FreeImage::Bitmap.open(image_path('sample.png'))
|
21
|
+
result = bitmap1.flip_horizontal!
|
22
|
+
assert_kind_of(TrueClass, result)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_flip_vertical
|
26
|
+
bitmap1 = FreeImage::Bitmap.open(image_path('sample.png'))
|
27
|
+
result = bitmap1.flip_vertical!
|
28
|
+
assert_kind_of(TrueClass, result)
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: free-image
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Charlie Savage
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ffi
|
16
|
+
requirement: &22083624 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.10
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *22083624
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: hanna-nouveau
|
27
|
+
requirement: &22083396 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *22083396
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: open4
|
38
|
+
requirement: &22083120 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *22083120
|
47
|
+
description: ! " FreeImage is an Open Source library project for developers who
|
48
|
+
would like to support\n popular graphics image formats like PNG, BMP, JPEG, TIFF
|
49
|
+
and others as needed by\n today's multimedia applications. FreeImage is easy
|
50
|
+
to use, fast, multithreading\n safe, compatible with all 32-bit or 64-bit versions
|
51
|
+
of Windows, and\n cross-platform (works both with Linux and Mac OS X).\n"
|
52
|
+
email:
|
53
|
+
executables: []
|
54
|
+
extensions: []
|
55
|
+
extra_rdoc_files: []
|
56
|
+
files:
|
57
|
+
- HISTORY
|
58
|
+
- LICENSE
|
59
|
+
- free-image.gemspec
|
60
|
+
- Rakefile
|
61
|
+
- cookbook.rdoc
|
62
|
+
- README.rdoc
|
63
|
+
- lib/free-image/bitmap.rb
|
64
|
+
- lib/free-image/enums/color_types.rb
|
65
|
+
- lib/free-image/enums/dithers.rb
|
66
|
+
- lib/free-image/enums/filters.rb
|
67
|
+
- lib/free-image/enums/formats.rb
|
68
|
+
- lib/free-image/enums/image_types.rb
|
69
|
+
- lib/free-image/errors.rb
|
70
|
+
- lib/free-image/modules/conversions.rb
|
71
|
+
- lib/free-image/modules/helper.rb
|
72
|
+
- lib/free-image/modules/icc.rb
|
73
|
+
- lib/free-image/modules/information.rb
|
74
|
+
- lib/free-image/modules/modify.rb
|
75
|
+
- lib/free-image/modules/pixels.rb
|
76
|
+
- lib/free-image/modules/transforms.rb
|
77
|
+
- lib/free-image/palette.rb
|
78
|
+
- lib/free-image/scanline.rb
|
79
|
+
- lib/free-image/sources/abstract_source.rb
|
80
|
+
- lib/free-image/sources/file.rb
|
81
|
+
- lib/free-image/sources/io.rb
|
82
|
+
- lib/free-image/sources/memory.rb
|
83
|
+
- lib/free-image/types/boolean.rb
|
84
|
+
- lib/free-image/types/complex.rb
|
85
|
+
- lib/free-image/types/ffi.rb
|
86
|
+
- lib/free-image/types/rgb16.rb
|
87
|
+
- lib/free-image/types/rgba16.rb
|
88
|
+
- lib/free-image/types/rgbaf.rb
|
89
|
+
- lib/free-image/types/rgbf.rb
|
90
|
+
- lib/free-image/types/rgb_quad.rb
|
91
|
+
- lib/free-image/types/rgb_triple.rb
|
92
|
+
- lib/free-image.rb
|
93
|
+
- test/cookbook.rb
|
94
|
+
- test/images/gradient.png
|
95
|
+
- test/images/lena.png
|
96
|
+
- test/images/lena.tiff
|
97
|
+
- test/images/lena_flipped.png
|
98
|
+
- test/images/lena_rescale_bicubic.png
|
99
|
+
- test/images/lena_rescale_bilinear.png
|
100
|
+
- test/images/lena_rescale_box.png
|
101
|
+
- test/images/lena_rescale_bspline.png
|
102
|
+
- test/images/lena_rescale_catmullrom.png
|
103
|
+
- test/images/lena_rescale_lanczos3.png
|
104
|
+
- test/images/lena_rotate_45.png
|
105
|
+
- test/images/lena_rotate_ex_45_masked.png
|
106
|
+
- test/images/lena_rotate_ex_45_mirrored.png
|
107
|
+
- test/images/lena_rotate_ex_45_top_left.png
|
108
|
+
- test/images/lena_thumbnail.png
|
109
|
+
- test/images/lena_thumbnail_border_enlarge.png
|
110
|
+
- test/images/lena_thumbnail_border_paste.png
|
111
|
+
- test/images/lena_thumbnail_border_scanline.png
|
112
|
+
- test/images/not_an_image.txt
|
113
|
+
- test/images/sample.png
|
114
|
+
- test/images/sample_composite_color.png
|
115
|
+
- test/test_bitmap.rb
|
116
|
+
- test/test_conversions.rb
|
117
|
+
- test/test_file.rb
|
118
|
+
- test/test_free_image.rb
|
119
|
+
- test/test_helper.rb
|
120
|
+
- test/test_information.rb
|
121
|
+
- test/test_io.rb
|
122
|
+
- test/test_memory.rb
|
123
|
+
- test/test_modify.rb
|
124
|
+
- test/test_palette.rb
|
125
|
+
- test/test_pixels.rb
|
126
|
+
- test/test_rgb_quad.rb
|
127
|
+
- test/test_scanline.rb
|
128
|
+
- test/test_suite.rb
|
129
|
+
- test/test_transforms.rb
|
130
|
+
homepage:
|
131
|
+
licenses: []
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.8.7
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 1.8.10
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: Ruby Bindings for the Free Image Library
|
154
|
+
test_files:
|
155
|
+
- test/test_bitmap.rb
|
156
|
+
- test/test_conversions.rb
|
157
|
+
- test/test_file.rb
|
158
|
+
- test/test_free_image.rb
|
159
|
+
- test/test_helper.rb
|
160
|
+
- test/test_information.rb
|
161
|
+
- test/test_io.rb
|
162
|
+
- test/test_memory.rb
|
163
|
+
- test/test_modify.rb
|
164
|
+
- test/test_palette.rb
|
165
|
+
- test/test_pixels.rb
|
166
|
+
- test/test_rgb_quad.rb
|
167
|
+
- test/test_scanline.rb
|
168
|
+
- test/test_suite.rb
|
169
|
+
- test/test_transforms.rb
|