Ejemplo n.º 1
0
double oyGetTemperature                ( double              default_ )
{
  double cie_a = 0.0, cie_b = 0.0, XYZ[3], Lab[3];
  oyGetDisplayWhitePoint( 1 /* automatic */, XYZ );
  oyXYZ2Lab(XYZ,Lab); cie_a = Lab[1]/256.0+0.5; cie_b = Lab[2]/256.0+0.5;
  double dist = 1.0;
  double temperature = oyEstimateTemperature( cie_a, cie_b, &dist );
  if( (temperature && dist < 0.0001) ||
      default_ < 0 )
    return temperature;
  else
    return default_;
}
/** Function: oyNamedColor_GetColorStd
 *  @memberof oyNamedColor_s
 *  @brief   convert a named color to a standard color space
 *
 *  @since Oyranos: version 0.1.8
 *  @date  23 december 2007 (API 0.1.8)
 */
int      oyNamedColor_GetColorStd    ( oyNamedColor_s    * color,
                                       oyPROFILE_e         color_space,
                                       oyPointer           buf,
                                       oyDATATYPE_e        buf_type,
                                       uint32_t            flags,
                                       oyOptions_s       * options )
{                        
  int ret = 0;
  oyProfile_s * profile;
  oyNamedColor_s_ * s = (oyNamedColor_s_*) color;

  if(!color)
    return 1;

  /* abreviate */
  if(buf_type == oyDOUBLE &&
     s->XYZ_[0] != -1 && s->XYZ_[1] != -1 && s->XYZ_[2] != -1)
  {
    if(color_space == oyEDITING_LAB)
    {
      oyXYZ2Lab( s->XYZ_, (double*)buf );
      return 0;
    }

    if(color_space == oyEDITING_XYZ)
    {
      oyCopyColor( s->XYZ_, (double*)buf, 1, 0, 0 );
      return 0;
    }
  }

  profile = oyProfile_FromStd ( color_space, flags, NULL );
  if(!profile)
    return 1;

  ret = oyNamedColor_GetColor ( color, profile, buf, buf_type, 0, options );
  oyProfile_Release ( &profile );

  return ret;
}