Class: PureJPEG::JFIFReader

Inherits:
Object
  • Object
show all
Defined in:
lib/pure_jpeg/jfif_reader.rb

Defined Under Namespace

Classes: Component, Scan, ScanComponent

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, stop_after_frame: false) ⇒ JFIFReader

Returns a new instance of JFIFReader.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/pure_jpeg/jfif_reader.rb', line 12

def initialize(data, stop_after_frame: false)
  @data = data.b
  @stop_after_frame = stop_after_frame
  @pos = 0
  @quant_tables = {}
  @huffman_tables = {}
  @components = []
  @restart_interval = 0
  @progressive = false
  @scans = []
  @icc_chunks = {}
  parse
  assemble_icc_profile
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def components
  @components
end

#heightObject (readonly)

Returns the value of attribute height.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def height
  @height
end

#huffman_tablesObject (readonly)

Returns the value of attribute huffman_tables.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def huffman_tables
  @huffman_tables
end

#icc_profileObject (readonly)

Returns the value of attribute icc_profile.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def icc_profile
  @icc_profile
end

#progressiveObject (readonly)

Returns the value of attribute progressive.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def progressive
  @progressive
end

#quant_tablesObject (readonly)

Returns the value of attribute quant_tables.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def quant_tables
  @quant_tables
end

#restart_intervalObject (readonly)

Returns the value of attribute restart_interval.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def restart_interval
  @restart_interval
end

#scansObject (readonly)

Returns the value of attribute scans.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def scans
  @scans
end

#widthObject (readonly)

Returns the value of attribute width.



5
6
7
# File 'lib/pure_jpeg/jfif_reader.rb', line 5

def width
  @width
end

Instance Method Details

#scan_componentsObject



27
28
29
# File 'lib/pure_jpeg/jfif_reader.rb', line 27

def scan_components
  @scans.first&.components || []
end

#scan_dataObject



31
32
33
# File 'lib/pure_jpeg/jfif_reader.rb', line 31

def scan_data
  @scans.first&.data || "".b
end