/** Function oyArray2d_Init_ * @memberof oyArray2d_s * @brief Initialise Array * * @version Oyranos: 0.9.0 * @since 2012/10/20 (Oyranos: 0.9.0) * @date 2012/10/20 */ int oyArray2d_Init_ ( oyArray2d_s_ * s, int width, int height, oyDATATYPE_e data_type ) { int error = !(width || height); if(error <= 0) { int y_len = sizeof(unsigned char *) * (height + 1); oyOBJECT_e rtype = oyOBJECT_RECTANGLE_S; s->width = width; s->height = height; s->t = data_type; memcpy( &s->data_area, &rtype, sizeof(oyOBJECT_e) ); oyRectangle_SetGeo( (oyRectangle_s*)&s->data_area, 0,0, width, height ); oyAllocHelper_m_( s->array2d, unsigned char *, height + 1, s->oy_->allocateFunc_, return 1 ); error = !memset( s->array2d, 0, y_len ); s->own_lines = oyNO; }
/** 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; }