Sha256: bd59a795259fcd8b6cf25bb72d2b22df0632953ea6fb24c742015206d5a8aa1d

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require File.expand_path('../spec_helper.rb', File.dirname(__FILE__))

describe ChunkyPNG::PixelMatrix::Encoding do
  include ChunkyPNG::PixelMatrix::Encoding
  
  describe '#encode_scanline' do
    
    it "should encode a scanline without filtering correctly" do
      bytes = [0, 0, 0, 1, 1, 1, 2, 2, 2]
      encoded_bytes = encode_scanline(ChunkyPNG::PixelMatrix::FILTER_NONE, bytes, nil)
      encoded_bytes.should == [0, 0, 0, 0, 1, 1, 1, 2, 2, 2]
    end
    
    it "should encode a scanline with sub filtering correctly" do
      bytes = [255, 255, 255, 255, 255, 255, 255, 255, 255]
      encoded_bytes = encode_scanline(ChunkyPNG::PixelMatrix::FILTER_SUB, bytes, nil)
      encoded_bytes.should == [1, 255, 255, 255, 0, 0, 0, 0, 0, 0]
    end
    
    it "should encode a scanline with up filtering correctly" do
      bytes          = [255, 255, 255, 255, 255, 255, 255, 255, 255]
      previous_bytes = [255, 255, 255, 255, 255, 255, 255, 255, 255]
      encoded_bytes  = encode_scanline(ChunkyPNG::PixelMatrix::FILTER_UP, bytes, previous_bytes)
      encoded_bytes.should == [2, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chunky_png-0.0.2 spec/unit/encoding_spec.rb