chunky_png 0.10.3 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +13 -3
- data/chunky_png.gemspec +3 -3
- data/lib/chunky_png.rb +3 -2
- data/lib/chunky_png/canvas/png_encoding.rb +3 -3
- data/lib/chunky_png/chunk.rb +2 -2
- data/lib/chunky_png/datastream.rb +6 -0
- data/spec/chunky_png/canvas/png_encoding_spec.rb +7 -7
- data/spec/spec_helper.rb +2 -2
- data/tasks/github-gem.rake +10 -11
- metadata +16 -19
data/Gemfile.lock
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
chunky_png (0.10.
|
4
|
+
chunky_png (0.10.4)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
+
diff-lcs (1.1.2)
|
9
10
|
rake (0.8.7)
|
10
|
-
rspec (
|
11
|
+
rspec (2.0.0)
|
12
|
+
rspec-core (= 2.0.0)
|
13
|
+
rspec-expectations (= 2.0.0)
|
14
|
+
rspec-mocks (= 2.0.0)
|
15
|
+
rspec-core (2.0.0)
|
16
|
+
rspec-expectations (2.0.0)
|
17
|
+
diff-lcs (>= 1.1.2)
|
18
|
+
rspec-mocks (2.0.0)
|
19
|
+
rspec-core (= 2.0.0)
|
20
|
+
rspec-expectations (= 2.0.0)
|
11
21
|
|
12
22
|
PLATFORMS
|
13
23
|
ruby
|
@@ -15,4 +25,4 @@ PLATFORMS
|
|
15
25
|
DEPENDENCIES
|
16
26
|
chunky_png!
|
17
27
|
rake
|
18
|
-
rspec (~>
|
28
|
+
rspec (~> 2.0)
|
data/chunky_png.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
|
4
4
|
# Do not change the version and date fields by hand. This will be done
|
5
5
|
# automatically by the gem release script.
|
6
|
-
s.version = "0.10.
|
7
|
-
s.date = "2010-10-
|
6
|
+
s.version = "0.10.4"
|
7
|
+
s.date = "2010-10-18"
|
8
8
|
|
9
9
|
s.summary = "Pure ruby library for read/write, chunk-level access to PNG files"
|
10
10
|
s.description = <<-EOT
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.homepage = 'http://wiki.github.com/wvanbergen/chunky_png'
|
32
32
|
|
33
33
|
s.add_development_dependency('rake')
|
34
|
-
s.add_development_dependency('rspec', '~>
|
34
|
+
s.add_development_dependency('rspec', '~> 2.0')
|
35
35
|
|
36
36
|
s.rdoc_options << '--title' << s.name << '--main' << 'README.rdoc' << '--line-numbers' << '--inline-source'
|
37
37
|
s.extra_rdoc_files = ['README.rdoc', 'BENCHMARKS.rdoc']
|
data/lib/chunky_png.rb
CHANGED
@@ -27,7 +27,7 @@ module ChunkyPNG
|
|
27
27
|
|
28
28
|
# The current version of ChunkyPNG. This value will be updated automatically
|
29
29
|
# by them gem:release rake task.
|
30
|
-
VERSION = "0.10.
|
30
|
+
VERSION = "0.10.4"
|
31
31
|
|
32
32
|
###################################################
|
33
33
|
# PNG international standard defined constants
|
@@ -81,7 +81,8 @@ module ChunkyPNG
|
|
81
81
|
class OutOfBounds < ChunkyPNG::ExpectationFailed
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
EMPTY_BYTEARRAY = (RUBY_VERSION.to_f < 1.9) ? "".freeze : "".force_encoding('ASCII-8BIT').freeze
|
85
|
+
EXTRA_BYTE = (RUBY_VERSION.to_f < 1.9) ? "\0" : "\0".force_encoding('ASCII-8BIT')
|
85
86
|
end
|
86
87
|
|
87
88
|
if RUBY_VERSION.to_f < 1.9
|
@@ -136,7 +136,7 @@ module ChunkyPNG
|
|
136
136
|
end
|
137
137
|
return encoding
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
# Encodes the canvas according to the PNG format specification with a given color
|
141
141
|
# mode, possibly with interlacing.
|
142
142
|
# @param [Integer] color_mode The color mode to use for encoding.
|
@@ -160,7 +160,7 @@ module ChunkyPNG
|
|
160
160
|
# @param [Integer] filtering The filtering method to use.
|
161
161
|
# @return [String] The PNG encoded canvas as string.
|
162
162
|
def encode_png_image_without_interlacing(color_mode, filtering = ChunkyPNG::FILTER_NONE)
|
163
|
-
stream =
|
163
|
+
stream = ChunkyPNG::Datastream.empty_bytearray
|
164
164
|
encode_png_image_pass_to_stream(stream, color_mode, filtering)
|
165
165
|
stream
|
166
166
|
end
|
@@ -175,7 +175,7 @@ module ChunkyPNG
|
|
175
175
|
# @param [Integer] filtering The filtering method to use.
|
176
176
|
# @return [String] The PNG encoded canvas as string.
|
177
177
|
def encode_png_image_with_interlacing(color_mode, filtering = ChunkyPNG::FILTER_NONE)
|
178
|
-
stream =
|
178
|
+
stream = ChunkyPNG::Datastream.empty_bytearray
|
179
179
|
0.upto(6) do |pass|
|
180
180
|
subcanvas = self.class.adam7_extract_pass(pass, self)
|
181
181
|
subcanvas.encoding_palette = encoding_palette
|
data/lib/chunky_png/chunk.rb
CHANGED
@@ -158,14 +158,14 @@ module ChunkyPNG
|
|
158
158
|
# @return [ChunkyPNG::Chunk::End] The new End chunk instance.
|
159
159
|
# @raise [RuntimeError] Raises an exception if the content was not empty.
|
160
160
|
def self.read(type, content)
|
161
|
-
raise 'The IEND chunk should be empty!' if content
|
161
|
+
raise 'The IEND chunk should be empty!' if content.bytesize > 0
|
162
162
|
self.new
|
163
163
|
end
|
164
164
|
|
165
165
|
# Returns an empty string, because this chunk should always be empty.
|
166
166
|
# @return [""] An empty string.
|
167
167
|
def content
|
168
|
-
|
168
|
+
ChunkyPNG::Datastream.empty_bytearray
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -146,6 +146,12 @@ module ChunkyPNG
|
|
146
146
|
# WRITING DATASTREAMS
|
147
147
|
##################################################################################
|
148
148
|
|
149
|
+
# Returns an empty stream using binary encoding that can be used as stream to encode to.
|
150
|
+
# @eturn [String] An empty, binary string.
|
151
|
+
def self.empty_bytearray
|
152
|
+
ChunkyPNG::EMPTY_BYTEARRAY.dup
|
153
|
+
end
|
154
|
+
|
149
155
|
# Writes the datastream to the given output stream.
|
150
156
|
# @param [IO] io The output stream to write to.
|
151
157
|
def write(io)
|
@@ -72,39 +72,39 @@ describe ChunkyPNG::Canvas::PNGEncoding do
|
|
72
72
|
before { @canvas = ChunkyPNG::Canvas.new(2, 2, ChunkyPNG::Color.rgba(1, 2, 3, 4)) }
|
73
73
|
|
74
74
|
it "should encode using RGBA / no filtering mode correctly" do
|
75
|
-
@canvas.encode_png_image_pass_to_stream(stream =
|
75
|
+
@canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, ChunkyPNG::FILTER_NONE)
|
76
76
|
stream.should == "\0\1\2\3\4\1\2\3\4\0\1\2\3\4\1\2\3\4"
|
77
77
|
end
|
78
78
|
|
79
79
|
it "should encode using RGBA / SUB filtering mode correctly" do
|
80
|
-
@canvas.encode_png_image_pass_to_stream(stream =
|
80
|
+
@canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, ChunkyPNG::FILTER_SUB)
|
81
81
|
stream.should == "\1\1\2\3\4\0\0\0\0\1\1\2\3\4\0\0\0\0"
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should encode using RGBA / UP filtering mode correctly" do
|
85
|
-
@canvas.encode_png_image_pass_to_stream(stream =
|
85
|
+
@canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, ChunkyPNG::FILTER_UP)
|
86
86
|
stream.should == "\2\1\2\3\4\1\2\3\4\2\0\0\0\0\0\0\0\0"
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should encode using RGBA / AVERAGE filtering mode correctly" do
|
90
|
-
@canvas.encode_png_image_pass_to_stream(stream =
|
90
|
+
@canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, ChunkyPNG::FILTER_AVERAGE)
|
91
91
|
stream.should == "\3\1\2\3\4\1\1\2\2\3\1\1\2\2\0\0\0\0"
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should encode using RGB / no filtering mode correctly" do
|
95
|
-
@canvas.encode_png_image_pass_to_stream(stream =
|
95
|
+
@canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, ChunkyPNG::FILTER_NONE)
|
96
96
|
stream.should == "\0\1\2\3\1\2\3\0\1\2\3\1\2\3"
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should encode using indexed / no filtering mode correctly" do
|
100
100
|
@canvas.stub(:encoding_palette).and_return(mock('Palette', :index => 1))
|
101
|
-
@canvas.encode_png_image_pass_to_stream(stream =
|
101
|
+
@canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, ChunkyPNG::FILTER_NONE)
|
102
102
|
stream.should == "\0\1\1\0\1\1"
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should encode using indexed / PAETH filtering mode correctly" do
|
106
106
|
@canvas.stub(:encoding_palette).and_return(mock('Palette', :index => 1))
|
107
|
-
@canvas.encode_png_image_pass_to_stream(stream =
|
107
|
+
@canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, ChunkyPNG::FILTER_PAETH)
|
108
108
|
stream.should == "\4\1\0\4\0\0"
|
109
109
|
end
|
110
110
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,7 @@ require 'bundler'
|
|
5
5
|
|
6
6
|
Bundler.setup
|
7
7
|
|
8
|
-
require '
|
8
|
+
require 'rspec'
|
9
9
|
require 'chunky_png'
|
10
10
|
|
11
11
|
module ResourceFileHelper
|
@@ -31,7 +31,7 @@ module MatrixSpecHelper
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
RSpec.configure do |config|
|
35
35
|
config.include ResourceFileHelper
|
36
36
|
config.include MatrixSpecHelper
|
37
37
|
end
|
data/tasks/github-gem.rake
CHANGED
@@ -71,23 +71,23 @@ module GithubGem
|
|
71
71
|
|
72
72
|
# Defines RSpec tasks
|
73
73
|
def define_rspec_tasks!
|
74
|
-
require '
|
74
|
+
require 'rspec/core/rake_task'
|
75
75
|
|
76
76
|
namespace(:spec) do
|
77
77
|
desc "Verify all RSpec examples for #{gemspec.name}"
|
78
|
-
|
79
|
-
t.
|
78
|
+
RSpec::Core::RakeTask.new(:basic) do |t|
|
79
|
+
t.pattern = spec_pattern
|
80
80
|
end
|
81
81
|
|
82
82
|
desc "Verify all RSpec examples for #{gemspec.name} and output specdoc"
|
83
|
-
|
84
|
-
t.
|
85
|
-
t.
|
83
|
+
RSpec::Core::RakeTask.new(:specdoc) do |t|
|
84
|
+
t.pattern = spec_pattern
|
85
|
+
t.rspec_opts = ['--format', 'documentation', '--color']
|
86
86
|
end
|
87
87
|
|
88
88
|
desc "Run RCov on specs for #{gemspec.name}"
|
89
|
-
|
90
|
-
t.
|
89
|
+
RSpec::Core::RakeTask.new(:rcov) do |t|
|
90
|
+
t.pattern = spec_pattern
|
91
91
|
t.rcov = true
|
92
92
|
t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
|
93
93
|
end
|
@@ -271,8 +271,7 @@ module GithubGem
|
|
271
271
|
# All work is done by the task's dependencies, so just display a release completed message.
|
272
272
|
def release_task
|
273
273
|
puts
|
274
|
-
puts
|
275
|
-
puts "Released #{gemspec.name} version #{gemspec.version}"
|
274
|
+
puts "Release successful."
|
276
275
|
end
|
277
276
|
|
278
277
|
private
|
@@ -333,7 +332,7 @@ module GithubGem
|
|
333
332
|
# Reload the gemspec so the changes are incorporated
|
334
333
|
load_gemspec!
|
335
334
|
|
336
|
-
#
|
335
|
+
# Also mark the Gemfile.lock file as changed because of the new version.
|
337
336
|
modified_files << 'Gemfile.lock' if File.exist?(File.join(root_dir, 'Gemfile.lock'))
|
338
337
|
end
|
339
338
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chunky_png
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 49
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 10
|
9
|
-
-
|
10
|
-
version: 0.10.
|
8
|
+
- 4
|
9
|
+
version: 0.10.4
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Willem van Bergen
|
@@ -15,38 +14,36 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-10-
|
17
|
+
date: 2010-10-18 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
21
|
+
name: rake
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
27
|
segments:
|
29
28
|
- 0
|
30
29
|
version: "0"
|
31
|
-
requirement: *id001
|
32
|
-
name: rake
|
33
|
-
prerelease: false
|
34
30
|
type: :development
|
31
|
+
prerelease: false
|
32
|
+
version_requirements: *id001
|
35
33
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
34
|
+
name: rspec
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
36
|
none: false
|
38
37
|
requirements:
|
39
38
|
- - ~>
|
40
39
|
- !ruby/object:Gem::Version
|
41
|
-
hash: 9
|
42
40
|
segments:
|
43
|
-
-
|
44
|
-
-
|
45
|
-
version: "
|
46
|
-
requirement: *id002
|
47
|
-
name: rspec
|
48
|
-
prerelease: false
|
41
|
+
- 2
|
42
|
+
- 0
|
43
|
+
version: "2.0"
|
49
44
|
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *id002
|
50
47
|
description: " This pure Ruby library can read and write PNG images without depending on an external \n image library, like RMagick. It tries to be memory efficient and reasonably fast.\n \n It supports reading and writing all PNG variants that are defined in the specification, \n with one limitation: only 8-bit color depth is supported. It supports all transparency, \n interlacing and filtering options the PNG specifications allows. It can also read and \n write textual metadata from PNG files. Low-level read/write access to PNG chunks is\n also possible.\n \n This library supports simple drawing on the image canvas and simple operations like\n alpha composition and cropping. Finally, it can import from and export to RMagick for \n interoperability.\n \n Also, have a look at OilyPNG at http://github.com/wvanbergen/oily_png. OilyPNG is a \n drop in mixin module that implements some of the ChunkyPNG algorithms in C, which \n provides a massive speed boost to encoding and decoding.\n"
|
51
48
|
email:
|
52
49
|
- willem@railsdoctors.com
|
@@ -154,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
154
151
|
requirements:
|
155
152
|
- - ">="
|
156
153
|
- !ruby/object:Gem::Version
|
157
|
-
hash:
|
154
|
+
hash: -1708180723927543177
|
158
155
|
segments:
|
159
156
|
- 0
|
160
157
|
version: "0"
|
@@ -163,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
160
|
requirements:
|
164
161
|
- - ">="
|
165
162
|
- !ruby/object:Gem::Version
|
166
|
-
hash:
|
163
|
+
hash: -1708180723927543177
|
167
164
|
segments:
|
168
165
|
- 0
|
169
166
|
version: "0"
|