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; }
/** Function Configs_FromPattern * @brief CMM_NICK oyCMMapi8_s scanner devices * * @param[in] registration a string to compare ?????? * @param[in] options read what to do from the options object * @param[out] s Return a configuration for each device found * * @version Oyranos: 0.1.10 * @since 2009/01/19 (Oyranos: 0.1.10) * @date 2009/02/09 */ int Configs_FromPattern(const char *registration, oyOptions_s * options, oyConfigs_s ** s) { oyConfig_s *device = NULL; oyConfigs_s *devices = NULL; oyOption_s *context_opt = NULL, *handle_opt = NULL, *version_opt = NULL, *name_opt = NULL; int i, num_devices, g_error = 0, status, call_sane_exit = 0; const char *device_name = 0, *command_list = 0, *command_properties = 0; const SANE_Device **device_list = NULL; int rank; oyAlloc_f allocateFunc = malloc; printf(PRFX "Entering %s(). Options:\n%s", __func__, oyOptions_GetText(options, oyNAME_NICK)); rank = oyFilterRegistrationMatch(_api8.registration, registration, oyOBJECT_CMM_API8_S); command_list = oyOptions_FindString(options, "command", "list"); command_properties = oyOptions_FindString(options, "command", "properties"); device_name = oyOptions_FindString(options, "device_name", 0); /* "error handling" section */ if (rank == 0) { SANE_msg(oyMSG_WARN, (oyStruct_s *) options, _DBG_FORMAT_ "\n " "Registration match Failed. Options:\n%s", _DBG_ARGS_, oyOptions_GetText(options, oyNAME_NICK)); return 1; } if (s == NULL) { SANE_msg(oyMSG_WARN, (oyStruct_s *) options, _DBG_FORMAT_ "\n " "oyConfigs_s is NULL! Options:\n%s", _DBG_ARGS_, oyOptions_GetText(options, oyNAME_NICK)); return 1; } if (*s != NULL) { SANE_msg(oyMSG_WARN, (oyStruct_s *) options, _DBG_FORMAT_ "\n " "Devices struct already present! Options:\n%s", _DBG_ARGS_, oyOptions_GetText(options, oyNAME_NICK)); return 1; } if (!device_name && command_properties) { SANE_msg(oyMSG_WARN, (oyStruct_s *) options, _DBG_FORMAT_ "\n " "Device_name is mandatory for properties command:\n%s", _DBG_ARGS_, oyOptions_GetText(options, oyNAME_NICK)); return 1; } /* "help" call section */ if (oyOptions_FindString(options, "command", "help") || !options || !oyOptions_Count(options)) { /** oyMSG_WARN should make shure our message is visible. */ ConfigsFromPatternUsage((oyStruct_s *) options); return 0; } context_opt = oyOptions_Find(options, "device_context", oyNAME_PATTERN); handle_opt = oyOptions_Find(options, "device_handle", oyNAME_PATTERN); name_opt = oyOptions_Find(options, "oyNAME_NAME", oyNAME_PATTERN); /*Handle "driver_version" option [IN] */ check_driver_version(options, &version_opt, &call_sane_exit); devices = oyConfigs_New(0); if (command_list) { /* "list" call section */ if (device_name && /*If a user provides a device_name option,*/ !context_opt && /*and does not need the device_context data,*/ !name_opt /*or the oyNAME_NAME description*/ ) num_devices = 1; /*then we can get away without calling GetDevices()*/ else if (GetDevices(&device_list, &num_devices) != 0) { num_devices = 0; /*So that for loop will not run*/ ++g_error; } for (i = 0; i < num_devices; ++i) { int error = 0; const char *sane_name = NULL, *sane_model = NULL; if (device_list) { sane_name = device_list[i]->name; sane_model = device_list[i]->model; } else { sane_name = device_name; } /*Handle "device_name" option [IN] */ if (device_name && /*device_name is provided*/ sane_name && /*and sane_name has been retrieved*/ strcmp(device_name, sane_name) != 0) /*and they don't match,*/ continue; /*then try the next*/ device = oyConfig_FromRegistration(CMM_BASE_REG, 0); /*Handle "driver_version" option [OUT] */ if (version_opt) { oyOption_s * tmp = oyOption_Copy(version_opt, 0); oyOptions_MoveIn(*oyConfig_GetOptions(device,"backend_core"), &tmp, -1); } /*Handle "device_name" option [OUT] */ oyOptions_SetFromString(oyConfig_GetOptions(device,"backend_core"), CMM_BASE_REG OY_SLASH "device_name", sane_name, OY_CREATE_NEW); /*Handle "oyNAME_NAME" option */ if (name_opt) oyOptions_SetFromString(oyConfig_GetOptions(device,"backend_core"), CMM_BASE_REG OY_SLASH "oyNAME_NAME", sane_model, OY_CREATE_NEW); /*Handle "device_context" option */ /* SANE Backend protocol states that device_context is *always* returned * This is a slight variation: Only when GetDevices() is called will it be returned, * unless we call sane_exit*/ if (device_list && !call_sane_exit) { oyBlob_s *context_blob = oyBlob_New(NULL); oyOption_s *context_opt = oyOption_FromRegistration( CMM_BASE_REG OY_SLASH "device_context", 0); oyBlob_SetFromData(context_blob, (oyPointer) device_list[i], sizeof(SANE_Device), "sane"); oyOption_MoveInStruct(context_opt, (oyStruct_s **) & context_blob); oyOptions_MoveIn(*oyConfig_GetOptions(device,"data"), &context_opt, -1); } /*Handle "device_handle" option */ if (handle_opt && !call_sane_exit) { oyPointer_s *handle_ptr = NULL; SANE_Handle h; status = sane_open(sane_name, &h); if (status == SANE_STATUS_GOOD) { handle_ptr = oyPointer_New(0); oyPointer_Set(handle_ptr, "SANE", "handle", (oyPointer)h, "sane_release_handle", sane_release_handle); oyOptions_MoveInStruct(oyConfig_GetOptions(device,"data"), CMM_BASE_REG OY_SLASH "device_handle", (oyStruct_s **) &handle_ptr, OY_CREATE_NEW); } else printf(PRFX "Unable to open sane device \"%s\": %s\n", sane_name, sane_strstatus(status)); } oyConfig_SetRankMap( device, _api8.rank_map ); error = oyConfigs_MoveIn(devices, &device, -1); /*Cleanup*/ if (error) { oyConfig_Release(&device); ++g_error; } } *s = devices; } else if (command_properties) { /* "properties" call section */ const SANE_Device *device_context = NULL; SANE_Device *aux_context = NULL; SANE_Handle device_handle = NULL; /*Return a full list of scanner H/W & * SANE driver S/W color options * with the according rank map */ device = oyConfig_FromRegistration(CMM_BASE_REG, 0); /*Handle "driver_version" option [OUT] */ if (version_opt) { oyOption_s *tmp = oyOption_Copy(version_opt, 0); oyOptions_MoveIn(*oyConfig_GetOptions(device,"backend_core"), &tmp, -1); } /*1a. Get the "device_context"*/ if (!context_opt) { /*we'll have to get it ourselves*/ if (GetDevices(&device_list, &num_devices) == 0) { device_context = *device_list; while (device_context) { if(device_name && device_context->name && strcmp(device_name,device_context->name) == 0) break; device_context++; } if (!device_context) { printf(PRFX "device_name does not match any installed device.\n"); g_error++; } } else { g_error++; } } else { aux_context = (SANE_Device*)oyOption_GetData(context_opt, NULL, allocateFunc); device_context = aux_context; } /*1b. Use the "device_context"*/ if (device_context) DeviceInfoFromContext_(device_context, oyConfig_GetOptions(device,"backend_core")); /*2a. Get the "device_handle"*/ if (!handle_opt) { status = sane_open( device_name, &device_handle ); if (status != SANE_STATUS_GOOD) { printf(PRFX "Unable to open sane device \"%s\": %s\n", device_name, sane_strstatus(status)); g_error++; } } else { oyPointer_s * oy_struct = (oyPointer_s*) oyOption_GetStruct( handle_opt, oyOBJECT_POINTER_S ); device_handle = (SANE_Handle)oyPointer_GetPointer(oy_struct); oyPointer_Release( &oy_struct ); } if (device_handle) { /*2b. Use the "device_handle"*/ ColorInfoFromHandle(device_handle, oyConfig_GetOptions(device,"backend_core")); /*3. Set the rank map*/ oyConfig_SetRankMap( device, _api8.rank_map ); } oyConfigs_MoveIn(devices, &device, -1); /*Cleanup*/ free(aux_context); *s = devices; } else { /*unsupported, wrong or no command */ SANE_msg(oyMSG_WARN, (oyStruct_s *) options, _DBG_FORMAT_ "\n " "No supported commands in options:\n%s", _DBG_ARGS_, oyOptions_GetText(options, oyNAME_NICK) ); ConfigsFromPatternUsage((oyStruct_s *) options); g_error = 1; } /*Global Cleanup*/ if (call_sane_exit) { printf(PRFX "sane_exit()\n"); sane_exit(); } oyOption_Release(&context_opt); oyOption_Release(&handle_opt); oyOption_Release(&version_opt); oyOption_Release(&name_opt ); printf(PRFX "Leaving %s\n", __func__); return g_error; }
int DeviceAttributes_ ( ppd_file_t * ppd, oyOptions_s * options, oyConfig_s * device, const char * ppd_file_location ) { oyOption_s * o = 0; int error = !device; oyOption_s * value3 = oyOptions_Find( options, "device_context", oyNAME_PATTERN ); const char * device_name = oyConfig_FindString( device, "device_name", 0 ); if(!error) { char * manufacturer= 0, * model=0, * serial=0, * device_settings = 0; const char * system_port = 0, * host = 0; const char * keyword = 0; ppd_attr_t * attrs = 0; int attr_n, i, j; char ** color_key_words = 0, * tmp = 0; int color_key_words_n = 0; if(!device_name && !value3 && !ppd_file_location && !ppd) { message(oyMSG_WARN, (oyStruct_s*)options, _DBG_FORMAT_ "The \"device_name\" and \"device_context\" is\n" " missed to select a appropriate device.", _DBG_ARGS_ ); error = 1; return error; } if(!ppd) { message( oyMSG_DBG, (oyStruct_s*)0, _DBG_FORMAT_ "\n" "No PPD obtained for ", _DBG_ARGS_, device_name ); error = -1; return error; } manufacturer = ppd->manufacturer; model = ppd->modelname; serial = 0; /* Not known at this time. */ system_port = device_name; host = cupsServer(); attrs = ppdFindAttr(ppd, "cupsICCProfile", 0); if(attrs && attrs->text) device_settings = attrs->text; if(error <= 0) { size_t size = 0; char * data = 0; oyConfig_s * d = device; oyRankMap * rank_map = oyRankMapCopy( oyConfig_GetRankMap( device ), oyAllocateFunc_ ); if(!rank_map) rank_map = oyRankMapCopy( _api8.rank_map, oyAllocateFunc_ ); OPTIONS_ADD( oyConfig_GetOptions(d,"backend_core"), manufacturer ) OPTIONS_ADD( oyConfig_GetOptions(d,"backend_core"), model ) OPTIONS_ADD( oyConfig_GetOptions(d,"backend_core"), serial ) OPTIONS_ADD( oyConfig_GetOptions(d,"backend_core"), system_port ) OPTIONS_ADD( oyConfig_GetOptions(d,"backend_core"), host ) OPTIONS_ADD( oyConfig_GetOptions(d,"backend_core"), device_settings ) if (value3) { /* open the PPD data */ if(ppd_file_location) { FILE * fp = fopen( ppd_file_location, "r" ); size_t lsize = 0; /* Find the total size. */ fseek(fp , 0, SEEK_END); lsize = ftell(fp); rewind (fp); /* Create buffer to read contents into a profile. */ data = (char*) malloc (sizeof(char)*lsize + 1); if (data == NULL) fputs ("Unable to open PPD size.",stderr); size = fread( data, 1, lsize, fp); data[size] = 0; } if(!error && data && size) { o = oyOption_FromRegistration( CMM_BASE_REG OY_SLASH "device_context.PPD.text", 0 ); error = !o; if(!error) error = oyOption_SetFromData( o, data, size ); if(!error) oyOptions_MoveIn( *oyConfig_GetOptions(device,"data"), &o, -1 ); } } /* Collect all ColorKeyWords. */ attr_n = ppd->num_attrs; for(i = 0; i < attr_n; i++) { char key[16]; keyword = ppd->attrs[i]->name; /* we support keys beginning with ColorKeyWords, e.g. "ColorKeyWords" "ColorKeyWords" ... */ snprintf( &key[0], 16, "%s", keyword ); key[14] = 0; if (strcmp(key, "ColorKeyWords") == 0) { if( tmp && tmp[oyStrlen_(tmp) - 1] != ';' ) STRING_ADD( tmp, ";" ); STRING_ADD( tmp, ppd->attrs[i]->value ); } } if(tmp) { color_key_words = oyStringSplit( tmp, ';', &color_key_words_n, oyAllocateFunc_); oyDeAllocateFunc_( tmp ); tmp = 0; } /* add the key/value pairs to the devices backend_core options. */ for(j = 0; j < color_key_words_n; ++j) { const char * keyword = color_key_words[j], * value = NULL; ppd_choice_t * c = ppdFindMarkedChoice( ppd, keyword ); ppd_option_t * o = ppdFindOption( ppd, keyword ); char * reg_name = 0; /* take the marked choice */ if(c) value = c->choice; /* fall back to a default */ else if(o) value = o->defchoice; else /* Scan PPD attributes for matching the ColorKeyWords and */ for(i = 0; i < attr_n; i++) if(oyStrcmp_( ppd->attrs[i]->name, keyword ) == 0) value = ppd->attrs[i]->value; STRING_ADD( reg_name, CMM_BASE_REG OY_SLASH ); STRING_ADD( reg_name, keyword ); if(value) { error= oyOptions_SetFromText( oyConfig_GetOptions(d,"backend_core"), reg_name, value, OY_CREATE_NEW ); oyRankMapAppend( &rank_map, reg_name, 2, -2, 0, 0,0 ); } if(reg_name) oyDeAllocateFunc_( reg_name ); reg_name = 0; } if( color_key_words && color_key_words_n) oyStringListRelease_( &color_key_words, color_key_words_n, oyDeAllocateFunc_ ); else { ppd_option_t * o; while((o = ppdNextOption(ppd)) != 0) { const char * value = 0; char * reg_name = 0; keyword = o->keyword; STRING_ADD( reg_name, CMM_BASE_REG OY_SLASH ); STRING_ADD( reg_name, keyword ); /* take the marked choice */ for(i = 0; i < o->num_choices; ++i) if(o->choices[i].marked) { value = o->choices[i].choice; break; } if(!value) value = o->defchoice; if(value) { error = oyOptions_SetFromText( oyConfig_GetOptions(d,"backend_core"), reg_name, value, OY_CREATE_NEW ); oyRankMapAppend( &rank_map, reg_name, 2, -2, 0, 0,0 ); } if(reg_name) oyDeAllocateFunc_( reg_name ); reg_name = 0; } } oyConfig_SetRankMap( device, rank_map ); oyRankMapRelease( &rank_map, oyDeAllocateFunc_ ); }
oyConversion_s * oyConversion_FromImageForDisplay_ ( oyImage_s * image_in, oyImage_s * image_out, oyFilterNode_s ** cc_node, uint32_t flags, oyDATATYPE_e data_type, oyOptions_s * cc_options, oyObject_s obj ) { oyFilterNode_s * in = 0, * out = 0, * icc = 0; int error = 0; oyConversion_s * conversion = 0; oyOptions_s * options = 0; oyOption_s * option = 0; const char * sv = 0; double scale = 0; if(!image_in || !image_out) return NULL; /* start with an empty conversion object */ conversion = oyConversion_New( obj ); /* create a filter node */ in = oyFilterNode_NewWith( "//" OY_TYPE_STD "/root", 0, obj ); /* set the above filter node as the input */ oyConversion_Set( conversion, in, 0 ); /* set the image buffer */ oyFilterNode_SetData( in, (oyStruct_s*)image_in, 0, 0 ); /* add a scale node */ out = oyFilterNode_NewWith( "//" OY_TYPE_STD "/scale", 0, obj ); options = oyFilterNode_GetOptions( out, OY_SELECT_FILTER ); /* scale factor from DB */ option = oyOption_FromRegistration( OY_INTERNAL "/scale/scale", 0 ); error = oyOption_SetFromText( option, 0, 0 ); error = oyOption_SetValueFromDB( option ); scale = 1.0; if(!error) { sv = oyOption_GetValueString( option, 0 ); if(sv) scale = strtod( sv, 0 ); } oyOption_Release( &option ); error = oyOptions_SetFromDouble( &options, OY_INTERNAL "/scale/scale", scale, 0, OY_CREATE_NEW ); oyOptions_Release( &options ); /* append the node */ error = oyFilterNode_Connect( in, "//" OY_TYPE_STD "/data", out, "//" OY_TYPE_STD "/data", 0 ); if(error > 0) fprintf( stderr, "could not add filter: %s\n", "//" OY_TYPE_STD "/scale" ); in = out; /* add a expose node */ out = oyFilterNode_NewWith( "//" OY_TYPE_STD "/expose", 0, obj ); options = oyFilterNode_GetOptions( out, OY_SELECT_FILTER ); /* expose factor */ error = oyOptions_SetFromDouble( &options, "//" OY_TYPE_STD "/expose/expose", 1.0, 0, OY_CREATE_NEW ); oyOptions_Release( &options ); /* append the node */ error = oyFilterNode_Connect( in, "//" OY_TYPE_STD "/data", out, "//" OY_TYPE_STD "/data", 0 ); if(error > 0) fprintf( stderr, "could not add filter: %s\n", "//" OY_TYPE_STD "/expose" ); in = out; /* add a channel node */ out = oyFilterNode_NewWith( "//" OY_TYPE_STD "/channel", 0, obj ); options = oyFilterNode_GetOptions( out, OY_SELECT_FILTER ); /* channel option*/ error = oyOptions_SetFromText( &options, "//" OY_TYPE_STD "/channel/channel", "", OY_CREATE_NEW ); oyOptions_Release( &options ); /* append the node */ error = oyFilterNode_Connect( in, "//" OY_TYPE_STD "/data", out, "//" OY_TYPE_STD "/data", 0 ); if(error > 0) fprintf( stderr, "could not add filter: %s\n", "//" OY_TYPE_STD "/channel" ); in = out; /* create a new filter node */ { icc = out = oyFilterNode_FromOptions( OY_CMM_STD, "//" OY_TYPE_STD "/icc_color", cc_options, NULL ); /* append the new to the previous one */ error = oyFilterNode_Connect( in, "//" OY_TYPE_STD "/data", out, "//" OY_TYPE_STD "/data", 0 ); if(error > 0) fprintf( stderr, "could not add filter: %s\n", OY_CMM_STD ); /* Set the image to the first/only socket of the filter node. * oyFilterNode_Connect() has now no chance to copy it it the other nodes. * We rely on resolving the image later. */ error = oyFilterNode_SetData( out, (oyStruct_s*)image_out, 0, 0 ); if(error != 0) fprintf( stderr, "could not add data\n" ); } /* swap in and out */ if(out) in = out; /* create a node for preparing the image for displaying */ { out = oyFilterNode_NewWith( "//" OY_TYPE_STD "/display", 0, obj ); options = oyFilterNode_GetOptions( out, OY_SELECT_FILTER ); /* data type for display */ error = oyOptions_SetFromInt( &options, "//" OY_TYPE_STD "/display/datatype", data_type, 0, OY_CREATE_NEW ); /* alpha might be support once by FLTK? */ error = oyOptions_SetFromInt( &options, "//" OY_TYPE_STD "/display/preserve_alpha", 1, 0, OY_CREATE_NEW ); oyOptions_Release( &options ); /* append the node */ error = oyFilterNode_Connect( in, "//" OY_TYPE_STD "/data", out, "//" OY_TYPE_STD "/data", 0 ); if(error > 0) fprintf( stderr, "could not add filter: %s\n", "//" OY_TYPE_STD "/display" ); oyFilterNode_SetData( out, (oyStruct_s*)image_out, 0, 0 ); in = out; } /* add a closing node */ out = oyFilterNode_NewWith( "//" OY_TYPE_STD "/output", 0, obj ); error = oyFilterNode_Connect( in, "//" OY_TYPE_STD "/data", out, "//" OY_TYPE_STD "/data", 0 ); if(error > 0) fprintf( stderr, "could not add filter: %s\n", "//" OY_TYPE_STD "/output" ); /* set the output node of the conversion */ oyConversion_Set( conversion, 0, out ); /* apply policies */ /*error = oyOptions_SetFromText( &options, "//" OY_TYPE_STD "//verbose", "true", OY_CREATE_NEW );*/ oyConversion_Correct( conversion, "//" OY_TYPE_STD "/icc_color", flags, options ); oyOptions_Release( &options ); if(cc_node) *cc_node = icc; return conversion; }
/** Function oyDrawScreenImage * @brief generate a Oyranos image from a given context for display * * The function asks the 'oydi' node to provide parameters to render a * oyImage_s from a prepared oyConversion_s context. * * @param[in] context the Oyranos graph * @param[in,out] ticket rendering context for tracking * rectangles * @param[in] display_rectangle absolute coordinates of visible image * in relation to display * @param[in,out] old_display_rectangle * rembering of display_rectangle + @param[in,out] old_roi_rectangle remembering of ticket's ROI (optional) * @param[in] system_type the system dependent type specification * - "X11" is well supported * - "oy-test" for internal tests * @param[in] data_type_request oyUINT8 or oyUINT16 * @param[in] display the system display with system_type: * - "X11": a Display object * @param[in] window the system window with system_type: * - "X11": a Window ID * @param[in] dirty explicite redraw * @param[out] image the image from graph to display * @return 0 - success, -1 - issue, >= 1 - error * * @version Oyranos: 0.9.6 * @date 2016/09/22 * @since 2010/09/05 (Oyranos: 0.1.11) */ int oyDrawScreenImage ( oyConversion_s * context, oyPixelAccess_s * ticket, oyRectangle_s * display_rectangle, oyRectangle_s * old_display_rectangle, oyRectangle_s * old_roi_rectangle, const char * system_type, oyDATATYPE_e data_type_request, void * display, void * window, int dirty, oyImage_s * image ) { int result = 0; if(context) { double X,Y,W,H; int channels = 0; oyFilterNode_s * node_out = 0; oyRectangle_s * disp_rectangle = 0, * ticket_roi = 0; oyOptions_s * image_tags = 0; oyDATATYPE_e data_type = oyUINT8; oyPixel_t pt = 0; oyRectangle_GetGeo( display_rectangle, &X, &Y, &W, &H ); if(!image) return 1; if( W <= 0 || H <= 0) return -1; image_tags = oyImage_GetTags( image ); if(window && strcmp("X11", system_type) == 0) { #if defined(XCM_HAVE_X11) /* add X11 window and display identifiers to output image */ oyOption_s * o = 0; Display *disp = (Display*) display; Window w = (Window) window; int count = oyOptions_CountType( image_tags, "//" OY_TYPE_STD "/display/window_id", oyOBJECT_BLOB_S ); if(!count && w) { oyBlob_s * win_id = oyBlob_New(0), * display_id = oyBlob_New(0); if(win_id) { oyBlob_SetFromStatic( win_id, (oyPointer)w, 0, 0 ); o = oyOption_FromRegistration( "//" OY_TYPE_STD "/display/window_id", 0 ); oyOption_MoveInStruct( o, (oyStruct_s**)&win_id ); oyOptions_MoveIn( image_tags, &o, -1 ); oyBlob_SetFromStatic( display_id, (oyPointer)disp, 0, 0 ); o = oyOption_FromRegistration( "//" OY_TYPE_STD "/display/display_id", 0 ); oyOption_MoveInStruct( o, (oyStruct_s**)&display_id ); oyOptions_MoveIn( image_tags, &o, -1 ); oyOptions_SetFromText( &image_tags, "//" OY_TYPE_STD "/display/display_name", DisplayString(disp), OY_CREATE_NEW ); } else printf("%s:%d WARNING: no X11 Window obtained or\n" " no oyBlob_s allocateable\n", __FILE__,__LINE__); } #endif } else if(strcmp("oy-test", system_type) == 0) oyOptions_SetFromText( &image_tags, "//" OY_TYPE_STD "/display/display_name", system_type, OY_CREATE_NEW ); /* check if the actual data can be displayed */ pt = oyImage_GetPixelLayout( image, oyLAYOUT ); data_type = oyToDataType_m( pt ); channels = oyToChannels_m( pt ); if(pt != 0 && ((channels != 4 && channels != 3) || data_type != data_type_request)) { printf( "%s:%d WARNING: wrong image data format: %s\n%s\n" "need 4 or 3 channels with %s\n", __FILE__,__LINE__, oyOptions_FindString( image_tags, "filename", 0 ), image ? oyObject_GetName( image->oy_, oyNAME_NICK ) : "", oyDataTypeToText( data_type_request ) ); return 1; } /* Inform about the images display coverage. */ disp_rectangle = (oyRectangle_s*) oyOptions_GetType( image_tags, -1, "display_rectangle", oyOBJECT_RECTANGLE_S ); oyRectangle_SetGeo( disp_rectangle, X,Y,W,H ); node_out = oyConversion_GetNode( context, OY_OUTPUT ); ticket_roi = oyPixelAccess_GetArrayROI( ticket ); /* decide wether to refresh the cached rectangle of our static image */ if( node_out && /* Did the window area move? */ ((!oyRectangle_IsEqual( disp_rectangle, old_display_rectangle ) || /* Something explicite to update? */ (old_roi_rectangle && !oyRectangle_IsEqual( ticket_roi, old_roi_rectangle ))|| /* Did the image move? */ oyPixelAccess_GetStart( ticket,0 ) != oyPixelAccess_GetOldStart( ticket,0 ) || oyPixelAccess_GetStart( ticket,1 ) != oyPixelAccess_GetOldStart( ticket,1 )) || dirty > 0)) { #ifdef DEBUG_ printf( "%s:%d new display rectangle: %s +%d+%d\n", __FILE__,__LINE__, oyRectangle_Show(disp_rectangle), X, Y ), #endif /* convert the image data */ oyConversion_RunPixels( context, ticket ); if(oy_debug && getenv("OY_DEBUG_WRITE")) { oyImage_s * out = oyConversion_GetImage( context, OY_OUTPUT ); oyImage_WritePPM( out, "debug_image_out.ppm", "image_display output image"); oyImage_Release( &out ); } /* remember the old rectangle */ oyRectangle_SetByRectangle( old_display_rectangle, disp_rectangle ); oyRectangle_SetByRectangle( old_roi_rectangle, ticket_roi ); oyPixelAccess_SetOldStart(ticket,0, oyPixelAccess_GetStart(ticket,0)); oyPixelAccess_SetOldStart(ticket,1, oyPixelAccess_GetStart(ticket,1)); } else result = -1; oyFilterNode_Release( &node_out ); oyOptions_Release( &image_tags ); oyRectangle_Release( &disp_rectangle ); oyRectangle_Release( &ticket_roi ); } if(oy_debug >= 4) fprintf( stderr, "%s:%d %s() result: %d\n", strrchr(__FILE__,'/'),__LINE__,__func__, result ); return result; }