Object
Class representing a Filter used to encode and decode data with zlib/Flate compression algorithm.
Decodes data using zlib/Inflate decompression method.
stream |
The data to decode. |
# File lib/origami/filters/flate.rb, line 80 def decode(stream) zlib_stream = Zlib::Inflate.new begin uncompressed = zlib_stream.inflate(stream) rescue Zlib::DataError => zlib_except uncompressed = zlib_stream.flush_next_out unless Origami::OPTIONS[:ignore_zlib_errors] raise InvalidFlateDataError.new(zlib_except.message, uncompressed) end end if @params.Predictor.is_a?(Integer) colors = @params.Colors.is_a?(Integer) ? @params.Colors.to_i : 1 bpc = @params.BitsPerComponent.is_a?(Integer) ? @params.BitsPerComponent.to_i : 8 columns = @params.Columns.is_a?(Integer) ? @params.Columns.to_i : 1 uncompressed = Predictor.do_post_prediction(uncompressed, @params.Predictor.to_i, colors, bpc, columns) end uncompressed end
Encodes data using zlib/Deflate compression method.
stream |
The data to encode. |
# File lib/origami/filters/flate.rb, line 64 def encode(stream) if @params.Predictor.is_a?(Integer) colors = @params.Colors.is_a?(Integer) ? @params.Colors.to_i : 1 bpc = @params.BitsPerComponent.is_a?(Integer) ? @params.BitsPerComponent.to_i : 8 columns = @params.Columns.is_a?(Integer) ? @params.Columns.to_i : 1 stream = Predictor.do_pre_prediction(stream, @params.Predictor.to_i, colors, bpc, columns) end Zlib::Deflate.deflate(stream, Zlib::BEST_COMPRESSION) end
Generated with the Darkfish Rdoc Generator 2.