コード例 #1
0
oyProfile_s * getEditingProfile      ( )
{
  static oyProfile_s * editing = NULL;

  if(!editing)
  {
    oyOption_s *matrix = oyOption_FromRegistration("///color_matrix."
              "from_primaries."
              "redx_redy_greenx_greeny_bluex_bluey_whitex_whitey_gamma", NULL );
    /* http://www.color.org/chardata/rgb/rommrgb.xalter
     * original gamma is 1.8, we adapt to typical LCD gamma of 2.2 */
    oyOption_SetFromDouble( matrix, 0.7347, 0, 0);
    oyOption_SetFromDouble( matrix, 0.2653, 1, 0);
    oyOption_SetFromDouble( matrix, 0.1596, 2, 0);
    oyOption_SetFromDouble( matrix, 0.8404, 3, 0);
    oyOption_SetFromDouble( matrix, 0.0366, 4, 0);
    oyOption_SetFromDouble( matrix, 0.0001, 5, 0);
    oyOption_SetFromDouble( matrix, 0.3457, 6, 0);
    oyOption_SetFromDouble( matrix, 0.3585, 7, 0);
    oyOption_SetFromDouble( matrix, 2.2, 8, 0);

    oyOptions_s * opts = oyOptions_New(0),
                * result = 0;

    oyOptions_MoveIn( opts, &matrix, -1 );
    oyOptions_Handle( "//" OY_TYPE_STD "/create_profile.icc",
                                opts,"create_profile.icc_profile.color_matrix",
                                &result );

    editing = (oyProfile_s*)oyOptions_GetType( result, -1, "icc_profile",
                                               oyOBJECT_PROFILE_S );
    oyOptions_Release( &result );

    oyProfile_AddTagText( editing, icSigProfileDescriptionTag,
                                            "ICC Examin ROMM gamma 2.2" );

    if(oy_debug)
    {
      size_t size = 0;
      char * data = (char*) oyProfile_GetMem( editing, &size, 0, malloc );
      oyWriteMemToFile_( "ICC Examin ROMM gamma 2.2.icc", data, size );
    }
  }

  return editing;
}
コード例 #2
0
/** Function  oyFilterNode_SetContext_
 *  @memberof oyFilterNode_s
 *  @brief    Set module context in a filter
 *  @internal
 *
 *  The api4 data is passed to a interpolator specific transformer. The result
 *  of this transformer will on request be cached by Oyranos as well.
 *
 *  @param[in]     node                filter
 *  @param[in,out] blob                context to fill; expensive
 *  @return                            error
 *
 *  @version Oyranos: 0.9.6
 *  @date    2014/06/26
 *  @since   2008/11/02 (Oyranos: 0.1.8)
 */
int          oyFilterNode_SetContext_( oyFilterNode_s_    * node,
                                       oyBlob_s_          * blob  )
{
  int error = 0;
  oyFilterCore_s_ * core_ = node->core;

  if(error <= 0)
  {
          size_t size = 0;
          oyHash_s * hash4 = 0,          /* public context provider */
                   * hash7 = 0;          /* data processor part */
          oyPointer ptr = 0;
          oyPointer_s * cmm_ptr4 = 0,
                      * cmm_ptr7 = 0;


          /*  Cache Search
           *  1.     hash from input
           *  2.     query for hash in cache
           *  3.     check
           *  3a.       eighter take cache entry
           *  3b.       or ask CMM
           *  3b.1.                update cache entry
           */


          if(oy_debug && getenv("OY_DEBUG_WRITE"))
          {
            size = 0;
            ptr = oyFilterNode_TextToInfo_( node, &size, oyAllocateFunc_ );
            if(ptr)
              oyWriteMemToFile_( "test_dbg_color.icc", ptr, size );
          }

          /* 1. + 2. query in cache for api7 */
          hash7 = oyFilterNode_GetHash_(node, 7);

          if(error <= 0)
          {
            /* select the module by option */
            oyOption_s * ct = oyOptions_Find( node->core->options_,
                                                       "////context",
                                                       oyNAME_PATTERN );
            const char * pattern = oyOption_GetValueString( ct, 0 );
            if(pattern &&
               !oyFilterRegistrationMatch( core_->registration_, pattern, 0 ))
            {
              oyMessageFunc_p( oyMSG_DBG, (oyStruct_s*) node,
                               OY_DBG_FORMAT_ "create core from pattern: %s",
                               OY_DBG_ARGS_,
                     oyFilterNode_GetText( (oyFilterNode_s*)node,oyNAME_NICK) );

              error = oyFilterNode_SetFromPattern_( node, 1, pattern );

              if(error)
              {
                if(oyOption_GetFlags( ct ) & oyOPTIONATTRIBUTE_EDIT)
                {
                  oyMessageFunc_p( oyMSG_WARN, (oyStruct_s*) node,
                               OY_DBG_FORMAT_ "edited pattern not available: %d %s",
                               OY_DBG_ARGS_, oyObject_GetId(ct->oy_),
                                   pattern );
                  error = 1;
                  goto clean;
                } else
                  error = 0;
              } else
                core_ = node->core;

              oyHash_Release( &hash7 );
              hash7 = oyFilterNode_GetHash_(node, 7);
            }
            oyOption_Release( &ct );

            ct = oyOptions_Find( node->core->options_,
                                                       "////renderer",
                                                       oyNAME_PATTERN );
            pattern = oyOption_GetValueString( ct, 0 );
            if(pattern &&
               !oyFilterRegistrationMatch( node->api7_->registration, pattern, 0 ))
            {
              oyMessageFunc_p( oyMSG_DBG, (oyStruct_s*) node,
                               OY_DBG_FORMAT_ "create node from pattern: %s",
                               OY_DBG_ARGS_,
                     oyFilterNode_GetText( (oyFilterNode_s*)node,oyNAME_NICK) );

              error = oyFilterNode_SetFromPattern_( node, 0, pattern );

              if(error)
              {
                if(oyOption_GetFlags( ct ) & oyOPTIONATTRIBUTE_EDIT)
                {
                  error = 1;
                  goto clean;
                } else
                  error = 0;
              } else
                core_ = node->core;

              oyHash_Release( &hash7 );
              hash7 = oyFilterNode_GetHash_(node, 7);
            }

            /* 3. check and 3.a take*/
            cmm_ptr7 = (oyPointer_s*) oyHash_GetPointer( hash7,
                                                         oyOBJECT_POINTER_S);

            if(!(cmm_ptr7 && oyPointer_GetPointer(cmm_ptr7)) || blob)
            {
              /* write the cmm4 context to memory */
              if(blob)
              {
                if(oy_debug)
                error = oyOptions_SetFromString( &node->tags, "////verbose",
                                               "true", OY_CREATE_NEW );

                /* oy_debug is used to obtain a complete data set */
                ptr = oyFilterNode_ContextToMem_( node, &size, oyAllocateFunc_);
                oyBlob_SetFromData( (oyBlob_s*)blob, ptr, size,
                                    core_->api4_->context_type );
                if(oy_debug)
                error = oyOptions_SetFromString( &node->tags, "////verbose",
                                               "false", 0 );

                goto clean;
              }

              /* 2. query in cache for api4 */
              hash4 = oyFilterNode_GetHash_(node, 4);
              cmm_ptr4 = (oyPointer_s*) oyHash_GetPointer( hash4,
                                                        oyOBJECT_POINTER_S);

              if(!cmm_ptr4)
              {
                cmm_ptr4 = oyPointer_New(0);
              }

              if(!oyPointer_GetPointer(cmm_ptr4))
              {
                size = 0;
                /* 3b. ask CMM */
                ptr = oyFilterNode_ContextToMem_( node, &size, oyAllocateFunc_);

                if(!ptr || !size)
                {
                  oyOption_s * ct = oyOptions_Find( core_->options_,
                                                    "////context",
                                                    oyNAME_PATTERN );
                  oyMessageFunc_p( oyMSG_DBG, (oyStruct_s*) node,
                    OY_DBG_FORMAT_ "device link creation failed", OY_DBG_ARGS_);
                  if(!(oyOption_GetFlags( ct ) & oyOPTIONATTRIBUTE_EDIT))
                  {
                    char * pattern = oyFilterNode_GetFallback_( node, 1 );

                    oyMessageFunc_p( oyMSG_WARN, (oyStruct_s*) node,
                               OY_DBG_FORMAT_ "create core from fallback: %s",
                               OY_DBG_ARGS_, pattern );

                    error = oyFilterNode_SetFromPattern_( node, 1, pattern );
                    if(error)
                    {
                      error = 1;
                      oyMessageFunc_p( oyMSG_ERROR, (oyStruct_s*) node,
                      OY_DBG_FORMAT_ "no device link for caching\n%s",
                      OY_DBG_ARGS_,
                      oyFilterNode_GetText( (oyFilterNode_s*)node,oyNAME_NICK));
                      goto clean;
                    } else
                      core_ = node->core;
                    
                    ptr = oyFilterNode_ContextToMem_( node,
                                                      &size, oyAllocateFunc_ );
                    oyFree_m_( pattern );
                  }

                  if(!ptr || !size)
                  {
                    oyMessageFunc_p( oyMSG_ERROR, (oyStruct_s*) node,
                      OY_DBG_FORMAT_ "no device link for caching\n%s",
                      OY_DBG_ARGS_,
                      oyFilterNode_GetText( (oyFilterNode_s*)node,oyNAME_NICK));

                    error = 1;
                    oyPointer_Release( &cmm_ptr4 );

                  } else if(oy_debug)
                    oyMessageFunc_p( oyMSG_WARN, (oyStruct_s*) node,
                        OY_DBG_FORMAT_ "use fallback CMM\n%s", OY_DBG_ARGS_,
                        oyFilterNode_GetText( (oyFilterNode_s*)node,
                                              oyNAME_NICK ));
                }

                if(!error)
                {
                  /* 3b.1. update the hash as the CMM can change options */
                  hash4 = oyFilterNode_GetHash_( node, 4 );
                  oyPointer_Release( &cmm_ptr4 );
                  cmm_ptr4 = (oyPointer_s*) oyHash_GetPointer( hash4,
                                                        oyOBJECT_POINTER_S);
                  hash7 = oyFilterNode_GetHash_( node, 7 );

                  if(!cmm_ptr4)
                    cmm_ptr4 = oyPointer_New(0);

                  error = oyPointer_Set( cmm_ptr4, core_->api4_->id_,
                                         core_->api4_->context_type,
                                    ptr, "oyPointerRelease", oyPointerRelease);
                  oyPointer_SetSize( cmm_ptr4, size );

                  /* 3b.2. update cmm4 cache entry */
                  error = oyHash_SetPointer( hash4, (oyStruct_s*) cmm_ptr4);
                }
              }


              if(error <= 0 && cmm_ptr4 && oyPointer_GetPointer(cmm_ptr4))
              {
                if(node->backend_data && node->backend_data->release)
                node->backend_data->release( (oyStruct_s**)&node->backend_data);

                if( oyStrcmp_( node->api7_->context_type,
                               core_->api4_->context_type ) != 0 )
                {
                  cmm_ptr7 = oyPointer_New(0);
                  error = oyPointer_Set( cmm_ptr7, node->api7_->id_,
                                         node->api7_->context_type, 0, 0, 0);

                  /* 3b.3. search for a convertor and convert */
                  oyPointer_ConvertData( cmm_ptr4, cmm_ptr7,
                                         (oyFilterNode_s*)node );
                  node->backend_data = cmm_ptr7;
                  /* 3b.4. update cmm7 cache entry */
                  error = oyHash_SetPointer( hash7,
                                              (oyStruct_s*) cmm_ptr7);

                } else
                  node->backend_data = oyPointer_Copy( cmm_ptr4, 0 );
              }

              if(oy_debug && getenv("OY_DEBUG_WRITE"))
              {
                int id = oyFilterNode_GetId( (oyFilterNode_s*)node );
                char * file_name = 0;
                oyAllocHelper_m_( file_name, char, 80, 0, return 1 );
                sprintf( file_name, "dbg_color_dl-node[%d].icc", id );
                if(ptr && size && node->backend_data)
                  oyWriteMemToFile_( file_name, ptr, size );
                oyFree_m_(file_name);
              }

            } else