Class: PDF::Reader::Filter::Depredict

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/reader/filter/depredict.rb

Overview

some filter implementations support preprocessing of the data to improve compression

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Depredict

Returns a new instance of Depredict


8
9
10
# File 'lib/pdf/reader/filter/depredict.rb', line 8

def initialize(options = {})
  @options = options || {}
end

Instance Method Details

#filter(data) ⇒ Object

Streams can be preprocessed to improve compression. This reverses the preprocessing


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pdf/reader/filter/depredict.rb', line 16

def filter(data)
  predictor = @options[:Predictor].to_i

  case predictor
  when 0, 1 then
    data
  when 2    then
    tiff_depredict(data)
  when 10, 11, 12, 13, 14, 15 then
    png_depredict(data)
  else
    raise  MalformedPDFError, "Unrecognised predictor value (#{predictor})"
  end
end