Class: Pdfrb::Model::Type::FunctionSampled

Inherits:
Cos::Stream show all
Defined in:
lib/pdfrb/model/type/function_sampled.rb

Overview

Type 0 Sampled function (s8.9.3). N-dimensional lookup table with interpolation. Carries sample data in the stream payload.

Instance Attribute Summary

Attributes inherited from Cos::Stream

#stream

Attributes inherited from Object

#document, #gen, #oid, #value

Instance Method Summary collapse

Methods inherited from Cos::Stream

#decoded_stream, #encoded_stream=, #initialize

Methods inherited from Cos::Dictionary

#[], #[]=, apply_arlington_definition, arlington_default, arlington_key_to_symbol, arlington_one_type_to_ruby, arlington_required?, arlington_scalar, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, merged_field, own_fields, #pdf_type, register_type, type_map, #validate

Methods included from Cos::ArlingtonBacked

#arlington_object

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Stream

Instance Method Details

#bit_depth_16?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/pdfrb/model/type/function_sampled.rb', line 50

def bit_depth_16?
  bits_per_sample == 16
end

#bit_depth_8?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/pdfrb/model/type/function_sampled.rb', line 46

def bit_depth_8?
  bits_per_sample == 8
end

#bits_per_sampleObject



15
# File 'lib/pdfrb/model/type/function_sampled.rb', line 15

def bits_per_sample; self[:BitsPerSample]; end

#decodeObject



17
# File 'lib/pdfrb/model/type/function_sampled.rb', line 17

def decode; self[:Decode]; end

#domainObject



12
# File 'lib/pdfrb/model/type/function_sampled.rb', line 12

def domain; self[:Domain]; end

#encodeObject



16
# File 'lib/pdfrb/model/type/function_sampled.rb', line 16

def encode; self[:Encode]; end

#function_typeObject



10
# File 'lib/pdfrb/model/type/function_sampled.rb', line 10

def function_type; self[:FunctionType] || 0; end

#input_dimensionObject



23
24
25
26
27
28
# File 'lib/pdfrb/model/type/function_sampled.rb', line 23

def input_dimension
  return nil unless domain

  arr = domain.is_a?(Pdfrb::Model::PdfArray) ? domain.to_a : domain
  arr.is_a?(Array) ? arr.size / 2 : nil
end

#output_dimensionObject



30
31
32
33
34
35
# File 'lib/pdfrb/model/type/function_sampled.rb', line 30

def output_dimension
  return nil unless range

  arr = range.is_a?(Pdfrb::Model::PdfArray) ? range.to_a : range
  arr.is_a?(Array) ? arr.size / 2 : nil
end

#rangeObject



13
# File 'lib/pdfrb/model/type/function_sampled.rb', line 13

def range; self[:Range]; end

#sample_countObject



37
38
39
40
41
42
43
44
# File 'lib/pdfrb/model/type/function_sampled.rb', line 37

def sample_count
  return 1 unless size

  arr = size.is_a?(Pdfrb::Model::PdfArray) ? size.to_a : size
  return 1 unless arr.is_a?(Array) && !arr.empty?

  arr.reduce(1) { |product, n| product * n.to_i }
end

#sampled?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/pdfrb/model/type/function_sampled.rb', line 19

def sampled?
  true
end

#sizeObject



14
# File 'lib/pdfrb/model/type/function_sampled.rb', line 14

def size; self[:Size]; end