XYZ to RGB
Given an XYZ color whose components are in the nominal range [0.0, 1.0] and whose reference white is the same as
that of the RGB system, the conversion to RGB is as follows:
If the RGB system is not sRGB:

and if it is sRGB:

where, in either of the above cases:

Implementation Notes:
- The transformation matrix [M] is calculated from the RGB reference primaries as discussed here.
- γ is the gamma value of the RGB color system used. Many common ones may be found here.
- The output RGB values are in the nominal range [0.0, 1.0]. You may wish to scale them to some other range. For example,
if you want RGB in the range [0, 255], you must multiply each component by 255.0.
- If the input XYZ color is not relative to the same reference white as the RGB system, you must first apply a
chromatic adaptation transform to the XYZ color to convert
it from its own reference white to the reference white of the RGB system.
- Sometimes the more complicated special case of sRGB shown above is replaced by a "simplified" version using a straight gamma function with γ = 2.2.