Class: PNG::IDAT

Inherits:
Chunk show all
Defined in:
lib/spittle/png/idat.rb

Instance Method Summary collapse

Methods inherited from Chunk

#to_chunk

Constructor Details

#initialize(uncompressed = "") ⇒ IDAT

I don’t like that @compressed contains different values depending on how you’re using it maybe we should introduce a builder?



5
6
7
8
# File 'lib/spittle/png/idat.rb', line 5

def initialize( uncompressed="" )
  @compressed = ""
  @compressed += Zlib::Deflate.deflate( uncompressed.pack("C*") ) unless uncompressed == ""
end

Instance Method Details

#<<(data) ⇒ Object



10
11
12
# File 'lib/spittle/png/idat.rb', line 10

def <<( data )
  @compressed << data
end

#chunk_nameObject



22
23
24
# File 'lib/spittle/png/idat.rb', line 22

def chunk_name
  "IDAT"
end

#encodeObject



14
15
16
# File 'lib/spittle/png/idat.rb', line 14

def encode
  @compressed
end

#uncompressedObject



18
19
20
# File 'lib/spittle/png/idat.rb', line 18

def uncompressed
  @uncompressed ||= Zlib::Inflate.inflate( @compressed ).unpack("C*")
end