Sha256: c44439865d7bb160456806329250d18a7cdfe079a1257c5d2ea4f8bf999aaa62
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
require File.expand_path('../spec_helper.rb', File.dirname(__FILE__)) describe ChunkyPNG::PixelMatrix::Decoding do include ChunkyPNG::PixelMatrix::Decoding describe '#decode_scanline' do it "should decode a line without filtering as is" do bytes = [255, 255, 255, 255, 255, 255, 255, 255, 255] decode_scanline(ChunkyPNG::PixelMatrix::FILTER_NONE, bytes, nil).should == bytes end it "should decode a line with sub filtering correctly" do # all white pixels bytes = [255, 255, 255, 0, 0, 0, 0, 0, 0] decoded_bytes = decode_scanline(ChunkyPNG::PixelMatrix::FILTER_SUB, bytes, nil) decoded_bytes.should == [255, 255, 255, 255, 255, 255, 255, 255, 255] # all black pixels bytes = [0, 0, 0, 0, 0, 0, 0, 0, 0] decoded_bytes = decode_scanline(ChunkyPNG::PixelMatrix::FILTER_SUB, bytes, nil) decoded_bytes.should == [0, 0, 0, 0, 0, 0, 0, 0, 0] # various colors bytes = [255, 0, 45, 0, 255, 0, 112, 200, 178] decoded_bytes = decode_scanline(ChunkyPNG::PixelMatrix::FILTER_SUB, bytes, nil) decoded_bytes.should == [255, 0, 45, 255, 255, 45, 111, 199, 223] end it "should decode a line with up filtering correctly" do # previous line is all black previous_bytes = [0, 0, 0, 0, 0, 0, 0, 0, 0] bytes = [255, 255, 255, 127, 127, 127, 0, 0, 0] decoded_bytes = decode_scanline(ChunkyPNG::PixelMatrix::FILTER_UP, bytes, previous_bytes) decoded_bytes.should == [255, 255, 255, 127, 127, 127, 0, 0, 0] # previous line has various pixels previous_bytes = [255, 255, 255, 127, 127, 127, 0, 0, 0] bytes = [0, 127, 255, 0, 127, 255, 0, 127, 255] decoded_bytes = decode_scanline(ChunkyPNG::PixelMatrix::FILTER_UP, bytes, previous_bytes) decoded_bytes.should == [255, 126, 254, 127, 254, 126, 0, 127, 255] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chunky_png-0.0.2 | spec/unit/decoding_spec.rb |