Class | Origami::Stream |
In: |
sources/parser/stream.rb
sources/parser/obfuscation.rb |
Parent: | Object |
Length | = | @rawdata.length |
Length | = | @rawdata.length |
dictionary | [RW] |
Returns the uncompressed stream content.
# File sources/parser/stream.rb, line 162 162: def data 163: self.decode! if @data.nil? 164: 165: @data 166: end
Uncompress the stream data.
# File sources/parser/stream.rb, line 198 198: def decode! 199: 200: if @rawdata 201: 202: filters = @dictionary[:Filter] 203: 204: if filters.nil? 205: @data = @rawdata 206: elsif filters.type == :Array 207: 208: @data = @rawdata 209: 210: filters.each { |filter| 211: @data = decodedata(@data, filter) 212: } 213: 214: elsif filters.type == :Name 215: 216: @data = decodedata(@rawdata, filters) 217: else 218: raise InvalidStream, "Invalid Filter type parameter" 219: end 220: 221: end 222: 223: self 224: end
Compress the stream data.
# File sources/parser/stream.rb, line 229 229: def encode! 230: 231: if @data 232: 233: filters = @dictionary[:Filter] 234: 235: if filters.nil? 236: @rawdata = @data 237: elsif filters.is_a?(Array) 238: 239: @rawdata = @data 240: 241: filters.to_a.reverse.each { |filter| 242: @rawdata = encodedata(@rawdata, filter) 243: } 244: 245: elsif filters.is_a?(Name) 246: 247: @rawdata = encodedata(@data, filters) 248: 249: else 250: raise InvalidStream, "Invalid filter type parameter" 251: end 252: 253: self.Length = @rawdata.length 254: 255: end 256: 257: self 258: end
# File sources/parser/stream.rb, line 90 90: def post_build 91: 92: unless self.Length.nil? 93: self.Length = @rawdata.length 94: end 95: 96: super 97: end
# File sources/parser/stream.rb, line 83 83: def pre_build 84: set_indirect(true) 85: encode! 86: 87: super 88: end
Returns the raw compressed stream content.
# File sources/parser/stream.rb, line 180 180: def rawdata 181: self.encode! if @rawdata.nil? 182: 183: @rawdata 184: end
# File sources/parser/stream.rb, line 138 138: def set_predictor(predictor, colors = 1, bitspercomponent = 8, columns = 1) 139: 140: filters = @dictionary[:Filter].is_a?(::Array) ? filters : [ @dictionary[:Filter] ] 141: 142: if not filters.include?(:FlateDecode) and not filters.include?(:LZWDecode) 143: raise InvalidStream, 'Predictor functions can only be used with Flate or LZW filters' 144: end 145: 146: params = @dictionary[:DecodeParms] ||= Filter::LZW::DecodeParms.new 147: params[:Predictor] = predictor 148: params[:Colors] = colors if colors != 1 149: params[:BitsPerComponent] = bitspercomponent if bitspercomponent != 8 150: params[:Columns] = columns if columns != 1 151: 152: self 153: end