Class: Pdfrb::Model::Type::XObjectImage

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

Overview

Image XObject (s8.9). /Type /XObject, /Subtype /Image, /Width, /Height, /ColorSpace, /BitsPerComponent, etc.

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

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, 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, own_fields, #pdf_type, register_type, type_map, #validate

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

#alternatesObject



25
# File 'lib/pdfrb/model/type/xobject_image.rb', line 25

def alternates; self[:Alternates]; end

#associated_filesObject



29
# File 'lib/pdfrb/model/type/xobject_image.rb', line 29

def associated_files; self[:AF]; end

#bits_per_componentObject



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

def bits_per_component; self[:BitsPerComponent]; end

#bytes_per_rowObject



61
62
63
64
65
# File 'lib/pdfrb/model/type/xobject_image.rb', line 61

def bytes_per_row
  return nil unless width && bits_per_component && components

  ((width * components * bits_per_component) + 7) / 8
end

#color_spaceObject



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

def color_space; self[:ColorSpace]; end

#componentsObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pdfrb/model/type/xobject_image.rb', line 31

def components
  cs = color_space
  return 0 unless cs

  case cs.to_sym
  when :DeviceGray, :CalGray, :Indexed then 1
  when :DeviceRGB, :CalRGB, :Lab then 3
  when :DeviceCMYK then 4
  end
rescue StandardError
  nil
end

#decodeObject



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

def decode; self[:Decode]; end

#decode_parmsObject



23
# File 'lib/pdfrb/model/type/xobject_image.rb', line 23

def decode_parms; self[:DecodeParms]; end

#filterObject



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

def filter; self[:Filter]; end

#has_soft_mask?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/pdfrb/model/type/xobject_image.rb', line 48

def has_soft_mask?
  !!smask || smask_in_data.to_i.positive?
end

#heightObject



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

def height; self[:Height]; end

#image_mask?Boolean

Returns:

  • (Boolean)


19
# File 'lib/pdfrb/model/type/xobject_image.rb', line 19

def image_mask?; truthy?(self[:ImageMask]); end

#indexed?Boolean

Returns:

  • (Boolean)


56
57
58
59
# File 'lib/pdfrb/model/type/xobject_image.rb', line 56

def indexed?
  color_space.is_a?(Array) &&
    color_space.to_ary.first&.to_sym == :Indexed
end

#inline_soft_mask?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/pdfrb/model/type/xobject_image.rb', line 52

def inline_soft_mask?
  smask_in_data.to_i == 2
end

#intentObject



18
# File 'lib/pdfrb/model/type/xobject_image.rb', line 18

def intent; self[:Intent]; end

#interpolate?Boolean

Returns:

  • (Boolean)


24
# File 'lib/pdfrb/model/type/xobject_image.rb', line 24

def interpolate?; truthy?(self[:Interpolate]); end

#maskObject



20
# File 'lib/pdfrb/model/type/xobject_image.rb', line 20

def mask; self[:Mask]; end

#masked?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/pdfrb/model/type/xobject_image.rb', line 44

def masked?
  image_mask? || !!mask
end

#nameObject



27
# File 'lib/pdfrb/model/type/xobject_image.rb', line 27

def name; self[:Name]; end

#ocObject



26
# File 'lib/pdfrb/model/type/xobject_image.rb', line 26

def oc; self[:OC]; end

#smaskObject



21
# File 'lib/pdfrb/model/type/xobject_image.rb', line 21

def smask; self[:SMask]; end

#smask_in_dataObject



22
# File 'lib/pdfrb/model/type/xobject_image.rb', line 22

def smask_in_data; self[:SMaskInData]; end

#struct_parentObject



28
# File 'lib/pdfrb/model/type/xobject_image.rb', line 28

def struct_parent; self[:StructParent]; end

#subtypeObject



11
# File 'lib/pdfrb/model/type/xobject_image.rb', line 11

def subtype; self[:Subtype]; end

#widthObject



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

def width; self[:Width]; end