png 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,84 @@
1
+ dir = File.expand_path "~/.ruby_inline"
2
+ if test ?d, dir then
3
+ require 'fileutils'
4
+ puts "nuking #{dir}"
5
+ # force removal, Windoze is bitching at me, something to hunt later...
6
+ FileUtils.rm_r dir, :force => true
7
+ end
8
+
9
+ require 'rubygems'
10
+ require 'minitest/autorun'
11
+ require 'png/font'
12
+
13
+ class TestPngFont < MiniTest::Unit::TestCase
14
+
15
+ def setup
16
+ @font = PNG::Font.default
17
+ end
18
+
19
+ def test_height
20
+ assert_equal 6, @font.height
21
+ end
22
+
23
+ def test_width
24
+ assert_equal 6, @font.width
25
+ end
26
+
27
+ def test_coordinates
28
+ assert_equal [ 0, 0, 5, 5], @font.coordinates('(')
29
+ assert_equal [ 0, 6, 5, 11], @font.coordinates('0')
30
+ assert_equal [ 0, 12, 5, 17], @font.coordinates('a')
31
+ assert_equal [ 0, 18, 5, 23], @font.coordinates('A')
32
+
33
+ assert_equal [42, 12, 47, 17], @font.coordinates('h')
34
+ assert_equal [42, 18, 47, 23], @font.coordinates('H')
35
+ end
36
+
37
+ def test_index
38
+ expected = "
39
+ 0000....0000
40
+ 00..0000..00
41
+ 00..0000..00
42
+ 00........00
43
+ 00..0000..00
44
+ 000000000000
45
+ ".strip + "\n"
46
+
47
+ assert_equal expected, @font['A'].to_s
48
+
49
+ expected = "
50
+ 00000000..00
51
+ 00000000..00
52
+ 00000000..00
53
+ 00000000..00
54
+ 00000000..00
55
+ 000000000000
56
+ ".strip + "\n"
57
+
58
+ assert_equal expected, @font['l'].to_s
59
+ end
60
+
61
+ def test_index_identity
62
+ assert_same @font['A'], @font['A']
63
+ end
64
+
65
+ def test_annotate
66
+ canvas = PNG::Canvas.new 30, 6, PNG::Color::White
67
+ canvas.annotate "hello", 0, 0
68
+
69
+ expected = "
70
+ 00..0000000000000000000000000000..0000000000..00000000000000
71
+ 00......000000......000000000000..0000000000..000000....0000
72
+ 00..0000..00..0000....0000000000..0000000000..0000..0000..00
73
+ 00..0000..00..00..00000000000000..0000000000..0000..0000..00
74
+ 00..0000..0000......000000000000..0000000000..000000....0000
75
+ 000000000000000000000000000000000000000000000000000000000000
76
+ ".strip + "\n"
77
+
78
+ assert_equal expected, canvas.to_s
79
+ end
80
+
81
+ def test_identity
82
+ assert_same PNG::Font.default, PNG::Font.default
83
+ end
84
+ end
@@ -0,0 +1,94 @@
1
+ dir = File.expand_path "~/.ruby_inline"
2
+ if test ?d, dir then
3
+ require 'fileutils'
4
+ puts "nuking #{dir}"
5
+ # force removal, Windoze is bitching at me, something to hunt later...
6
+ FileUtils.rm_r dir, :force => true
7
+ end
8
+
9
+ require 'rubygems'
10
+ require 'minitest/autorun'
11
+ require 'png/reader'
12
+
13
+ class TestPngReader < MiniTest::Unit::TestCase
14
+
15
+ def setup
16
+ @canvas = PNG::Canvas.new 5, 10, PNG::Color::White
17
+ @png = PNG.new @canvas
18
+
19
+ @IHDR_length = "\000\000\000\r"
20
+ @IHDR_crc = "\2152\317\275"
21
+ @IHDR_crc_value = @IHDR_crc.unpack('N').first
22
+ @IHDR_data = "\000\000\000\n\000\000\000\n\b\006\000\000\000"
23
+ @IHDR_chunk = "#{@IHDR_length}IHDR#{@IHDR_data}#{@IHDR_crc}"
24
+
25
+ @blob = <<-EOF.unpack('m*').first
26
+ iVBORw0KGgoAAAANSUhEUgAAAAUAAAAKCAYAAAB8OZQwAAAAD0lEQVR4nGP4
27
+ jwUwDGVBALuJxzlQugpEAAAAAElFTkSuQmCC
28
+ EOF
29
+ end
30
+
31
+ def test_class_check_crc
32
+ assert PNG.check_crc('IHDR', @IHDR_data, @IHDR_crc_value)
33
+ end
34
+
35
+ def test_class_check_crc_exception
36
+ begin
37
+ PNG.check_crc('IHDR', @IHDR_data, @IHDR_crc_value + 1)
38
+ rescue ArgumentError => e
39
+ assert_equal "Invalid CRC encountered in IHDR chunk", e.message
40
+ else
41
+ flunk "exception wasn't raised"
42
+ end
43
+ end
44
+
45
+ def test_class_read_chunk
46
+ data = PNG.read_chunk 'IHDR', @IHDR_chunk
47
+
48
+ assert_equal @IHDR_data, data
49
+ end
50
+
51
+ def test_class_read_IDAT
52
+ canvas = PNG::Canvas.new 5, 10, PNG::Color::White
53
+
54
+ data = ([ 0, [255] * (4*5) ] * 10)
55
+ data = data.flatten.map { |n| n.chr }.join
56
+ data = Zlib::Deflate.deflate(data)
57
+
58
+ PNG.read_IDAT data, 8, PNG::RGBA, canvas
59
+
60
+ assert_equal @blob, PNG.new(canvas).to_blob
61
+ end
62
+
63
+ def test_class_read_IHDR
64
+ bit_depth, color_type, width, height = PNG.read_IHDR @IHDR_data
65
+ assert_equal 10, width
66
+ assert_equal 10, height
67
+ end
68
+
69
+ def test_class_load_metadata
70
+ png, canvas = util_png
71
+
72
+ width, height, bit_depth = PNG.load(png.to_blob, :metadata)
73
+
74
+ assert_equal 2, width
75
+ assert_equal 2, height
76
+ assert_equal 8, bit_depth
77
+ end
78
+
79
+ def test_class_load
80
+ png, canvas = util_png
81
+
82
+ new_png = PNG.load(png.to_blob)
83
+
84
+ assert_equal canvas.data, new_png.data
85
+ end
86
+
87
+ def util_png
88
+ canvas = PNG::Canvas.new 2, 2
89
+ canvas[0, 0] = PNG::Color::Black
90
+ canvas[1, 1] = PNG::Color::Black
91
+ png = PNG.new canvas
92
+ return png, canvas
93
+ end
94
+ end
metadata CHANGED
@@ -1,34 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0.9
3
- specification_version: 1
4
2
  name: png
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.1.0
7
- date: 2007-03-26 00:00:00 -07:00
8
- summary: An almost-pure-ruby PNG library
9
- require_paths:
10
- - lib
11
- email: support@zenspider.com
12
- homepage: http://www.zenspider.com/ZSS/Products/png/
13
- rubyforge_project: seattlerb
14
- description: "PNG is an almost-pure-ruby PNG library. It lets you write a PNG without any C libraries. == FEATURES * Very simple interface. * Outputs simple PNG files with ease. * Basic PNG reader as well (someday it might do compositing and the like!). * Almost pure ruby, does require a compiler. == SYNOPSYS require 'png' canvas = PNG::Canvas.new 200, 200 # Set a point to a color canvas[100, 100] = PNG::Color::Black # draw an anti-aliased line canvas.line 50, 50, 100, 50, PNG::Color::Blue png = PNG.new canvas png.save 'blah.png'"
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 1.2.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Ryan Davis
31
8
  - Eric Hodel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
15
+ ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
16
+ GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE
17
+ AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
18
+ JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
19
+ b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
20
+ taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT
21
+ oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
22
+ GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
23
+ qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
24
+ gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
25
+ HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
26
+ AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m
27
+ vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/
28
+ w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0
29
+ l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl
30
+ n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T
31
+ FBHgymkyj/AOSqKRIpXPhjC6
32
+ -----END CERTIFICATE-----
33
+
34
+ date: 2009-06-23 00:00:00 -07:00
35
+ default_executable:
36
+ dependencies:
37
+ - !ruby/object:Gem::Dependency
38
+ name: hoe
39
+ type: :development
40
+ version_requirement:
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 2.3.0
46
+ version:
47
+ description: |-
48
+ PNG is an almost-pure-ruby PNG library. It lets you write a PNG
49
+ without any C libraries.
50
+ email:
51
+ - ryand-ruby@zenspider.com
52
+ - drbrain@segment7.net
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - History.txt
59
+ - Manifest.txt
60
+ - README.txt
32
61
  files:
33
62
  - History.txt
34
63
  - Manifest.txt
@@ -38,36 +67,43 @@ files:
38
67
  - example/profile.rb
39
68
  - example/profile_lines.rb
40
69
  - lib/png.rb
70
+ - lib/png/default_font.png
71
+ - lib/png/font.rb
41
72
  - lib/png/pie.rb
73
+ - lib/png/reader.rb
42
74
  - test/test_png.rb
43
- test_files:
44
- - test/test_png.rb
45
- rdoc_options: []
46
-
47
- extra_rdoc_files: []
48
-
49
- executables: []
50
-
51
- extensions: []
75
+ - test/test_png_font.rb
76
+ - test/test_png_reader.rb
77
+ has_rdoc: true
78
+ homepage: http://seattlerb.rubyforge.org/
79
+ licenses: []
52
80
 
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --main
84
+ - README.txt
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: "0"
92
+ version:
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: "0"
98
+ version:
53
99
  requirements: []
54
100
 
55
- dependencies:
56
- - !ruby/object:Gem::Dependency
57
- name: RubyInline
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Version::Requirement
60
- requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: 3.5.0
64
- version:
65
- - !ruby/object:Gem::Dependency
66
- name: hoe
67
- version_requirement:
68
- version_requirements: !ruby/object:Gem::Version::Requirement
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 1.2.0
73
- version:
101
+ rubyforge_project: seattlerb
102
+ rubygems_version: 1.3.4
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: PNG is an almost-pure-ruby PNG library
106
+ test_files:
107
+ - test/test_png.rb
108
+ - test/test_png_font.rb
109
+ - test/test_png_reader.rb
Binary file