Class: Abachrome::Converters::XyzToSrgb

Inherits:
Base
  • Object
show all
Defined in:
lib/abachrome/converters/xyz_to_srgb.rb

Instance Attribute Summary

Attributes inherited from Base

#from_space, #to_space

Class Method Summary collapse

Methods inherited from Base

#can_convert?, #convert, find_converter, #initialize, raise_unless, register

Constructor Details

This class inherits a constructor from Abachrome::Converters::Base

Class Method Details

.convert(xyz_color) ⇒ Abachrome::Color

Converts a color from XYZ color space to sRGB color space.

This method first converts XYZ to linear RGB using the inverse transformation matrix, then applies gamma correction to convert to sRGB. The XYZ color space is the CIE 1931 color space that forms the basis for most other color space definitions and serves as a device-independent reference.

the same alpha as the input color

Parameters:

Returns:

Raises:

  • (ArgumentError)

    If the input color is not in XYZ color space



17
18
19
20
21
22
23
24
25
# File 'lib/abachrome/converters/xyz_to_srgb.rb', line 17

def self.convert(xyz_color)
  raise_unless xyz_color, :xyz

  # Convert XYZ to linear RGB first
  lrgb_color = Converters::XyzToLrgb.convert(xyz_color)

  # Then convert linear RGB to sRGB
  Converters::LrgbToSrgb.convert(lrgb_color)
end