Class: Abachrome::Converters::SrgbToXyz

Inherits:
Base
  • Object
show all
Defined in:
lib/abachrome/converters/srgb_to_xyz.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(srgb_color) ⇒ Abachrome::Color

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

This method first converts sRGB to linear RGB by removing gamma correction, then applies the linear RGB to XYZ transformation matrix. 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:

  • The color in sRGB color space

Returns:

  • The resulting color in XYZ color space with

Raises:

  • If the input color is not in sRGB color space



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

def self.convert(srgb_color)
  raise_unless srgb_color, :srgb

  # Convert sRGB to linear RGB first
  lrgb_color = Converters::SrgbToLrgb.convert(srgb_color)

  # Then convert linear RGB to XYZ
  Converters::LrgbToXyz.convert(lrgb_color)
end