chunky_png 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -0
- data/chunky_png.gemspec +3 -3
- data/lib/chunky_png.rb +1 -1
- data/lib/chunky_png/canvas/resampling.rb +114 -13
- data/lib/chunky_png/color.rb +24 -0
- data/spec/chunky_png/canvas/resampling_spec.rb +60 -3
- data/spec/resources/clock_bl_xdown_ydown.png +0 -0
- data/spec/resources/clock_bl_xdown_yup.png +0 -0
- data/spec/resources/clock_bl_xup_yup.png +0 -0
- data/spec/resources/clock_nn_xdown_ydown.png +0 -0
- data/spec/resources/clock_nn_xdown_yup.png +0 -0
- data/spec/resources/clock_nn_xup_yup.png +0 -0
- data/tasks/github-gem.rake +5 -3
- metadata +7 -3
data/.travis.yml
ADDED
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 = "1.2.
|
7
|
-
s.date = "2011-
|
6
|
+
s.version = "1.2.1"
|
7
|
+
s.date = "2011-08-10"
|
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 .yardopts 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/masking.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/resampling.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/dimension.rb lib/chunky_png/image.rb lib/chunky_png/palette.rb lib/chunky_png/point.rb lib/chunky_png/rmagick.rb lib/chunky_png/vector.rb spec/chunky_png/canvas/adam7_interlacing_spec.rb spec/chunky_png/canvas/drawing_spec.rb spec/chunky_png/canvas/masking_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/resampling_spec.rb spec/chunky_png/canvas/stream_exporting_spec.rb spec/chunky_png/canvas/stream_importing_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/dimension_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/point_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png/vector_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/bezier_five_point.png spec/resources/bezier_four_point.png spec/resources/bezier_four_point_flipped.png spec/resources/bezier_four_point_s.png spec/resources/bezier_six_point.png spec/resources/bezier_three_point.png spec/resources/bezier_three_point_flipped.png spec/resources/circles.png spec/resources/clock.png spec/resources/clock_base.png spec/resources/clock_mask.png spec/resources/clock_mask_updated.png spec/resources/clock_nn_xdown_ydown.png spec/resources/clock_nn_xdown_yup.png spec/resources/clock_nn_xup_yup.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/operations_grayscale.png spec/resources/partial_circles.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/polygon_filled_horizontal.png spec/resources/polygon_filled_vertical.png spec/resources/polygon_triangle_filled.png spec/resources/polygon_unfilled.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 .travis.yml .yardopts 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/masking.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/resampling.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/dimension.rb lib/chunky_png/image.rb lib/chunky_png/palette.rb lib/chunky_png/point.rb lib/chunky_png/rmagick.rb lib/chunky_png/vector.rb spec/chunky_png/canvas/adam7_interlacing_spec.rb spec/chunky_png/canvas/drawing_spec.rb spec/chunky_png/canvas/masking_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/resampling_spec.rb spec/chunky_png/canvas/stream_exporting_spec.rb spec/chunky_png/canvas/stream_importing_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/dimension_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/point_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png/vector_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/bezier_five_point.png spec/resources/bezier_four_point.png spec/resources/bezier_four_point_flipped.png spec/resources/bezier_four_point_s.png spec/resources/bezier_six_point.png spec/resources/bezier_three_point.png spec/resources/bezier_three_point_flipped.png spec/resources/circles.png spec/resources/clock.png spec/resources/clock_base.png spec/resources/clock_bl_xdown_ydown.png spec/resources/clock_bl_xdown_yup.png spec/resources/clock_bl_xup_yup.png spec/resources/clock_mask.png spec/resources/clock_mask_updated.png spec/resources/clock_nn_xdown_ydown.png spec/resources/clock_nn_xdown_yup.png spec/resources/clock_nn_xup_yup.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/operations_grayscale.png spec/resources/partial_circles.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/polygon_filled_horizontal.png spec/resources/polygon_filled_vertical.png spec/resources/polygon_triangle_filled.png spec/resources/polygon_unfilled.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/masking_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/resampling_spec.rb spec/chunky_png/canvas/stream_exporting_spec.rb spec/chunky_png/canvas/stream_importing_spec.rb spec/chunky_png/canvas_spec.rb spec/chunky_png/color_spec.rb spec/chunky_png/datastream_spec.rb spec/chunky_png/dimension_spec.rb spec/chunky_png/image_spec.rb spec/chunky_png/point_spec.rb spec/chunky_png/rmagick_spec.rb spec/chunky_png/vector_spec.rb spec/chunky_png_spec.rb spec/png_suite_spec.rb)
|
43
43
|
end
|
data/lib/chunky_png.rb
CHANGED
@@ -25,7 +25,7 @@ module ChunkyPNG
|
|
25
25
|
|
26
26
|
# The current version of ChunkyPNG. This value will be updated
|
27
27
|
# automatically by them <tt>gem:release</tt> rake task.
|
28
|
-
VERSION = "1.2.
|
28
|
+
VERSION = "1.2.1"
|
29
29
|
|
30
30
|
###################################################
|
31
31
|
# PNG international standard defined constants
|
@@ -1,3 +1,6 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
1
4
|
module ChunkyPNG
|
2
5
|
class Canvas
|
3
6
|
|
@@ -9,26 +12,80 @@ module ChunkyPNG
|
|
9
12
|
#
|
10
13
|
# @see ChunkyPNG::Canvas
|
11
14
|
module Resampling
|
15
|
+
|
16
|
+
# Interger Interpolation between two values
|
17
|
+
#
|
18
|
+
# Used for generating indicies for interpolation (eg, nearest
|
19
|
+
# neighbour).
|
20
|
+
#
|
21
|
+
# @param [Integer] width The width of the source
|
22
|
+
# @param [Integer] new_width The width of the destination
|
23
|
+
# @return [Array<Integer>] An Array of Integer indicies
|
24
|
+
def steps(width, new_width)
|
25
|
+
indicies, residues = steps_residues(width, new_width)
|
26
|
+
|
27
|
+
for i in 1..new_width
|
28
|
+
indicies[i-1] = (indicies[i-1] + (residues[i-1] + 127)/255)
|
29
|
+
end
|
30
|
+
return indicies
|
31
|
+
end
|
32
|
+
|
33
|
+
# Fractional Interpolation between two values
|
34
|
+
#
|
35
|
+
# Used for generating values for interpolation (eg, bilinear).
|
36
|
+
# Produces both the indices and the interpolation factors (residues).
|
37
|
+
#
|
38
|
+
# @param [Integer] width The width of the source
|
39
|
+
# @param [Integer] new_width The width of the destination
|
40
|
+
# @return [Array<Integer>, Array<Integer>] Two arrays of indicies and residues
|
41
|
+
def steps_residues(width, new_width)
|
42
|
+
indicies = Array.new(size=new_width, obj=nil)
|
43
|
+
residues = Array.new(size=new_width, obj=nil)
|
44
|
+
|
45
|
+
# This works by accumulating the fractional error and
|
46
|
+
# overflowing when necessary.
|
47
|
+
|
48
|
+
# We use mixed number arithmetic with a denominator of
|
49
|
+
# 2 * new_width
|
50
|
+
base_step = width / new_width
|
51
|
+
err_step = (width % new_width) << 1
|
52
|
+
denominator = (new_width) << 1
|
53
|
+
|
54
|
+
# Initial pixel
|
55
|
+
index = (width - new_width) / denominator
|
56
|
+
err = (width - new_width) % denominator
|
57
|
+
|
58
|
+
for i in 1..new_width
|
59
|
+
indicies[i-1] = index
|
60
|
+
residues[i-1] = (255.0 * err.to_f / denominator.to_f).round
|
61
|
+
|
62
|
+
index += base_step
|
63
|
+
err += err_step
|
64
|
+
if err >= denominator
|
65
|
+
index += 1
|
66
|
+
err -= denominator
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
return indicies, residues
|
71
|
+
end
|
72
|
+
|
12
73
|
|
13
|
-
# Resamples the canvas.
|
74
|
+
# Resamples the canvas using nearest neighbor interpolation.
|
14
75
|
# @param [Integer] new_width The width of the resampled canvas.
|
15
76
|
# @param [Integer] new_height The height of the resampled canvas.
|
16
77
|
# @return [ChunkyPNG::Canvas] A new canvas instance with the resampled pixels.
|
17
78
|
def resample_nearest_neighbor!(new_width, new_height)
|
18
|
-
|
19
|
-
|
20
|
-
height_ratio = height.to_f / new_height.to_f
|
79
|
+
steps_x = steps(width, new_width)
|
80
|
+
steps_y = steps(height, new_height)
|
21
81
|
|
22
|
-
pixels = []
|
23
|
-
for y in 1..new_height do
|
24
|
-
source_y = (y - 0.5) * height_ratio + 0.5
|
25
|
-
input_y = source_y.to_i
|
26
82
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
pixels
|
83
|
+
pixels = Array(size=new_width*new_height)
|
84
|
+
i = 0
|
85
|
+
for y in steps_y
|
86
|
+
for x in steps_x
|
87
|
+
pixels[i] = get_pixel(x, y)
|
88
|
+
i += 1
|
32
89
|
end
|
33
90
|
end
|
34
91
|
|
@@ -38,6 +95,50 @@ module ChunkyPNG
|
|
38
95
|
def resample_nearest_neighbor(new_width, new_height)
|
39
96
|
dup.resample_nearest_neighbor!(new_width, new_height)
|
40
97
|
end
|
98
|
+
|
99
|
+
# Resamples the canvas with bilinear interpolation.
|
100
|
+
# @param [Integer] new_width The width of the resampled canvas.
|
101
|
+
# @param [Integer] new_height The height of the resampled canvas.
|
102
|
+
# @return [ChunkyPNG::Canvas] A new canvas instance with the resampled pixels.
|
103
|
+
def resample_bilinear!(new_width, new_height)
|
104
|
+
index_x, interp_x = steps_residues(width, new_width)
|
105
|
+
index_y, interp_y = steps_residues(height, new_height)
|
106
|
+
|
107
|
+
pixels = Array(size=new_width*new_height)
|
108
|
+
i = 0
|
109
|
+
for y in 1..new_height
|
110
|
+
# Clamp the indicies to the edges of the image
|
111
|
+
y1 = [index_y[y-1], 0].max
|
112
|
+
y2 = [index_y[y-1] + 1, height - 1].min
|
113
|
+
y_residue = interp_y[y-1]
|
114
|
+
|
115
|
+
for x in 1..new_width
|
116
|
+
# Clamp the indicies to the edges of the image
|
117
|
+
x1 = [index_x[x-1], 0].max
|
118
|
+
x2 = [index_x[x-1] + 1, width - 1].min
|
119
|
+
x_residue = interp_x[x-1]
|
120
|
+
|
121
|
+
pixel_11 = get_pixel(x1, y1)
|
122
|
+
pixel_21 = get_pixel(x2, y1)
|
123
|
+
pixel_12 = get_pixel(x1, y2)
|
124
|
+
pixel_22 = get_pixel(x2, y2)
|
125
|
+
|
126
|
+
# Interpolate by Row
|
127
|
+
pixel_top = ChunkyPNG::Color.interpolate_quick(pixel_21, pixel_11, x_residue)
|
128
|
+
pixel_bot = ChunkyPNG::Color.interpolate_quick(pixel_22, pixel_12, x_residue)
|
129
|
+
|
130
|
+
# Interpolate by Column
|
131
|
+
|
132
|
+
pixels[i] = ChunkyPNG::Color.interpolate_quick(pixel_bot, pixel_top, y_residue)
|
133
|
+
i += 1
|
134
|
+
end
|
135
|
+
end
|
136
|
+
replace_canvas!(new_width.to_i, new_height.to_i, pixels)
|
137
|
+
end
|
138
|
+
|
139
|
+
def resample_bilinear(new_width, new_height)
|
140
|
+
dup.resample_bilinear!(new_width, new_height)
|
141
|
+
end
|
41
142
|
|
42
143
|
alias_method :resample, :resample_nearest_neighbor
|
43
144
|
alias_method :resize, :resample
|
data/lib/chunky_png/color.rb
CHANGED
@@ -305,6 +305,30 @@ module ChunkyPNG
|
|
305
305
|
(fg + bg) >> 1
|
306
306
|
end
|
307
307
|
|
308
|
+
# Interpolates the foreground and background colors by the given alpha value.
|
309
|
+
# This also blends the alpha channels themselves.
|
310
|
+
#
|
311
|
+
# A blending factor of 255 will give entirely the foreground,
|
312
|
+
# while a blending factor of 0 will give the background.
|
313
|
+
#
|
314
|
+
# @param [Integer] fg The foreground color.
|
315
|
+
# @param [Integer] bg The background color.
|
316
|
+
# @param [Integer] alpha The blending factor (fixed 8bit)
|
317
|
+
# @param [Integer] The interpolated color.
|
318
|
+
def interpolate_quick(fg, bg, alpha)
|
319
|
+
return fg if alpha >= 255
|
320
|
+
return bg if alpha <= 0
|
321
|
+
|
322
|
+
alpha_com = 255 - alpha
|
323
|
+
|
324
|
+
new_r = int8_mult(alpha, r(fg)) + int8_mult(alpha_com, r(bg))
|
325
|
+
new_g = int8_mult(alpha, g(fg)) + int8_mult(alpha_com, g(bg))
|
326
|
+
new_b = int8_mult(alpha, b(fg)) + int8_mult(alpha_com, b(bg))
|
327
|
+
new_a = int8_mult(alpha, a(fg)) + int8_mult(alpha_com, a(bg))
|
328
|
+
|
329
|
+
return rgba(new_r, new_g, new_b, new_a)
|
330
|
+
end
|
331
|
+
|
308
332
|
# Calculates the grayscale teint of an RGB color.
|
309
333
|
#
|
310
334
|
# @param [Integer] color The color to convert.
|
@@ -8,12 +8,12 @@ describe ChunkyPNG::Canvas::Resampling do
|
|
8
8
|
|
9
9
|
it "should downscale from 2x2 to 1x1 correctly" do
|
10
10
|
canvas = ChunkyPNG::Canvas.new(2, 2, [1, 2, 3, 4])
|
11
|
-
canvas.resample_nearest_neighbor(1, 1).should == ChunkyPNG::Canvas.new(1, 1, [
|
11
|
+
canvas.resample_nearest_neighbor(1, 1).should == ChunkyPNG::Canvas.new(1, 1, [4])
|
12
12
|
end
|
13
13
|
|
14
|
-
it "should
|
14
|
+
it "should upscale from 2x2 to 4x4 correctly" do
|
15
15
|
canvas = ChunkyPNG::Canvas.new(2, 2, [1, 2, 3, 4])
|
16
|
-
canvas.resample_nearest_neighbor(4, 4).should == ChunkyPNG::Canvas.new(4, 4, [1,1,
|
16
|
+
canvas.resample_nearest_neighbor(4, 4).should == ChunkyPNG::Canvas.new(4, 4, [1, 1, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 4, 4])
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should upscale both axis of the image" do
|
@@ -61,4 +61,61 @@ describe ChunkyPNG::Canvas::Resampling do
|
|
61
61
|
lambda { subject.resample_nearest_neighbor!(1, 1) }.should change(subject, :dimension).to(ChunkyPNG::Dimension('1x1'))
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
describe "#resample_bilinear" do
|
66
|
+
it "should downscale from 2x2 to 1x1 correctly" do
|
67
|
+
canvas = ChunkyPNG::Canvas.new(2, 2, [1, 2, 3, 4])
|
68
|
+
canvas.resample_bilinear(1, 1).should == ChunkyPNG::Canvas.new(1, 1, [2])
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should upscale from 2x2 to 4x4 correctly" do
|
72
|
+
canvas = ChunkyPNG::Canvas.new(2, 2, [1, 2, 3, 4])
|
73
|
+
canvas.resample_bilinear(4, 4).should == ChunkyPNG::Canvas.new(4, 4, [1, 2, 1, 2, 2, 2, 2, 2, 2, 3, 3, 4, 3, 3, 4, 4])
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should upscale both axis of the image" do
|
77
|
+
subject.resample_bilinear(45, 45).should == reference_canvas('clock_bl_xup_yup')
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should downscale both axis of the image" do
|
81
|
+
subject.resample_bilinear(12, 12).should == reference_canvas('clock_bl_xdown_ydown')
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should downscale the x-axis and upscale the y-axis of the image" do
|
85
|
+
subject.resample_bilinear(20, 50).should == reference_canvas('clock_bl_xdown_yup')
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should not return itself" do
|
89
|
+
subject.resample_bilinear(1, 1).should_not equal(subject)
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not change the original image's dimensions" do
|
93
|
+
lambda { subject.resample_bilinear(1, 1) }.should_not change(subject, :dimension)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#resample_bilinear!' do
|
98
|
+
it "should upscale both axis of the image" do
|
99
|
+
subject.resample_bilinear!(45, 45)
|
100
|
+
subject.should == reference_canvas('clock_bl_xup_yup')
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should downscale both axis of the image" do
|
104
|
+
subject.resample_bilinear!(12, 12)
|
105
|
+
subject.should == reference_canvas('clock_bl_xdown_ydown')
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should downscale the x-axis and upscale the y-axis of the image" do
|
109
|
+
subject.resample_bilinear!(20, 50)
|
110
|
+
subject.should == reference_canvas('clock_bl_xdown_yup')
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should return itself" do
|
114
|
+
subject.resample_bilinear!(1, 1).should equal(subject)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should change the original image's dimensions" do
|
118
|
+
lambda { subject.resample_bilinear!(1, 1) }.should change(subject, :dimension).to(ChunkyPNG::Dimension('1x1'))
|
119
|
+
end
|
120
|
+
end
|
64
121
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/tasks/github-gem.rake
CHANGED
@@ -13,8 +13,8 @@ module GithubGem
|
|
13
13
|
|
14
14
|
# Detects the main include file of this project using heuristics
|
15
15
|
def self.detect_main_include
|
16
|
-
if
|
17
|
-
"lib/#{
|
16
|
+
if File.exist?(File.expand_path("../lib/#{File.basename(detect_gemspec_file, '.gemspec').gsub(/-/, '/')}.rb", detect_gemspec_file))
|
17
|
+
"lib/#{File.basename(detect_gemspec_file, '.gemspec').gsub(/-/, '/')}.rb"
|
18
18
|
elsif FileList['lib/*.rb'].length == 1
|
19
19
|
FileList['lib/*.rb'].first
|
20
20
|
else
|
@@ -24,6 +24,8 @@ module GithubGem
|
|
24
24
|
|
25
25
|
class RakeTasks
|
26
26
|
|
27
|
+
include Rake::DSL if Rake.const_defined?('DSL')
|
28
|
+
|
27
29
|
attr_reader :gemspec, :modified_files
|
28
30
|
attr_accessor :gemspec_file, :task_namespace, :main_include, :root_dir, :spec_pattern, :test_pattern, :remote, :remote_branch, :local_branch
|
29
31
|
|
@@ -342,7 +344,7 @@ module GithubGem
|
|
342
344
|
require 'net/https'
|
343
345
|
require 'uri'
|
344
346
|
|
345
|
-
uri = URI.parse('https://github.com/wvanbergen/github-gem/
|
347
|
+
uri = URI.parse('https://raw.github.com/wvanbergen/github-gem/master/tasks/github-gem.rake')
|
346
348
|
http = Net::HTTP.new(uri.host, uri.port)
|
347
349
|
http.use_ssl = true
|
348
350
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 1.2.
|
8
|
+
- 1
|
9
|
+
version: 1.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Willem van Bergen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-08-10 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -57,6 +57,7 @@ extra_rdoc_files:
|
|
57
57
|
files:
|
58
58
|
- .gitignore
|
59
59
|
- .infinity_test
|
60
|
+
- .travis.yml
|
60
61
|
- .yardopts
|
61
62
|
- BENCHMARKS.rdoc
|
62
63
|
- Gemfile
|
@@ -334,6 +335,9 @@ files:
|
|
334
335
|
- spec/resources/circles.png
|
335
336
|
- spec/resources/clock.png
|
336
337
|
- spec/resources/clock_base.png
|
338
|
+
- spec/resources/clock_bl_xdown_ydown.png
|
339
|
+
- spec/resources/clock_bl_xdown_yup.png
|
340
|
+
- spec/resources/clock_bl_xup_yup.png
|
337
341
|
- spec/resources/clock_mask.png
|
338
342
|
- spec/resources/clock_mask_updated.png
|
339
343
|
- spec/resources/clock_nn_xdown_ydown.png
|