Class: JXL::Headers::BitDepth

Inherits:
Data
  • Object
show all
Defined in:
lib/jxl/headers/bit_depth.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#bits_per_sampleObject (readonly)

Returns the value of attribute bits_per_sample

Returns:

  • (Object)

    the current value of bits_per_sample



5
6
7
# File 'lib/jxl/headers/bit_depth.rb', line 5

def bits_per_sample
  @bits_per_sample
end

#exponent_bitsObject (readonly)

Returns the value of attribute exponent_bits

Returns:

  • (Object)

    the current value of exponent_bits



5
6
7
# File 'lib/jxl/headers/bit_depth.rb', line 5

def exponent_bits
  @exponent_bits
end

#floating_pointObject (readonly)

Returns the value of attribute floating_point

Returns:

  • (Object)

    the current value of floating_point



5
6
7
# File 'lib/jxl/headers/bit_depth.rb', line 5

def floating_point
  @floating_point
end

Class Method Details

.read(reader) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jxl/headers/bit_depth.rb', line 6

def self.read(reader)
  floating_point = Bit::Field.read_bool(reader)
  bits_per_sample = if floating_point
                      Bit::Field.u32(reader, Bit::Field.val(32), Bit::Field.val(16),
                                     Bit::Field.val(24), Bit::Field.bits_offset(6, 1))
                    else
                      Bit::Field.u32(reader, Bit::Field.val(8), Bit::Field.val(10),
                                     Bit::Field.val(12), Bit::Field.bits_offset(6, 1))
                    end
  exponent_bits = floating_point ? reader.read(4) + 1 : 0
  validate!(floating_point, bits_per_sample, exponent_bits)
  new(floating_point:, bits_per_sample:, exponent_bits:)
end