chunky_png 0.12.0 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -5,4 +5,5 @@ spec/resources/_*.png
5
5
  /doc
6
6
  /.yardoc
7
7
  /.bundle
8
+ Gemfile.lock
8
9
  *.rbc
@@ -5,7 +5,7 @@ maximum portability. Let me rephrase: it does NOT require RMagick or any other
5
5
  memory leaking image library.
6
6
 
7
7
  Source code:: http://github.com/wvanbergen/chunky_png/tree
8
- RDoc:: http://rdoc.info/github/wvanbergen/chunky_png/master/file/README.rdoc
8
+ RDoc:: http://rdoc.info/gems/chunky_png/frames
9
9
  Wiki:: http://github.com/wvanbergen/chunky_png/wiki
10
10
  Issue tracker:: http://github.com/wvanbergen/chunky_png/issues
11
11
 
@@ -55,7 +55,7 @@ provides a massive speed boost to encoding and decoding.
55
55
  png_stream.each_chunk { |chunk| p chunk.type }
56
56
 
57
57
  For more information, see the project wiki on http://github.com/wvanbergen/chunky_png/wiki
58
- or the RDOC documentation on http://rdoc.info/github/wvanbergen/chunky_png/master/file/README.rdoc.
58
+ or the RDOC documentation on http://rdoc.info/gems/chunky_png/frames
59
59
 
60
60
  == About
61
61
 
data/Rakefile CHANGED
@@ -1,8 +1,3 @@
1
- require 'rubygems'
2
- require 'bundler'
3
-
4
- Bundler.setup
5
-
6
1
  Dir['tasks/*.rake'].each { |file| load(file) }
7
2
 
8
3
  GithubGem::RakeTasks.new(:gem)
@@ -1,7 +1,5 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
-
4
- Bundler.setup
2
+ require 'bundler/setup'
5
3
 
6
4
  require 'benchmark'
7
5
  require 'chunky_png'
@@ -1,7 +1,5 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
-
4
- Bundler.setup
2
+ require 'bundler/setup'
5
3
 
6
4
  require 'benchmark'
7
5
  require 'chunky_png'
@@ -1,7 +1,5 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
-
4
- Bundler.setup
2
+ require 'bundler/setup'
5
3
 
6
4
  require 'benchmark'
7
5
  require 'chunky_png'
@@ -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.12.0"
7
- s.date = "2010-12-12"
6
+ s.version = "1.0.0.beta1"
7
+ s.date = "2011-01-24"
8
8
 
9
9
  s.summary = "Pure ruby library for read/write, chunk-level access to PNG files"
10
10
  s.description = <<-EOT
@@ -38,6 +38,6 @@ Gem::Specification.new do |s|
38
38
 
39
39
  # Do not change the files and test_files fields by hand. This will be done
40
40
  # automatically by the gem release script.
41
- s.files = %w(.gitignore .infinity_test BENCHMARKS.rdoc Gemfile Gemfile.lock LICENSE README.rdoc Rakefile benchmarks/decoding_benchmark.rb benchmarks/encoding_benchmark.rb benchmarks/filesize_benchmark.rb chunky_png.gemspec lib/chunky_png.rb lib/chunky_png/canvas.rb lib/chunky_png/canvas/adam7_interlacing.rb lib/chunky_png/canvas/drawing.rb lib/chunky_png/canvas/operations.rb lib/chunky_png/canvas/png_decoding.rb lib/chunky_png/canvas/png_encoding.rb lib/chunky_png/canvas/stream_exporting.rb lib/chunky_png/canvas/stream_importing.rb lib/chunky_png/chunk.rb lib/chunky_png/color.rb lib/chunky_png/compatibility.rb lib/chunky_png/datastream.rb lib/chunky_png/image.rb lib/chunky_png/palette.rb lib/chunky_png/rmagick.rb spec/chunky_png/canvas/adam7_interlacing_spec.rb spec/chunky_png/canvas/drawing_spec.rb spec/chunky_png/canvas/operations_spec.rb spec/chunky_png/canvas/png_decoding_spec.rb spec/chunky_png/canvas/png_encoding_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png_spec.rb spec/png_suite/background_chunks/bgai4a08.png spec/png_suite/background_chunks/bgai4a16.png spec/png_suite/background_chunks/bgan6a08.png spec/png_suite/background_chunks/bgan6a16.png spec/png_suite/background_chunks/bgbn4a08.png spec/png_suite/background_chunks/bggn4a16.png spec/png_suite/background_chunks/bgwn6a08.png spec/png_suite/background_chunks/bgyn6a16.png spec/png_suite/basic/basi0g01.png spec/png_suite/basic/basi0g01.rgba spec/png_suite/basic/basi0g02.png spec/png_suite/basic/basi0g02.rgba spec/png_suite/basic/basi0g04.png spec/png_suite/basic/basi0g04.rgba spec/png_suite/basic/basi0g08.png spec/png_suite/basic/basi0g08.rgba spec/png_suite/basic/basi0g16.png spec/png_suite/basic/basi0g16.rgba spec/png_suite/basic/basi2c08.png spec/png_suite/basic/basi2c08.rgba spec/png_suite/basic/basi2c16.png spec/png_suite/basic/basi2c16.rgba spec/png_suite/basic/basi3p01.png spec/png_suite/basic/basi3p01.rgba spec/png_suite/basic/basi3p02.png spec/png_suite/basic/basi3p02.rgba spec/png_suite/basic/basi3p04.png spec/png_suite/basic/basi3p04.rgba spec/png_suite/basic/basi3p08.png spec/png_suite/basic/basi3p08.rgba spec/png_suite/basic/basi4a08.png spec/png_suite/basic/basi4a08.rgba spec/png_suite/basic/basi4a16.png spec/png_suite/basic/basi4a16.rgba spec/png_suite/basic/basi6a08.png spec/png_suite/basic/basi6a08.rgba spec/png_suite/basic/basi6a16.png spec/png_suite/basic/basi6a16.rgba spec/png_suite/basic/basn0g01.png spec/png_suite/basic/basn0g01.rgba spec/png_suite/basic/basn0g02.png spec/png_suite/basic/basn0g02.rgba spec/png_suite/basic/basn0g04.png spec/png_suite/basic/basn0g04.rgba spec/png_suite/basic/basn0g08.png spec/png_suite/basic/basn0g08.rgba spec/png_suite/basic/basn0g16.png spec/png_suite/basic/basn0g16.rgba spec/png_suite/basic/basn2c08.png spec/png_suite/basic/basn2c08.rgba spec/png_suite/basic/basn2c16.png spec/png_suite/basic/basn2c16.rgba spec/png_suite/basic/basn3p01.png spec/png_suite/basic/basn3p01.rgba spec/png_suite/basic/basn3p02.png spec/png_suite/basic/basn3p02.rgba spec/png_suite/basic/basn3p04.png spec/png_suite/basic/basn3p04.rgba spec/png_suite/basic/basn3p08.png spec/png_suite/basic/basn3p08.rgba spec/png_suite/basic/basn4a08.png spec/png_suite/basic/basn4a08.rgba spec/png_suite/basic/basn4a16.png spec/png_suite/basic/basn4a16.rgba spec/png_suite/basic/basn6a08.png spec/png_suite/basic/basn6a08.rgba spec/png_suite/basic/basn6a16.png spec/png_suite/basic/basn6a16.rgba spec/png_suite/broken/x00n0g01.png spec/png_suite/broken/xcrn0g04.png spec/png_suite/broken/xlfn0g04.png spec/png_suite/chunk_ordering/oi1n0g16.png spec/png_suite/chunk_ordering/oi1n2c16.png spec/png_suite/chunk_ordering/oi2n0g16.png spec/png_suite/chunk_ordering/oi2n2c16.png spec/png_suite/chunk_ordering/oi4n0g16.png spec/png_suite/chunk_ordering/oi4n2c16.png spec/png_suite/chunk_ordering/oi9n0g16.png spec/png_suite/chunk_ordering/oi9n2c16.png spec/png_suite/compression_levels/z00n2c08.png spec/png_suite/compression_levels/z03n2c08.png spec/png_suite/compression_levels/z06n2c08.png spec/png_suite/compression_levels/z09n2c08.png spec/png_suite/filtering/f00n0g08.png spec/png_suite/filtering/f00n0g08.rgba spec/png_suite/filtering/f00n0g08_reference.png spec/png_suite/filtering/f00n0g08_reference.rgba spec/png_suite/filtering/f00n2c08.png spec/png_suite/filtering/f00n2c08.rgba spec/png_suite/filtering/f00n2c08_reference.png spec/png_suite/filtering/f00n2c08_reference.rgba spec/png_suite/filtering/f01n0g08.png spec/png_suite/filtering/f01n0g08.rgba spec/png_suite/filtering/f01n0g08_reference.png spec/png_suite/filtering/f01n0g08_reference.rgba spec/png_suite/filtering/f01n2c08.png spec/png_suite/filtering/f01n2c08.rgba spec/png_suite/filtering/f01n2c08_reference.png spec/png_suite/filtering/f01n2c08_reference.rgba spec/png_suite/filtering/f02n0g08.png spec/png_suite/filtering/f02n0g08.rgba spec/png_suite/filtering/f02n0g08_reference.png spec/png_suite/filtering/f02n0g08_reference.rgba spec/png_suite/filtering/f02n2c08.png spec/png_suite/filtering/f02n2c08.rgba spec/png_suite/filtering/f02n2c08_reference.png spec/png_suite/filtering/f02n2c08_reference.rgba spec/png_suite/filtering/f03n0g08.png spec/png_suite/filtering/f03n0g08.rgba spec/png_suite/filtering/f03n0g08_reference.png spec/png_suite/filtering/f03n0g08_reference.rgba spec/png_suite/filtering/f03n2c08.png spec/png_suite/filtering/f03n2c08.rgba spec/png_suite/filtering/f03n2c08_reference.png spec/png_suite/filtering/f03n2c08_reference.rgba spec/png_suite/filtering/f04n0g08.png spec/png_suite/filtering/f04n0g08.rgba spec/png_suite/filtering/f04n0g08_reference.png spec/png_suite/filtering/f04n0g08_reference.rgba spec/png_suite/filtering/f04n2c08.png spec/png_suite/filtering/f04n2c08.rgba spec/png_suite/filtering/f04n2c08_reference.png spec/png_suite/filtering/f04n2c08_reference.rgba spec/png_suite/gamma/g03n0g16.png spec/png_suite/gamma/g03n2c08.png spec/png_suite/gamma/g03n3p04.png spec/png_suite/gamma/g04n0g16.png spec/png_suite/gamma/g04n2c08.png spec/png_suite/gamma/g04n3p04.png spec/png_suite/gamma/g05n0g16.png spec/png_suite/gamma/g05n2c08.png spec/png_suite/gamma/g05n3p04.png spec/png_suite/gamma/g07n0g16.png spec/png_suite/gamma/g07n2c08.png spec/png_suite/gamma/g07n3p04.png spec/png_suite/gamma/g10n0g16.png spec/png_suite/gamma/g10n2c08.png spec/png_suite/gamma/g10n3p04.png spec/png_suite/gamma/g25n0g16.png spec/png_suite/gamma/g25n2c08.png spec/png_suite/gamma/g25n3p04.png spec/png_suite/metadata/cm0n0g04.png spec/png_suite/metadata/cm7n0g04.png spec/png_suite/metadata/cm9n0g04.png spec/png_suite/other/ccwn2c08.png spec/png_suite/other/ccwn3p08.png spec/png_suite/other/cdfn2c08.png spec/png_suite/other/cdhn2c08.png spec/png_suite/other/cdsn2c08.png spec/png_suite/other/cdun2c08.png spec/png_suite/other/ch1n3p04.png spec/png_suite/other/ch2n3p08.png spec/png_suite/other/cs3n2c16.png spec/png_suite/other/cs3n3p08.png spec/png_suite/other/cs5n2c08.png spec/png_suite/other/cs5n3p08.png spec/png_suite/other/cs8n2c08.png spec/png_suite/other/cs8n3p08.png spec/png_suite/other/ct0n0g04.png spec/png_suite/other/ct1n0g04.png spec/png_suite/other/ctzn0g04.png spec/png_suite/other/pp0n2c16.png spec/png_suite/other/pp0n6a08.png spec/png_suite/other/ps1n0g08.png spec/png_suite/other/ps1n2c16.png spec/png_suite/other/ps2n0g08.png spec/png_suite/other/ps2n2c16.png spec/png_suite/sizes/s01i3p01.png spec/png_suite/sizes/s01n3p01.png spec/png_suite/sizes/s02i3p01.png spec/png_suite/sizes/s02n3p01.png spec/png_suite/sizes/s03i3p01.png spec/png_suite/sizes/s03n3p01.png spec/png_suite/sizes/s04i3p01.png spec/png_suite/sizes/s04n3p01.png spec/png_suite/sizes/s05i3p02.png spec/png_suite/sizes/s05n3p02.png spec/png_suite/sizes/s06i3p02.png spec/png_suite/sizes/s06n3p02.png spec/png_suite/sizes/s07i3p02.png spec/png_suite/sizes/s07n3p02.png spec/png_suite/sizes/s08i3p02.png spec/png_suite/sizes/s08n3p02.png spec/png_suite/sizes/s09i3p02.png spec/png_suite/sizes/s09n3p02.png spec/png_suite/sizes/s32i3p04.png spec/png_suite/sizes/s32n3p04.png spec/png_suite/sizes/s33i3p04.png spec/png_suite/sizes/s33n3p04.png spec/png_suite/sizes/s34i3p04.png spec/png_suite/sizes/s34n3p04.png spec/png_suite/sizes/s35i3p04.png spec/png_suite/sizes/s35n3p04.png spec/png_suite/sizes/s36i3p04.png spec/png_suite/sizes/s36n3p04.png spec/png_suite/sizes/s37i3p04.png spec/png_suite/sizes/s37n3p04.png spec/png_suite/sizes/s38i3p04.png spec/png_suite/sizes/s38n3p04.png spec/png_suite/sizes/s39i3p04.png spec/png_suite/sizes/s39n3p04.png spec/png_suite/sizes/s40i3p04.png spec/png_suite/sizes/s40n3p04.png spec/png_suite/transparency/tbbn1g04.png spec/png_suite/transparency/tbbn2c16.png spec/png_suite/transparency/tbbn3p08.png spec/png_suite/transparency/tbgn2c16.png spec/png_suite/transparency/tbgn3p08.png spec/png_suite/transparency/tbrn2c08.png spec/png_suite/transparency/tbwn1g16.png spec/png_suite/transparency/tbwn3p08.png spec/png_suite/transparency/tbyn3p08.png spec/png_suite/transparency/tp0n1g08.png spec/png_suite/transparency/tp0n2c08.png spec/png_suite/transparency/tp0n3p08.png spec/png_suite/transparency/tp1n3p08.png spec/png_suite_spec.rb spec/resources/adam7.png spec/resources/clock.png spec/resources/clock_base.png spec/resources/clock_flip_horizontally.png spec/resources/clock_flip_vertically.png spec/resources/clock_mask.png spec/resources/clock_mask_updated.png spec/resources/clock_rotate_180.png spec/resources/clock_rotate_left.png spec/resources/clock_rotate_right.png spec/resources/clock_stubbed.png spec/resources/clock_updated.png spec/resources/composited.png spec/resources/cropped.png spec/resources/damaged_chunk.png spec/resources/damaged_signature.png spec/resources/lines.png spec/resources/operations.png spec/resources/pixelstream.rgb spec/resources/pixelstream.rgba spec/resources/pixelstream_best_compression.png spec/resources/pixelstream_fast_rgba.png spec/resources/pixelstream_reference.png spec/resources/rect.png spec/resources/replaced.png spec/resources/text_chunk.png spec/resources/ztxt_chunk.png spec/spec_helper.rb tasks/benchmarks.rake tasks/github-gem.rake)
41
+ s.files = %w(.gitignore .infinity_test BENCHMARKS.rdoc Gemfile LICENSE README.rdoc Rakefile benchmarks/decoding_benchmark.rb benchmarks/encoding_benchmark.rb benchmarks/filesize_benchmark.rb chunky_png.gemspec lib/chunky_png.rb lib/chunky_png/canvas.rb lib/chunky_png/canvas/adam7_interlacing.rb lib/chunky_png/canvas/drawing.rb lib/chunky_png/canvas/operations.rb lib/chunky_png/canvas/png_decoding.rb lib/chunky_png/canvas/png_encoding.rb lib/chunky_png/canvas/stream_exporting.rb lib/chunky_png/canvas/stream_importing.rb lib/chunky_png/chunk.rb lib/chunky_png/color.rb lib/chunky_png/compatibility.rb lib/chunky_png/datastream.rb lib/chunky_png/image.rb lib/chunky_png/palette.rb lib/chunky_png/rmagick.rb spec/chunky_png/canvas/adam7_interlacing_spec.rb spec/chunky_png/canvas/drawing_spec.rb spec/chunky_png/canvas/operations_spec.rb spec/chunky_png/canvas/png_decoding_spec.rb spec/chunky_png/canvas/png_encoding_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png_spec.rb spec/png_suite/background_chunks/bgai4a08.png spec/png_suite/background_chunks/bgai4a16.png spec/png_suite/background_chunks/bgan6a08.png spec/png_suite/background_chunks/bgan6a16.png spec/png_suite/background_chunks/bgbn4a08.png spec/png_suite/background_chunks/bggn4a16.png spec/png_suite/background_chunks/bgwn6a08.png spec/png_suite/background_chunks/bgyn6a16.png spec/png_suite/basic/basi0g01.png spec/png_suite/basic/basi0g01.rgba spec/png_suite/basic/basi0g02.png spec/png_suite/basic/basi0g02.rgba spec/png_suite/basic/basi0g04.png spec/png_suite/basic/basi0g04.rgba spec/png_suite/basic/basi0g08.png spec/png_suite/basic/basi0g08.rgba spec/png_suite/basic/basi0g16.png spec/png_suite/basic/basi0g16.rgba spec/png_suite/basic/basi2c08.png spec/png_suite/basic/basi2c08.rgba spec/png_suite/basic/basi2c16.png spec/png_suite/basic/basi2c16.rgba spec/png_suite/basic/basi3p01.png spec/png_suite/basic/basi3p01.rgba spec/png_suite/basic/basi3p02.png spec/png_suite/basic/basi3p02.rgba spec/png_suite/basic/basi3p04.png spec/png_suite/basic/basi3p04.rgba spec/png_suite/basic/basi3p08.png spec/png_suite/basic/basi3p08.rgba spec/png_suite/basic/basi4a08.png spec/png_suite/basic/basi4a08.rgba spec/png_suite/basic/basi4a16.png spec/png_suite/basic/basi4a16.rgba spec/png_suite/basic/basi6a08.png spec/png_suite/basic/basi6a08.rgba spec/png_suite/basic/basi6a16.png spec/png_suite/basic/basi6a16.rgba spec/png_suite/basic/basn0g01.png spec/png_suite/basic/basn0g01.rgba spec/png_suite/basic/basn0g02.png spec/png_suite/basic/basn0g02.rgba spec/png_suite/basic/basn0g04.png spec/png_suite/basic/basn0g04.rgba spec/png_suite/basic/basn0g08.png spec/png_suite/basic/basn0g08.rgba spec/png_suite/basic/basn0g16.png spec/png_suite/basic/basn0g16.rgba spec/png_suite/basic/basn2c08.png spec/png_suite/basic/basn2c08.rgba spec/png_suite/basic/basn2c16.png spec/png_suite/basic/basn2c16.rgba spec/png_suite/basic/basn3p01.png spec/png_suite/basic/basn3p01.rgba spec/png_suite/basic/basn3p02.png spec/png_suite/basic/basn3p02.rgba spec/png_suite/basic/basn3p04.png spec/png_suite/basic/basn3p04.rgba spec/png_suite/basic/basn3p08.png spec/png_suite/basic/basn3p08.rgba spec/png_suite/basic/basn4a08.png spec/png_suite/basic/basn4a08.rgba spec/png_suite/basic/basn4a16.png spec/png_suite/basic/basn4a16.rgba spec/png_suite/basic/basn6a08.png spec/png_suite/basic/basn6a08.rgba spec/png_suite/basic/basn6a16.png spec/png_suite/basic/basn6a16.rgba spec/png_suite/broken/x00n0g01.png spec/png_suite/broken/xcrn0g04.png spec/png_suite/broken/xlfn0g04.png spec/png_suite/chunk_ordering/oi1n0g16.png spec/png_suite/chunk_ordering/oi1n2c16.png spec/png_suite/chunk_ordering/oi2n0g16.png spec/png_suite/chunk_ordering/oi2n2c16.png spec/png_suite/chunk_ordering/oi4n0g16.png spec/png_suite/chunk_ordering/oi4n2c16.png spec/png_suite/chunk_ordering/oi9n0g16.png spec/png_suite/chunk_ordering/oi9n2c16.png spec/png_suite/compression_levels/z00n2c08.png spec/png_suite/compression_levels/z03n2c08.png spec/png_suite/compression_levels/z06n2c08.png spec/png_suite/compression_levels/z09n2c08.png spec/png_suite/filtering/f00n0g08.png spec/png_suite/filtering/f00n0g08.rgba spec/png_suite/filtering/f00n0g08_reference.png spec/png_suite/filtering/f00n0g08_reference.rgba spec/png_suite/filtering/f00n2c08.png spec/png_suite/filtering/f00n2c08.rgba spec/png_suite/filtering/f00n2c08_reference.png spec/png_suite/filtering/f00n2c08_reference.rgba spec/png_suite/filtering/f01n0g08.png spec/png_suite/filtering/f01n0g08.rgba spec/png_suite/filtering/f01n0g08_reference.png spec/png_suite/filtering/f01n0g08_reference.rgba spec/png_suite/filtering/f01n2c08.png spec/png_suite/filtering/f01n2c08.rgba spec/png_suite/filtering/f01n2c08_reference.png spec/png_suite/filtering/f01n2c08_reference.rgba spec/png_suite/filtering/f02n0g08.png spec/png_suite/filtering/f02n0g08.rgba spec/png_suite/filtering/f02n0g08_reference.png spec/png_suite/filtering/f02n0g08_reference.rgba spec/png_suite/filtering/f02n2c08.png spec/png_suite/filtering/f02n2c08.rgba spec/png_suite/filtering/f02n2c08_reference.png spec/png_suite/filtering/f02n2c08_reference.rgba spec/png_suite/filtering/f03n0g08.png spec/png_suite/filtering/f03n0g08.rgba spec/png_suite/filtering/f03n0g08_reference.png spec/png_suite/filtering/f03n0g08_reference.rgba spec/png_suite/filtering/f03n2c08.png spec/png_suite/filtering/f03n2c08.rgba spec/png_suite/filtering/f03n2c08_reference.png spec/png_suite/filtering/f03n2c08_reference.rgba spec/png_suite/filtering/f04n0g08.png spec/png_suite/filtering/f04n0g08.rgba spec/png_suite/filtering/f04n0g08_reference.png spec/png_suite/filtering/f04n0g08_reference.rgba spec/png_suite/filtering/f04n2c08.png spec/png_suite/filtering/f04n2c08.rgba spec/png_suite/filtering/f04n2c08_reference.png spec/png_suite/filtering/f04n2c08_reference.rgba spec/png_suite/gamma/g03n0g16.png spec/png_suite/gamma/g03n2c08.png spec/png_suite/gamma/g03n3p04.png spec/png_suite/gamma/g04n0g16.png spec/png_suite/gamma/g04n2c08.png spec/png_suite/gamma/g04n3p04.png spec/png_suite/gamma/g05n0g16.png spec/png_suite/gamma/g05n2c08.png spec/png_suite/gamma/g05n3p04.png spec/png_suite/gamma/g07n0g16.png spec/png_suite/gamma/g07n2c08.png spec/png_suite/gamma/g07n3p04.png spec/png_suite/gamma/g10n0g16.png spec/png_suite/gamma/g10n2c08.png spec/png_suite/gamma/g10n3p04.png spec/png_suite/gamma/g25n0g16.png spec/png_suite/gamma/g25n2c08.png spec/png_suite/gamma/g25n3p04.png spec/png_suite/metadata/cm0n0g04.png spec/png_suite/metadata/cm7n0g04.png spec/png_suite/metadata/cm9n0g04.png spec/png_suite/other/ccwn2c08.png spec/png_suite/other/ccwn3p08.png spec/png_suite/other/cdfn2c08.png spec/png_suite/other/cdhn2c08.png spec/png_suite/other/cdsn2c08.png spec/png_suite/other/cdun2c08.png spec/png_suite/other/ch1n3p04.png spec/png_suite/other/ch2n3p08.png spec/png_suite/other/cs3n2c16.png spec/png_suite/other/cs3n3p08.png spec/png_suite/other/cs5n2c08.png spec/png_suite/other/cs5n3p08.png spec/png_suite/other/cs8n2c08.png spec/png_suite/other/cs8n3p08.png spec/png_suite/other/ct0n0g04.png spec/png_suite/other/ct1n0g04.png spec/png_suite/other/ctzn0g04.png spec/png_suite/other/pp0n2c16.png spec/png_suite/other/pp0n6a08.png spec/png_suite/other/ps1n0g08.png spec/png_suite/other/ps1n2c16.png spec/png_suite/other/ps2n0g08.png spec/png_suite/other/ps2n2c16.png spec/png_suite/sizes/s01i3p01.png spec/png_suite/sizes/s01n3p01.png spec/png_suite/sizes/s02i3p01.png spec/png_suite/sizes/s02n3p01.png spec/png_suite/sizes/s03i3p01.png spec/png_suite/sizes/s03n3p01.png spec/png_suite/sizes/s04i3p01.png spec/png_suite/sizes/s04n3p01.png spec/png_suite/sizes/s05i3p02.png spec/png_suite/sizes/s05n3p02.png spec/png_suite/sizes/s06i3p02.png spec/png_suite/sizes/s06n3p02.png spec/png_suite/sizes/s07i3p02.png spec/png_suite/sizes/s07n3p02.png spec/png_suite/sizes/s08i3p02.png spec/png_suite/sizes/s08n3p02.png spec/png_suite/sizes/s09i3p02.png spec/png_suite/sizes/s09n3p02.png spec/png_suite/sizes/s32i3p04.png spec/png_suite/sizes/s32n3p04.png spec/png_suite/sizes/s33i3p04.png spec/png_suite/sizes/s33n3p04.png spec/png_suite/sizes/s34i3p04.png spec/png_suite/sizes/s34n3p04.png spec/png_suite/sizes/s35i3p04.png spec/png_suite/sizes/s35n3p04.png spec/png_suite/sizes/s36i3p04.png spec/png_suite/sizes/s36n3p04.png spec/png_suite/sizes/s37i3p04.png spec/png_suite/sizes/s37n3p04.png spec/png_suite/sizes/s38i3p04.png spec/png_suite/sizes/s38n3p04.png spec/png_suite/sizes/s39i3p04.png spec/png_suite/sizes/s39n3p04.png spec/png_suite/sizes/s40i3p04.png spec/png_suite/sizes/s40n3p04.png spec/png_suite/transparency/tbbn1g04.png spec/png_suite/transparency/tbbn2c16.png spec/png_suite/transparency/tbbn3p08.png spec/png_suite/transparency/tbgn2c16.png spec/png_suite/transparency/tbgn3p08.png spec/png_suite/transparency/tbrn2c08.png spec/png_suite/transparency/tbwn1g16.png spec/png_suite/transparency/tbwn3p08.png spec/png_suite/transparency/tbyn3p08.png spec/png_suite/transparency/tp0n1g08.png spec/png_suite/transparency/tp0n2c08.png spec/png_suite/transparency/tp0n3p08.png spec/png_suite/transparency/tp1n3p08.png spec/png_suite_spec.rb spec/resources/adam7.png spec/resources/clock.png spec/resources/clock_base.png spec/resources/clock_flip_horizontally.png spec/resources/clock_flip_vertically.png spec/resources/clock_mask.png spec/resources/clock_mask_updated.png spec/resources/clock_rotate_180.png spec/resources/clock_rotate_left.png spec/resources/clock_rotate_right.png spec/resources/clock_stubbed.png spec/resources/clock_updated.png spec/resources/composited.png spec/resources/cropped.png spec/resources/damaged_chunk.png spec/resources/damaged_signature.png spec/resources/lines.png spec/resources/operations.png spec/resources/pixelstream.rgb spec/resources/pixelstream.rgba spec/resources/pixelstream_best_compression.png spec/resources/pixelstream_fast_rgba.png spec/resources/pixelstream_reference.png spec/resources/rect.png spec/resources/replaced.png spec/resources/text_chunk.png spec/resources/ztxt_chunk.png spec/spec_helper.rb tasks/benchmarks.rake tasks/github-gem.rake)
42
42
  s.test_files = %w(spec/chunky_png/canvas/adam7_interlacing_spec.rb spec/chunky_png/canvas/drawing_spec.rb spec/chunky_png/canvas/operations_spec.rb spec/chunky_png/canvas/png_decoding_spec.rb spec/chunky_png/canvas/png_encoding_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png_spec.rb spec/png_suite_spec.rb)
43
43
  end
@@ -28,7 +28,7 @@ module ChunkyPNG
28
28
 
29
29
  # The current version of ChunkyPNG. This value will be updated automatically
30
30
  # by them gem:release rake task.
31
- VERSION = "0.12.0"
31
+ VERSION = "1.0.0.beta1"
32
32
 
33
33
  ###################################################
34
34
  # PNG international standard defined constants
@@ -99,36 +99,30 @@ module ChunkyPNG
99
99
  # @return [Hash] A hash with encoding options for {ChunkyPNG::Canvas::PNGEncoding#to_datastream}
100
100
  def determine_png_encoding(constraints = {})
101
101
 
102
- if constraints == :fast_rgb
103
- encoding = { :color_mode => ChunkyPNG::COLOR_TRUECOLOR, :compression => Zlib::BEST_SPEED }
104
- elsif constraints == :fast_rgba
105
- encoding = { :color_mode => ChunkyPNG::COLOR_TRUECOLOR_ALPHA, :compression => Zlib::BEST_SPEED }
106
- elsif constraints == :best_compression
107
- encoding = { :compression => Zlib::BEST_COMPRESSION, :filtering => ChunkyPNG::FILTER_PAETH }
108
- elsif constraints == :good_compression
109
- encoding = { :compression => Zlib::BEST_COMPRESSION, :filtering => ChunkyPNG::FILTER_NONE }
110
- elsif constraints == :no_compression
111
- encoding = { :compression => Zlib::NO_COMPRESSION }
112
- else
113
- encoding = constraints
102
+ encoding = case constraints
103
+ when :fast_rgb; { :color_mode => ChunkyPNG::COLOR_TRUECOLOR, :compression => Zlib::BEST_SPEED }
104
+ when :fast_rgba; { :color_mode => ChunkyPNG::COLOR_TRUECOLOR_ALPHA, :compression => Zlib::BEST_SPEED }
105
+ when :best_compression; { :compression => Zlib::BEST_COMPRESSION, :filtering => ChunkyPNG::FILTER_PAETH }
106
+ when :good_compression; { :compression => Zlib::BEST_COMPRESSION, :filtering => ChunkyPNG::FILTER_NONE }
107
+ when :no_compression; { :compression => Zlib::NO_COMPRESSION }
108
+ when :black_and_white; { :color_mode => ChunkyPNG::COLOR_GRAYSCALE, :bit_depth => 1 }
109
+ when Hash; constraints
110
+ else raise ChunkyPNG::Exception, "Unknown encoding preset: #{constraints.inspect}"
114
111
  end
115
112
 
116
113
  # Do not create a pallete when the encoding is given and does not require a palette.
117
114
  if encoding[:color_mode]
118
115
  if encoding[:color_mode] == ChunkyPNG::COLOR_INDEXED
119
- self.encoding_palette = self.palette
116
+ self.encoding_palette = self.palette
117
+ encoding[:bit_depth] ||= self.encoding_palette.determine_bit_depth
118
+ else
119
+ encoding[:bit_depth] ||= 8
120
120
  end
121
121
  else
122
122
  self.encoding_palette = self.palette
123
- encoding[:color_mode] ||= encoding_palette.best_colormode
124
- end
125
-
126
- # Set the number of bits per color channel. This will always be 8 except for
127
- # indexed image, which may also use lower bit depths
128
- if encoding[:color_mode] == ChunkyPNG::COLOR_INDEXED
129
- encoding[:bit_depth] = [encoding_palette.determine_bit_depth, encoding[:bit_depth] || 1].max
130
- else
131
- encoding[:bit_depth] = 8
123
+ suggested_color_mode, suggested_bit_depth = encoding_palette.best_color_settings
124
+ encoding[:color_mode] ||= suggested_color_mode
125
+ encoding[:bit_depth] ||= suggested_bit_depth
132
126
  end
133
127
 
134
128
  # Use Zlib's default for compression unless otherwise provided.
@@ -156,8 +150,9 @@ module ChunkyPNG
156
150
  # @return [String] The PNG encoded canvas as string.
157
151
  def encode_png_pixelstream(color_mode = ChunkyPNG::COLOR_TRUECOLOR, bit_depth = 8, interlace = ChunkyPNG::INTERLACING_NONE, filtering = ChunkyPNG::FILTER_NONE)
158
152
 
159
- if color_mode == ChunkyPNG::COLOR_INDEXED && (encoding_palette.nil? || !encoding_palette.can_encode?)
160
- raise ChunkyPNG::ExpectationFailed, "This palette is not suitable for encoding!"
153
+ if color_mode == ChunkyPNG::COLOR_INDEXED
154
+ raise ChunkyPNG::ExpectationFailed, "This palette is not suitable for encoding!" if encoding_palette.nil? || !encoding_palette.can_encode?
155
+ raise ChunkyPNG::ExpectationFailed, "This palette has too many colors!" if encoding_palette.size > (1 << bit_depth)
161
156
  end
162
157
 
163
158
  case interlace
@@ -267,7 +262,7 @@ module ChunkyPNG
267
262
 
268
263
  # Encodes a line of pixels using 2-bit indexed mode.
269
264
  # @param [Array<Integer>] pixels A row of pixels of the original image.
270
- # @return [String] The encoded scanline as binary string
265
+ # @return [String] The encoded scanline as binary string
271
266
  def encode_png_pixels_to_scanline_indexed_2bit(pixels)
272
267
  chars = []
273
268
  pixels.each_slice(4) do |p1, p2, p3, p4|
@@ -297,6 +292,49 @@ module ChunkyPNG
297
292
  pixels.map { |p| encoding_palette.index(p) }.pack("xC#{width}")
298
293
  end
299
294
 
295
+ # Encodes a line of pixels using 1-bit grayscale mode.
296
+ # @param [Array<Integer>] pixels A row of pixels of the original image.
297
+ # @return [String] The encoded scanline as binary string
298
+ def encode_png_pixels_to_scanline_grayscale_1bit(pixels)
299
+ chars = []
300
+ pixels.each_slice(8) do |p1, p2, p3, p4, p5, p6, p7, p8|
301
+ chars << ((p1.nil? ? 0 : (p1 & 0x0000ffff) >> 15 << 7) |
302
+ (p2.nil? ? 0 : (p2 & 0x0000ffff) >> 15 << 6) |
303
+ (p3.nil? ? 0 : (p3 & 0x0000ffff) >> 15 << 5) |
304
+ (p4.nil? ? 0 : (p4 & 0x0000ffff) >> 15 << 4) |
305
+ (p5.nil? ? 0 : (p5 & 0x0000ffff) >> 15 << 3) |
306
+ (p6.nil? ? 0 : (p6 & 0x0000ffff) >> 15 << 2) |
307
+ (p7.nil? ? 0 : (p7 & 0x0000ffff) >> 15 << 1) |
308
+ (p8.nil? ? 0 : (p8 & 0x0000ffff) >> 15))
309
+ end
310
+ chars.pack('xC*')
311
+ end
312
+
313
+ # Encodes a line of pixels using 2-bit grayscale mode.
314
+ # @param [Array<Integer>] pixels A row of pixels of the original image.
315
+ # @return [String] The encoded scanline as binary string
316
+ def encode_png_pixels_to_scanline_grayscale_2bit(pixels)
317
+ chars = []
318
+ pixels.each_slice(4) do |p1, p2, p3, p4|
319
+ chars << ((p1.nil? ? 0 : (p1 & 0x0000ffff) >> 14 << 6) |
320
+ (p2.nil? ? 0 : (p2 & 0x0000ffff) >> 14 << 4) |
321
+ (p3.nil? ? 0 : (p3 & 0x0000ffff) >> 14 << 2) |
322
+ (p4.nil? ? 0 : (p4 & 0x0000ffff) >> 14))
323
+ end
324
+ chars.pack('xC*')
325
+ end
326
+
327
+ # Encodes a line of pixels using 2-bit grayscale mode.
328
+ # @param [Array<Integer>] pixels A row of pixels of the original image.
329
+ # @return [String] The encoded scanline as binary string
330
+ def encode_png_pixels_to_scanline_grayscale_4bit(pixels)
331
+ chars = []
332
+ pixels.each_slice(2) do |p1, p2|
333
+ chars << ((p1.nil? ? 0 : ((p1 & 0x0000ffff) >> 12) << 4) | (p2.nil? ? 0 : ((p2 & 0x0000ffff) >> 12)))
334
+ end
335
+ chars.pack('xC*')
336
+ end
337
+
300
338
  # Encodes a line of pixels using 8-bit grayscale mode.
301
339
  # @param [Array<Integer>] pixels A row of pixels of the original image.
302
340
  # @return [String] The encoded scanline as binary string
@@ -76,19 +76,26 @@ module ChunkyPNG
76
76
  size <= 256
77
77
  end
78
78
 
79
- # Check whether this pelette only contains opaque colors.
79
+ # Check whether this palette only contains opaque colors.
80
80
  # @return [true, false] True if all colors in this palette are opaque.
81
81
  # @see ChunkyPNG::Color#opaque?
82
82
  def opaque?
83
83
  all? { |color| Color.opaque?(color) }
84
84
  end
85
85
 
86
- # Check whether this pelette only contains grayscale colors.
86
+ # Check whether this palette only contains grayscale colors.
87
87
  # @return [true, false] True if all colors in this palette are grayscale teints.
88
88
  # @see ChunkyPNG::Color#grayscale??
89
89
  def grayscale?
90
90
  all? { |color| Color.grayscale?(color) }
91
91
  end
92
+
93
+ # Check whether this palette only contains bacl and white.
94
+ # @return [true, false] True if all colors in this palette are grayscale teints.
95
+ # @see ChunkyPNG::Color#grayscale??
96
+ def black_and_white?
97
+ entries == [ChunkyPNG::Color::BLACK, ChunkyPNG::Color::WHITE]
98
+ end
92
99
 
93
100
  # Returns a palette with all the opaque variants of the colors in this palette.
94
101
  # @return [ChunkyPNG::Palette] A new Palette instance with only opaque colors.
@@ -168,19 +175,21 @@ module ChunkyPNG
168
175
  # Determines the most suitable colormode for this palette.
169
176
  # @return [Integer] The colormode which would create the smalles possible
170
177
  # file for images that use this exact palette.
171
- def best_colormode
172
- if grayscale?
178
+ def best_color_settings
179
+ if black_and_white?
180
+ [ChunkyPNG::COLOR_GRAYSCALE, 1]
181
+ elsif grayscale?
173
182
  if opaque?
174
- ChunkyPNG::COLOR_GRAYSCALE
183
+ [ChunkyPNG::COLOR_GRAYSCALE, 8]
175
184
  else
176
- ChunkyPNG::COLOR_GRAYSCALE_ALPHA
185
+ [ChunkyPNG::COLOR_GRAYSCALE_ALPHA, 8]
177
186
  end
178
187
  elsif indexable?
179
- ChunkyPNG::COLOR_INDEXED
188
+ [ChunkyPNG::COLOR_INDEXED, determine_bit_depth]
180
189
  elsif opaque?
181
- ChunkyPNG::COLOR_TRUECOLOR
190
+ [ChunkyPNG::COLOR_TRUECOLOR, 8]
182
191
  else
183
- ChunkyPNG::COLOR_TRUECOLOR_ALPHA
192
+ [ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 8]
184
193
  end
185
194
  end
186
195
 
@@ -189,11 +198,11 @@ module ChunkyPNG
189
198
  # image cannot be saved as an indexed image.
190
199
  def determine_bit_depth
191
200
  case size
192
- when 1..2; 1
193
- when 3..4; 2
194
- when 5..16; 4
195
- when 17..256; 8
196
- else nil
201
+ when 1..2; 1
202
+ when 3..4; 2
203
+ when 5..16; 4
204
+ when 17..256; 8
205
+ else nil
197
206
  end
198
207
  end
199
208
  end
@@ -3,19 +3,16 @@ require 'spec_helper'
3
3
  describe ChunkyPNG::Canvas::PNGEncoding do
4
4
  include ChunkyPNG::Canvas::PNGEncoding
5
5
 
6
- describe '.encode_png' do
6
+ context 'determining encoding options' do
7
7
  [:indexed, :grayscale, :grayscale_alpha, :truecolor, :truecolor_alpha].each do |color_mode_name|
8
8
  it "should encode an image with color mode #{color_mode_name} correctly" do
9
- filename = resource_file("_tmp_#{color_mode_name}.png")
10
9
  canvas = ChunkyPNG::Canvas.new(10, 10, ChunkyPNG::Color.rgb(100, 100, 100))
11
10
  color_mode = ChunkyPNG.const_get("COLOR_#{color_mode_name.to_s.upcase}")
12
- canvas.save(filename, :color_mode => color_mode)
11
+ blob = canvas.to_blob(:color_mode => color_mode)
13
12
 
14
- ds = ChunkyPNG::Datastream.from_file(filename)
13
+ ds = ChunkyPNG::Datastream.from_blob(blob)
15
14
  ds.header_chunk.color.should == color_mode
16
15
  ChunkyPNG::Canvas.from_datastream(ds).should == ChunkyPNG::Canvas.new(10, 10, ChunkyPNG::Color.rgb(100, 100, 100))
17
-
18
- File.unlink(filename)
19
16
  end
20
17
  end
21
18
 
@@ -61,14 +58,11 @@ describe ChunkyPNG::Canvas::PNGEncoding do
61
58
 
62
59
  it "should encode an image with interlacing correctly" do
63
60
  input_canvas = ChunkyPNG::Canvas.from_file(resource_file('operations.png'))
64
- filename = resource_file("_tmp_interlaced.png")
65
- input_canvas.save(filename, :interlace => true)
61
+ blob = input_canvas.to_blob(:interlace => true)
66
62
 
67
- ds = ChunkyPNG::Datastream.from_file(filename)
63
+ ds = ChunkyPNG::Datastream.from_blob(blob)
68
64
  ds.header_chunk.interlace.should == ChunkyPNG::INTERLACING_ADAM7
69
65
  ChunkyPNG::Canvas.from_datastream(ds).should == input_canvas
70
-
71
- File.unlink(filename)
72
66
  end
73
67
 
74
68
  it "should save an image using the normal routine correctly" do
@@ -105,73 +99,80 @@ describe ChunkyPNG::Canvas::PNGEncoding do
105
99
  Zlib::Deflate.should_receive(:deflate).with(anything, Zlib::BEST_COMPRESSION).and_return('')
106
100
  canvas.to_blob(:best_compression)
107
101
  end
102
+
103
+ it "should save an image with black and white only if requested" do
104
+ ds = ChunkyPNG::Datastream.from_blob(reference_canvas('lines').to_blob(:black_and_white))
105
+ ds.header_chunk.color.should == ChunkyPNG::COLOR_GRAYSCALE
106
+ ds.header_chunk.depth.should == 1
107
+ end
108
108
  end
109
109
 
110
- describe '#encode_png_image_pass_to_stream' do
110
+ describe 'different color modes and bit depths' do
111
111
  before do
112
- @canvas = ChunkyPNG::Canvas.new(2, 2, ChunkyPNG::Color.rgba(1, 2, 3, 4))
113
- @palette_mock = mock('Palette')
114
- @palette_mock.stub(:index).with(ChunkyPNG::Color.rgba(1, 2, 3, 4)).and_return(1)
115
- @palette_mock.stub(:index).with(nil).and_return(0)
112
+ @canvas = ChunkyPNG::Canvas.new(2, 2)
113
+
114
+ @canvas[0, 0] = ChunkyPNG::Color.rgba( 1, 2, 3, 4)
115
+ @canvas[1, 0] = ChunkyPNG::Color.rgba(252, 253, 254, 255)
116
+ @canvas[0, 1] = ChunkyPNG::Color.rgba(255, 254, 253, 252)
117
+ @canvas[1, 1] = ChunkyPNG::Color.rgba( 4, 3, 2, 1)
118
+
119
+ @canvas.encoding_palette = @canvas.palette
120
+ @canvas.encoding_palette.to_plte_chunk
116
121
  end
117
122
 
118
- it "should encode using RGBA / no filtering mode correctly" do
119
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 8, ChunkyPNG::FILTER_NONE)
120
- stream.should == "\0\1\2\3\4\1\2\3\4\0\1\2\3\4\1\2\3\4"
123
+ it "should encode using 8-bit RGBA mode correctly" do
124
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 8, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
125
+ stream.should == "\0\x01\x02\x03\x04\xFC\xFD\xFE\xFF\0\xFF\xFE\xFD\xFC\x04\x03\x02\x01"
121
126
  end
122
127
 
123
- it "should encode using RGBA / SUB filtering mode correctly" do
124
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 8, ChunkyPNG::FILTER_SUB)
125
- stream.should == "\1\1\2\3\4\0\0\0\0\1\1\2\3\4\0\0\0\0"
128
+ it "should encode using 8 bit RGB mode correctly" do
129
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
130
+ stream.should == "\0\x01\x02\x03\xFC\xFD\xFE\0\xFF\xFE\xFD\x04\x03\x02"
126
131
  end
127
132
 
128
- it "should encode using RGBA / UP filtering mode correctly" do
129
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 8, ChunkyPNG::FILTER_UP)
130
- stream.should == "\2\1\2\3\4\1\2\3\4\2\0\0\0\0\0\0\0\0"
133
+ it "should encode using 1-bit grayscale mode correctly" do
134
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_GRAYSCALE, 1, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
135
+ stream.should == "\0\x40\0\x80" # Using the B byte of the pixel == 3, assuming R == G == B for grayscale images
131
136
  end
132
137
 
133
- it "should encode using RGBA / AVERAGE filtering mode correctly" do
134
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR_ALPHA, 8, ChunkyPNG::FILTER_AVERAGE)
135
- stream.should == "\3\1\2\3\4\1\1\2\2\3\1\1\2\2\0\0\0\0"
138
+ it "should encode using 2-bit grayscale mode correctly" do
139
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_GRAYSCALE, 2, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
140
+ stream.should == "\0\x30\0\xC0" # Using the B byte of the pixel == 3, assuming R == G == B for grayscale images
136
141
  end
137
142
 
138
- it "should encode using RGB / no filtering mode correctly" do
139
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_TRUECOLOR, 8, ChunkyPNG::FILTER_NONE)
140
- stream.should == "\0\1\2\3\1\2\3\0\1\2\3\1\2\3"
143
+ it "should encode using 4-bit grayscale mode correctly" do
144
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_GRAYSCALE, 4, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
145
+ stream.should == "\0\x0F\0\xF0" # Using the B byte of the pixel == 3, assuming R == G == B for grayscale images
141
146
  end
142
147
 
143
- it "should encode using indexed / no filtering mode correctly" do
144
- @canvas.stub(:encoding_palette).and_return(@palette_mock)
145
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 8, ChunkyPNG::FILTER_NONE)
146
- stream.should == "\0\1\1\0\1\1"
148
+ it "should encode using 8-bit grayscale mode correctly" do
149
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_GRAYSCALE, 8, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
150
+ stream.should == "\0\x03\xFE\0\xFD\x02" # Using the B byte of the pixel == 3, assuming R == G == B for grayscale images
147
151
  end
148
-
149
- it "should encode using 1-bit indexed / no filtering mode correctly" do
150
- @canvas.stub(:encoding_palette).and_return(@palette_mock)
151
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 1, ChunkyPNG::FILTER_NONE)
152
- stream.should == "\0\xc0\0\xc0"
152
+
153
+ it "should not encode using 1-bit indexed mode because the image has too many colors" do
154
+ lambda {
155
+ @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_INDEXED, 1, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
156
+ }.should raise_error(ChunkyPNG::ExpectationFailed)
153
157
  end
154
158
 
155
- it "should encode using 2-bit indexed / no filtering mode correctly" do
156
- @canvas.stub(:encoding_palette).and_return(@palette_mock)
157
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 2, ChunkyPNG::FILTER_NONE)
158
- stream.should == "\x00\x50\x00\x50"
159
+ it "should encode using 2-bit indexed mode correctly" do
160
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_INDEXED, 2, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
161
+ stream.should == "\0\x20\0\xD0"
159
162
  end
160
163
 
161
- it "should encode using 4-bit indexed / no filtering mode correctly" do
162
- @canvas.stub(:encoding_palette).and_return(@palette_mock)
163
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 4, ChunkyPNG::FILTER_NONE)
164
- stream.should == "\0\x11\0\x11"
164
+ it "should encode using 4-bit indexed mode correctly" do
165
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_INDEXED, 4, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
166
+ stream.should == "\0\x02\0\x31"
165
167
  end
166
-
167
- it "should encode using indexed / PAETH filtering mode correctly" do
168
- @canvas.stub(:encoding_palette).and_return(@palette_mock)
169
- @canvas.encode_png_image_pass_to_stream(stream = ChunkyPNG::Datastream.empty_bytearray, ChunkyPNG::COLOR_INDEXED, 8, ChunkyPNG::FILTER_PAETH)
170
- stream.should == "\4\1\0\4\0\0"
168
+
169
+ it "should encode using 8-bit indexed mode correctly" do
170
+ stream = @canvas.encode_png_pixelstream(ChunkyPNG::COLOR_INDEXED, 8, ChunkyPNG::INTERLACING_NONE, ChunkyPNG::FILTER_NONE)
171
+ stream.should == "\0\x00\x02\0\x03\x01"
171
172
  end
172
173
  end
173
-
174
- describe '#encode_png_str_scanline' do
174
+
175
+ describe 'different filter methods' do
175
176
 
176
177
  it "should encode a scanline without filtering correctly" do
177
178
  stream = [ChunkyPNG::FILTER_NONE, 0, 0, 0, 1, 1, 1, 2, 2, 2].pack('C*')
@@ -1,7 +1,6 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
-
4
- Bundler.require(:default, :development)
2
+ require 'bundler/setup'
3
+ require 'chunky_png'
5
4
 
6
5
  module PNGSuite
7
6
 
@@ -33,11 +32,11 @@ module ResourceFileHelper
33
32
  ChunkyPNG::Image.from_file(resource_file("#{name}.png"))
34
33
  end
35
34
 
36
- def display(canvas)
35
+ def display(png)
37
36
  filename = resource_file('_tmp.png')
38
- canvas.to_datastream.save(filename)
37
+ png.save(filename)
39
38
  `open #{filename}`
40
- end
39
+ end
41
40
  end
42
41
 
43
42
  RSpec.configure do |config|
@@ -220,7 +220,7 @@ module GithubGem
220
220
 
221
221
  def check_version_task
222
222
  raise "#{ENV['VERSION']} is not a valid version number!" if ENV['VERSION'] && !Gem::Version.correct?(ENV['VERSION'])
223
- proposed_version = Gem::Version.new(ENV['VERSION'].dup || gemspec.version)
223
+ proposed_version = Gem::Version.new((ENV['VERSION'] || gemspec.version).dup)
224
224
  raise "This version (#{proposed_version}) is not higher than the highest tagged version (#{newest_version})" if newest_version >= proposed_version
225
225
  end
226
226
 
@@ -339,22 +339,26 @@ module GithubGem
339
339
 
340
340
  # Updates the tasks file using the latest file found on Github
341
341
  def update_tasks_task
342
- require 'net/http'
343
-
344
- server = 'github.com'
345
- path = '/wvanbergen/github-gem/raw/master/tasks/github-gem.rake'
342
+ require 'net/https'
343
+ require 'uri'
344
+
345
+ uri = URI.parse('https://github.com/wvanbergen/github-gem/raw/master/tasks/github-gem.rake')
346
+ http = Net::HTTP.new(uri.host, uri.port)
347
+ http.use_ssl = true
348
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
349
+ response = http.request(Net::HTTP::Get.new(uri.path))
346
350
 
347
- Net::HTTP.start(server) do |http|
348
- response = http.get(path)
351
+ if Net::HTTPSuccess === response
349
352
  open(__FILE__, "w") { |file| file.write(response.body) }
350
- end
351
-
352
- relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
353
- if `#{git} ls-files -m #{relative_file}`.split("\n").any?
354
- sh git, 'add', relative_file
355
- sh git, 'commit', '-m', "Updated to latest gem release management tasks."
353
+ relative_file = File.expand_path(__FILE__).sub(%r[^#{@root_dir}/], '')
354
+ if `#{git} ls-files -m #{relative_file}`.split("\n").any?
355
+ sh git, 'add', relative_file
356
+ sh git, 'commit', '-m', "Updated to latest gem release management tasks."
357
+ else
358
+ puts "Release managament tasks already are at the latest version."
359
+ end
356
360
  else
357
- puts "Release managament tasks already are at the latest version."
361
+ raise "Download failed with HTTP status #{response.code}!"
358
362
  end
359
363
  end
360
364
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chunky_png
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
+ - 1
6
7
  - 0
7
- - 12
8
8
  - 0
9
- version: 0.12.0
9
+ - beta1
10
+ version: 1.0.0.beta1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Willem van Bergen
@@ -14,11 +15,12 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-12-12 00:00:00 -05:00
18
+ date: 2011-01-24 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rake
23
+ prerelease: false
22
24
  requirement: &id001 !ruby/object:Gem::Requirement
23
25
  none: false
24
26
  requirements:
@@ -28,10 +30,10 @@ dependencies:
28
30
  - 0
29
31
  version: "0"
30
32
  type: :development
31
- prerelease: false
32
33
  version_requirements: *id001
33
34
  - !ruby/object:Gem::Dependency
34
35
  name: rspec
36
+ prerelease: false
35
37
  requirement: &id002 !ruby/object:Gem::Requirement
36
38
  none: false
37
39
  requirements:
@@ -42,7 +44,6 @@ dependencies:
42
44
  - 2
43
45
  version: "2.2"
44
46
  type: :development
45
- prerelease: false
46
47
  version_requirements: *id002
47
48
  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"
48
49
  email:
@@ -59,7 +60,6 @@ files:
59
60
  - .infinity_test
60
61
  - BENCHMARKS.rdoc
61
62
  - Gemfile
62
- - Gemfile.lock
63
63
  - LICENSE
64
64
  - README.rdoc
65
65
  - Rakefile
@@ -360,19 +360,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
360
360
  requirements:
361
361
  - - ">="
362
362
  - !ruby/object:Gem::Version
363
- hash: 1966366750719945677
364
363
  segments:
365
364
  - 0
366
365
  version: "0"
367
366
  required_rubygems_version: !ruby/object:Gem::Requirement
368
367
  none: false
369
368
  requirements:
370
- - - ">="
369
+ - - ">"
371
370
  - !ruby/object:Gem::Version
372
- hash: 1966366750719945677
373
371
  segments:
374
- - 0
375
- version: "0"
372
+ - 1
373
+ - 3
374
+ - 1
375
+ version: 1.3.1
376
376
  requirements: []
377
377
 
378
378
  rubyforge_project:
@@ -1,31 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- chunky_png (0.12.0)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- bouncy-castle-java (1.5.0145.2)
10
- diff-lcs (1.1.2)
11
- jruby-openssl (0.7.2)
12
- bouncy-castle-java
13
- rake (0.8.7)
14
- rspec (2.2.0)
15
- rspec-core (~> 2.2)
16
- rspec-expectations (~> 2.2)
17
- rspec-mocks (~> 2.2)
18
- rspec-core (2.2.1)
19
- rspec-expectations (2.2.0)
20
- diff-lcs (~> 1.1.2)
21
- rspec-mocks (2.2.0)
22
-
23
- PLATFORMS
24
- java
25
- ruby
26
-
27
- DEPENDENCIES
28
- chunky_png!
29
- jruby-openssl
30
- rake
31
- rspec (~> 2.2)