Class: JXL::Headers::ColourEncoding

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

Constant Summary collapse

DEFAULT =
{ want_icc: false, colour_space: 0, white_point: 1, primaries: 1,
transfer_function: 13, gamma: nil, rendering_intent: 1,
white_point_xy: nil, primaries_xy: nil }.freeze
CUSTOM_XY =
[Bit::Field.bits(19), Bit::Field.bits_offset(19, 524_288),
Bit::Field.bits_offset(20, 1_048_576), Bit::Field.bits_offset(21, 2_097_152)].freeze
ENUM =
[Bit::Field.val(0), Bit::Field.val(1), Bit::Field.bits_offset(4, 2),
Bit::Field.bits_offset(6, 18)].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#colour_spaceObject (readonly)

Returns the value of attribute colour_space

Returns:

  • (Object)

    the current value of colour_space



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

def colour_space
  @colour_space
end

#gammaObject (readonly)

Returns the value of attribute gamma

Returns:

  • (Object)

    the current value of gamma



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

def gamma
  @gamma
end

#primariesObject (readonly)

Returns the value of attribute primaries

Returns:

  • (Object)

    the current value of primaries



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

def primaries
  @primaries
end

#primaries_xyObject (readonly)

Returns the value of attribute primaries_xy

Returns:

  • (Object)

    the current value of primaries_xy



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

def primaries_xy
  @primaries_xy
end

#rendering_intentObject (readonly)

Returns the value of attribute rendering_intent

Returns:

  • (Object)

    the current value of rendering_intent



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

def rendering_intent
  @rendering_intent
end

#transfer_functionObject (readonly)

Returns the value of attribute transfer_function

Returns:

  • (Object)

    the current value of transfer_function



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

def transfer_function
  @transfer_function
end

#want_iccObject (readonly)

Returns the value of attribute want_icc

Returns:

  • (Object)

    the current value of want_icc



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

def want_icc
  @want_icc
end

#white_pointObject (readonly)

Returns the value of attribute white_point

Returns:

  • (Object)

    the current value of white_point



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

def white_point
  @white_point
end

#white_point_xyObject (readonly)

Returns the value of attribute white_point_xy

Returns:

  • (Object)

    the current value of white_point_xy



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

def white_point_xy
  @white_point_xy
end

Class Method Details

.read(reader) ⇒ Object

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jxl/headers/colour_encoding.rb', line 18

def self.read(reader)
  return new(**DEFAULT) if Bit::Field.read_bool(reader)

  want_icc = Bit::Field.read_bool(reader)
  colour_space = read_enum(reader, [0, 1, 2, 3], "colour space")
  raise CorruptError, "unknown colour space without ICC" if !want_icc && colour_space == 3

  values = DEFAULT.merge(want_icc:, colour_space:)
  unless want_icc
    values[:white_point], values[:white_point_xy] = read_white_point(reader, colour_space)
    values[:primaries], values[:primaries_xy] = read_primaries(reader, colour_space)
    values[:transfer_function], values[:gamma] = read_transfer_function(reader, colour_space)
    values[:rendering_intent] = read_enum(reader, [0, 1, 2, 3], "rendering intent")
  end
  new(**values)
end