/** @brief manage complex oyNamedColor_s inside Oyranos * @memberof oyNamedColor_s * * @since Oyranos: version 0.1.8 * @date october 2007 (API 0.1.8) * * @param[in] chan pointer to channel data with a number of elements specified in sig or channels_n, optional * @param[in] blob CGATS or other reference data, optional * @param[in] blob_len length of the data blob * @param[in] ref possibly a ICC profile * @param object the optional object * */ oyNamedColor_s * oyNamedColor_Create ( const double * chan, const char * blob, int blob_len, oyProfile_s * ref, oyObject_s object ) { int n = 0; oyNamedColor_s_ * s = (oyNamedColor_s_*) oyNamedColor_New( object ); int error = !s; if(error <= 0) { s->profile_ = oyProfile_Copy( ref, 0 ); } n = oyProfile_GetChannelsCount( s->profile_ ); if(n) s->channels_ = s->oy_->allocateFunc_( n * sizeof(double) ); oyCopyColor( chan, &s->channels_[0], 1, ref, n ); oyCopyColor( 0, &s->XYZ_[0], 1, 0, 0 ); if(error <= 0 && blob && blob_len) { s->blob_ = s->oy_->allocateFunc_( blob_len ); if(!s->blob_) error = 1; if(error <= 0) error = !memcpy( s->blob_, blob, blob_len ); if(error <= 0) s->blob_len_ = blob_len; } return (oyNamedColor_s*) s; }
/** Function: oyNamedColor_GetSpaceRef * @memberof oyNamedColor_s * @brief get a color space reference * * @since Oyranos: version 0.1.8 * @date 23 december 2007 (API 0.1.8) */ oyProfile_s * oyNamedColor_GetSpaceRef ( oyNamedColor_s * color ) { oyNamedColor_s_ * s = (oyNamedColor_s_*) color; if(!color) return 0; oyProfile_Copy( s->profile_, 0 ); return s->profile_; }
/** Function oyProfile_FromStd * @memberof oyProfile_s * @brief Create from default colour space settings * * @param[in] type default colour space * @param[in] object the optional base * * @since Oyranos: version 0.1.8 * @date november 2007 (API 0.1.8) */ OYAPI oyProfile_s * OYEXPORT oyProfile_FromStd ( oyPROFILE_e type, oyObject_s object) { oyProfile_s_ * s = 0; char * name = 0; oyAlloc_f allocateFunc = 0; int pos = type - oyDEFAULT_PROFILE_START; if(!oy_profile_s_std_cache_) { int len = sizeof(oyProfile_s*) * (oyDEFAULT_PROFILE_END - oyDEFAULT_PROFILE_START); oy_profile_s_std_cache_ = oyAllocateFunc_( len ); memset( oy_profile_s_std_cache_, 0, len ); } if(oyDEFAULT_PROFILE_START < type && type < oyDEFAULT_PROFILE_END) if(oy_profile_s_std_cache_[pos]) return oyProfile_Copy( oy_profile_s_std_cache_[pos], 0 ); if(object) allocateFunc = object->allocateFunc_; if(type) name = oyGetDefaultProfileName ( type, allocateFunc ); s = oyProfile_FromFile_( name, 0, object ); if(s) s->use_default_ = type; if(oyDEFAULT_PROFILE_START < type && type < oyDEFAULT_PROFILE_END) oy_profile_s_std_cache_[pos] = oyProfile_Copy( (oyProfile_s*)s, 0 ); oyProfile_GetID( (oyProfile_s*)s ); return (oyProfile_s*)s; }
/** Function oyNamedColor_Copy__Members * @memberof oyNamedColor_s * @brief Custom NamedColor copy constructor * @internal * * This function makes a copy of all values from the input * to the output object. The destination object and all of its * members should already be allocated. * * @param[in] src the oyNamedColor_s_ input object * @param[out] dst the output oyNamedColor_s_ object * * @version Oyranos: x.x.x * @since YYYY/MM/DD (Oyranos: x.x.x) * @date YYYY/MM/DD */ int oyNamedColor_Copy__Members( oyNamedColor_s_ * dst, oyNamedColor_s_ * src) { int error = 0; oyNamedColor_s_ * s = dst; oyAlloc_f allocateFunc_ = 0; const double * chan; const char * blob; int blob_len; oyProfile_s * ref; int n = 0; if(!dst || !src) return 1; allocateFunc_ = dst->oy_->allocateFunc_; chan = src->channels_; blob = src->blob_; blob_len = src->blob_len_; ref = src->profile_; /* Copy each value of src to dst here */ if(error <= 0) { s->profile_ = oyProfile_Copy( ref, 0 ); } n = oyProfile_GetChannelsCount( s->profile_ ); if(n) s->channels_ = allocateFunc_( n * sizeof(double) ); oyCopyColor( chan, &s->channels_[0], 1, ref, n ); oyCopyColor( 0, &s->XYZ_[0], 1, 0, 0 ); if(error <= 0 && blob && blob_len) { s->blob_ = allocateFunc_( blob_len ); if(!s->blob_) error = 1; if(error <= 0) error = !memcpy( s->blob_, blob, blob_len ); if(error <= 0) s->blob_len_ = blob_len; } return error; }