Method: Origami::Stream#set_predictor
- Defined in:
- lib/origami/stream.rb
#set_predictor(predictor, colors: 1, bitspercomponent: 8, columns: 1) ⇒ Object
Set predictor type for the current Stream. Applies only for LZW and FlateDecode filters.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/origami/stream.rb', line 227 def set_predictor(predictor, colors: 1, bitspercomponent: 8, columns: 1) filters = self.filters layer = filters.index(:FlateDecode) or filters.index(:LZWDecode) if layer.nil? raise InvalidStreamObjectError, 'Predictor functions can only be used with Flate or LZW filters' end params = Filter::LZW::DecodeParms.new params[:Predictor] = predictor params[:Colors] = colors if colors != 1 params[:BitsPerComponent] = bitspercomponent if bitspercomponent != 8 params[:Columns] = columns if columns != 1 set_decode_params(layer, params) self end |