Blame IlmImf/ImfChromaticities.h

Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
//
Packit 0d464f
// Copyright (c) 2003, Industrial Light & Magic, a division of Lucas
Packit 0d464f
// Digital Ltd. LLC
Packit 0d464f
// 
Packit 0d464f
// All rights reserved.
Packit 0d464f
// 
Packit 0d464f
// Redistribution and use in source and binary forms, with or without
Packit 0d464f
// modification, are permitted provided that the following conditions are
Packit 0d464f
// met:
Packit 0d464f
// *       Redistributions of source code must retain the above copyright
Packit 0d464f
// notice, this list of conditions and the following disclaimer.
Packit 0d464f
// *       Redistributions in binary form must reproduce the above
Packit 0d464f
// copyright notice, this list of conditions and the following disclaimer
Packit 0d464f
// in the documentation and/or other materials provided with the
Packit 0d464f
// distribution.
Packit 0d464f
// *       Neither the name of Industrial Light & Magic nor the names of
Packit 0d464f
// its contributors may be used to endorse or promote products derived
Packit 0d464f
// from this software without specific prior written permission. 
Packit 0d464f
// 
Packit 0d464f
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 0d464f
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 0d464f
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 0d464f
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 0d464f
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 0d464f
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 0d464f
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 0d464f
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 0d464f
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 0d464f
//
Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
Packit 0d464f
Packit 0d464f
#ifndef INCLUDED_IMF_CHROMATICITIES_H
Packit 0d464f
#define INCLUDED_IMF_CHROMATICITIES_H
Packit 0d464f
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
//
Packit 0d464f
//	CIE (x,y) chromaticities, and conversions between
Packit 0d464f
//	RGB tiples and CIE XYZ tristimulus values.
Packit 0d464f
//
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
#include "ImathVec.h"
Packit 0d464f
#include "ImathMatrix.h"
Packit 0d464f
#include "ImfNamespace.h"
Packit 0d464f
#include "ImfExport.h"
Packit 0d464f
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit 0d464f
Packit 0d464f
   
Packit 0d464f
struct IMF_EXPORT Chromaticities
Packit 0d464f
{
Packit 0d464f
    //-----------------------------------------------
Packit 0d464f
    // The CIE x and y coordinates of the RGB triples
Packit 0d464f
    // (1,0,0), (0,1,0), (0,0,1) and (1,1,1).
Packit 0d464f
    //-----------------------------------------------
Packit 0d464f
Packit 0d464f
    IMATH_NAMESPACE::V2f	red;
Packit 0d464f
    IMATH_NAMESPACE::V2f	green;
Packit 0d464f
    IMATH_NAMESPACE::V2f	blue;
Packit 0d464f
    IMATH_NAMESPACE::V2f	white;
Packit 0d464f
Packit 0d464f
    //--------------------------------------------
Packit 0d464f
    // Default constructor produces chromaticities
Packit 0d464f
    // according to Rec. ITU-R BT.709-3
Packit 0d464f
    //--------------------------------------------
Packit 0d464f
Packit 0d464f
    Chromaticities (const IMATH_NAMESPACE::V2f &red   = IMATH_NAMESPACE::V2f (0.6400f, 0.3300f),
Packit 0d464f
		    const IMATH_NAMESPACE::V2f &green = IMATH_NAMESPACE::V2f (0.3000f, 0.6000f),
Packit 0d464f
		    const IMATH_NAMESPACE::V2f &blue  = IMATH_NAMESPACE::V2f (0.1500f, 0.0600f),
Packit 0d464f
		    const IMATH_NAMESPACE::V2f &white = IMATH_NAMESPACE::V2f (0.3127f, 0.3290f));
Packit 0d464f
    
Packit 0d464f
    
Packit 0d464f
    //---------
Packit 0d464f
    // Equality
Packit 0d464f
    //---------
Packit 0d464f
    
Packit 0d464f
    bool		operator == (const Chromaticities &v) const;    
Packit 0d464f
    bool		operator != (const Chromaticities &v) const;
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
Packit 0d464f
//
Packit 0d464f
// Conversions between RGB and CIE XYZ
Packit 0d464f
//
Packit 0d464f
// RGB to XYZ:
Packit 0d464f
//
Packit 0d464f
// 	Given a set of chromaticities, c, and the luminance, Y, of the RGB
Packit 0d464f
// 	triple (1,1,1), or "white", RGBtoXYZ(c,Y) computes a matrix, M, so
Packit 0d464f
// 	that multiplying an RGB value, v, with M produces an equivalent
Packit 0d464f
// 	XYZ value, w.  (w == v * M)
Packit 0d464f
// 
Packit 0d464f
// 	If we define that
Packit 0d464f
// 
Packit 0d464f
// 	   (Xr, Yr, Zr) == (1, 0, 0) * M
Packit 0d464f
// 	   (Xg, Yg, Zg) == (0, 1, 0) * M
Packit 0d464f
// 	   (Xb, Yb, Zb) == (0, 0, 1) * M
Packit 0d464f
// 	   (Xw, Yw, Zw) == (1, 1, 1) * M,
Packit 0d464f
// 
Packit 0d464f
// 	then the following statements are true:
Packit 0d464f
// 
Packit 0d464f
// 	   Xr / (Xr + Yr + Zr) == c.red.x
Packit 0d464f
// 	   Yr / (Xr + Yr + Zr) == c.red.y
Packit 0d464f
// 
Packit 0d464f
// 	   Xg / (Xg + Yg + Zg) == c.red.x
Packit 0d464f
// 	   Yg / (Xg + Yg + Zg) == c.red.y
Packit 0d464f
// 
Packit 0d464f
// 	   Xb / (Xb + Yb + Zb) == c.red.x
Packit 0d464f
// 	   Yb / (Xb + Yb + Zb) == c.red.y
Packit 0d464f
// 
Packit 0d464f
// 	   Xw / (Xw + Yw + Zw) == c.red.x
Packit 0d464f
// 	   Yw / (Xw + Yw + Zw) == c.red.y
Packit 0d464f
// 
Packit 0d464f
// 	   Yw == Y.
Packit 0d464f
// 
Packit 0d464f
// XYZ to RGB:
Packit 0d464f
// 
Packit 0d464f
// 	YYZtoRGB(c,Y) returns RGBtoXYZ(c,Y).inverse().
Packit 0d464f
// 
Packit 0d464f
Packit 0d464f
IMF_EXPORT IMATH_NAMESPACE::M44f    RGBtoXYZ (const Chromaticities chroma, float Y);
Packit 0d464f
IMF_EXPORT IMATH_NAMESPACE::M44f    XYZtoRGB (const Chromaticities chroma, float Y);
Packit 0d464f
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit 0d464f
Packit 0d464f
#endif