Class: ZIMG::JPEG::DQT
Overview
can store multiple tables
Instance Attribute Summary collapse
-
#tables ⇒ Object
Returns the value of attribute tables.
Attributes inherited from Chunk
Instance Method Summary collapse
-
#initialize(marker, io) ⇒ DQT
constructor
A new instance of DQT.
- #inspect(verbose = 0) ⇒ Object
Methods inherited from Chunk
Methods inherited from Chunk
Constructor Details
#initialize(marker, io) ⇒ DQT
Returns a new instance of DQT.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/zimg/jpeg/chunks.rb', line 201 def initialize(marker, io) super @tables = {} sio = StringIO.new(@data) until sio.eof? id = sio.read(1).unpack1("C") values = case (id >> 4) when 0 # 8 bit values sio.read(64).unpack("C*") when 1 # 16 bit values sio.read(128).unpack("n*") else raise "DQT: invalid table spec #{id}" end id &= 0x0f table = [0] * 64 values.each_with_index { |value, idx| table[DCT_ZIGZAG[idx]] = value } @tables[id] = table end end |
Instance Attribute Details
#tables ⇒ Object
Returns the value of attribute tables.
199 200 201 |
# File 'lib/zimg/jpeg/chunks.rb', line 199 def tables @tables end |
Instance Method Details
#inspect(verbose = 0) ⇒ Object
227 228 229 230 231 |
# File 'lib/zimg/jpeg/chunks.rb', line 227 def inspect(verbose = 0) r = super.chop + format("ids=%s >", tables.keys.inspect) r = r.chop + format("tables=%s >", tables.values.inspect) if verbose > 0 r end |