free-image 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/HISTORY +5 -0
  2. data/LICENSE +21 -0
  3. data/README.rdoc +99 -0
  4. data/Rakefile +47 -0
  5. data/cookbook.rdoc +239 -0
  6. data/free-image.gemspec +30 -0
  7. data/lib/free-image.rb +101 -0
  8. data/lib/free-image/bitmap.rb +154 -0
  9. data/lib/free-image/enums/color_types.rb +24 -0
  10. data/lib/free-image/enums/dithers.rb +24 -0
  11. data/lib/free-image/enums/filters.rb +12 -0
  12. data/lib/free-image/enums/formats.rb +84 -0
  13. data/lib/free-image/enums/image_types.rb +36 -0
  14. data/lib/free-image/errors.rb +44 -0
  15. data/lib/free-image/modules/conversions.rb +166 -0
  16. data/lib/free-image/modules/helper.rb +42 -0
  17. data/lib/free-image/modules/icc.rb +41 -0
  18. data/lib/free-image/modules/information.rb +305 -0
  19. data/lib/free-image/modules/modify.rb +261 -0
  20. data/lib/free-image/modules/pixels.rb +135 -0
  21. data/lib/free-image/modules/transforms.rb +83 -0
  22. data/lib/free-image/palette.rb +44 -0
  23. data/lib/free-image/scanline.rb +151 -0
  24. data/lib/free-image/sources/abstract_source.rb +172 -0
  25. data/lib/free-image/sources/file.rb +115 -0
  26. data/lib/free-image/sources/io.rb +154 -0
  27. data/lib/free-image/sources/memory.rb +189 -0
  28. data/lib/free-image/types/boolean.rb +14 -0
  29. data/lib/free-image/types/complex.rb +9 -0
  30. data/lib/free-image/types/ffi.rb +14 -0
  31. data/lib/free-image/types/rgb16.rb +11 -0
  32. data/lib/free-image/types/rgb_quad.rb +82 -0
  33. data/lib/free-image/types/rgb_triple.rb +42 -0
  34. data/lib/free-image/types/rgba16.rb +12 -0
  35. data/lib/free-image/types/rgbaf.rb +12 -0
  36. data/lib/free-image/types/rgbf.rb +11 -0
  37. data/test/cookbook.rb +46 -0
  38. data/test/images/gradient.png +0 -0
  39. data/test/images/lena.png +0 -0
  40. data/test/images/lena.tiff +0 -0
  41. data/test/images/lena_flipped.png +0 -0
  42. data/test/images/lena_rescale_bicubic.png +0 -0
  43. data/test/images/lena_rescale_bilinear.png +0 -0
  44. data/test/images/lena_rescale_box.png +0 -0
  45. data/test/images/lena_rescale_bspline.png +0 -0
  46. data/test/images/lena_rescale_catmullrom.png +0 -0
  47. data/test/images/lena_rescale_lanczos3.png +0 -0
  48. data/test/images/lena_rotate_45.png +0 -0
  49. data/test/images/lena_rotate_ex_45_masked.png +0 -0
  50. data/test/images/lena_rotate_ex_45_mirrored.png +0 -0
  51. data/test/images/lena_rotate_ex_45_top_left.png +0 -0
  52. data/test/images/lena_thumbnail.png +0 -0
  53. data/test/images/lena_thumbnail_border_enlarge.png +0 -0
  54. data/test/images/lena_thumbnail_border_paste.png +0 -0
  55. data/test/images/lena_thumbnail_border_scanline.png +0 -0
  56. data/test/images/not_an_image.txt +0 -0
  57. data/test/images/sample.png +0 -0
  58. data/test/images/sample_composite_color.png +0 -0
  59. data/test/test_bitmap.rb +43 -0
  60. data/test/test_conversions.rb +86 -0
  61. data/test/test_file.rb +51 -0
  62. data/test/test_free_image.rb +15 -0
  63. data/test/test_helper.rb +35 -0
  64. data/test/test_information.rb +118 -0
  65. data/test/test_io.rb +53 -0
  66. data/test/test_memory.rb +65 -0
  67. data/test/test_modify.rb +59 -0
  68. data/test/test_palette.rb +45 -0
  69. data/test/test_pixels.rb +62 -0
  70. data/test/test_rgb_quad.rb +26 -0
  71. data/test/test_scanline.rb +65 -0
  72. data/test/test_suite.rb +19 -0
  73. data/test/test_transforms.rb +30 -0
  74. 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
@@ -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