Oyranos  git-devel
Oyranos is a full featured Color Management System
Public Member Functions | Data Fields
oyConversion_s Struct Reference

Image Manipulation by a Graph (DAG) More...

#include <oyConversion_s.h>

Inheritance diagram for oyConversion_s:
Inheritance graph
Collaboration diagram for oyConversion_s:
Collaboration graph

Public Member Functions

OYAPI oyConversion_s *OYEXPORT oyConversion_New (oyObject_s object)
 allocate a new Conversion object More...
 
OYAPI oyConversion_s *OYEXPORT oyConversion_Copy (oyConversion_s *conversion, oyObject_s object)
 Copy or Reference a Conversion object. More...
 
OYAPI int OYEXPORT oyConversion_Release (oyConversion_s **conversion)
 release and possibly deallocate a oyConversion_s object More...
 
int oyConversion_Correct (oyConversion_s *conversion, const char *registration, uint32_t flags, oyOptions_s *options)
 Check for correctly adhering to policies. More...
 
oyConversion_soyConversion_CreateBasicPixels (oyImage_s *input, oyImage_s *output, oyOptions_s *options, oyObject_s object)
 Allocate and initialise a basic oyConversion_s object. More...
 
oyConversion_soyConversion_CreateBasicPixelsFromBuffers (oyProfile_s *p_in, oyPointer buf_in, oyPixel_t buf_type_in, oyProfile_s *p_out, oyPointer buf_out, oyPixel_t buf_type_out, oyOptions_s *options, int count)
 One dimensional color conversion context. More...
 
oyConversion_soyConversion_CreateFromImage (oyImage_s *image_in, oyOptions_s *module_options, oyProfile_s *output_profile, oyDATATYPE_e buf_type_out, uint32_t flags, oyObject_s obj)
 generate a Oyranos graph from a image file name More...
 
oyFilterGraph_soyConversion_GetGraph (oyConversion_s *conversion)
 Get the filter graph from a conversion context. More...
 
oyImage_soyConversion_GetImage (oyConversion_s *conversion, uint32_t flags)
 Get a image copy at the desired position. More...
 
oyFilterNode_soyConversion_GetNode (oyConversion_s *conversion, uint32_t flags)
 Get the filter node copy. More...
 
int oyConversion_GetOnePixel (oyConversion_s *conversion, double x, double y, oyPixelAccess_s *pixel_access)
 Compute one pixel at the given position. More...
 
int oyConversion_RunPixels (oyConversion_s *conversion, oyPixelAccess_s *pixel_access)
 Process a pixel conversion graph. More...
 
int oyConversion_Set (oyConversion_s *conversion, oyFilterNode_s *input, oyFilterNode_s *output)
 Set input and output of a conversion graph. More...
 
char * oyConversion_ToText (oyConversion_s *conversion, const char *head_line, int reserved, oyAlloc_f allocateFunc)
 Text description of a conversion graph. More...
 
void oyConversion_Release__Members (oyConversion_s_ *conversion)
 Custom Conversion destructor. More...
 
int oyConversion_Init__Members (oyConversion_s_ *conversion OY_UNUSED)
 Custom Conversion constructor. More...
 
int oyConversion_Copy__Members (oyConversion_s_ *dst, oyConversion_s_ *src)
 Custom Conversion copy constructor. More...
 
- Public Member Functions inherited from oyStruct_s
const char * oyStruct_GetTextFromModule (oyStruct_s *obj, oyNAME_e name_type, uint32_t flags)
 get object infos from a module More...
 
const char * oyStruct_GetText (oyStruct_s *obj, oyNAME_e name_type, uint32_t flags)
 Get a text dump. More...
 
int oyStruct_RegisterStaticMessageFunc (int type, oyStruct_RegisterStaticMessageFunc_f msg, oyStruct_RegisterStaticFreeFunc_f free_func)
 register a function for verbosity More...
 
const char * oyStruct_GetInfo (oyPointer context_object, oyNAME_e type, int flags)
 get a additional string from a object More...
 
const char * oyStructTypeToText (oyOBJECT_e type)
 Objects type to small string. More...
 

Data Fields

const oyOBJECT_e type_
 Type of object. More...
 
oyStruct_Copy_f copy
 Copy function. More...
 
oyStruct_Release_f release
 Release function. More...
 
oyObject_s oy_
 Oyranos internal object. More...
 
- Data Fields inherited from oyStruct_s
const oyOBJECT_e type_
 Type of object. More...
 
oyStruct_Copy_f copy
 Copy function. More...
 
oyStruct_Release_f release
 Release function. More...
 
oyObject_s oy_
 Oyranos internal object. More...
 

Detailed Description

Image Manipulation by a Graph (DAG)

The main and most simple entry points are oyConversion_CreateBasicPixels(), oyConversion_Correct() and oyConversion_RunPixels(). More details can be read in Graph Live Cycle.

Order of filters matters. The processing direction is a bit like raytracing as nodes request their parent.

The graph is allowed to be a directed graph without cycles.

oyConversion_s shall provide access to the graph and help in processing and managing nodes.

Graph Live Cycle

Creating Graphs:
Most simple is to use the oyConversion_CreateBasicPixels() function to create a profile to profile and possible image buffer to image buffer linear graph.
The other possibility is to create a non linear graph. The input member can be accessed for this directly.

While it would be possible to have several open ends in a graph, there are two endpoints considered as special. The input member prepresents the top most required node to be provided in a oyConversion_s graph. The input node is accessible for user manipulation. The other one is the out_ member. It is the closing node in the graph. It will be set by Oyranos during closing the graph.

Configuring Graphs:
Image graphs for displayable result should in most cases be synced with user and system settings. Image graphs are typically used in three categories:

Using Graphs:
To obtain the data the oyConversion_RunPixels() and oyConversion_GetOnePixel() functions are available.

Releasing Graphs:
Giving memory back is simple as oyConversion_Release()

Version
Oyranos: 0.1.8
Since
2008/06/08 (Oyranos: 0.1.8)
Date
2008/06/08
Examples:
image2pdf.c, image_display.cpp, and tutorial1.c.

Member Function Documentation

◆ oyConversion_Copy()

OYAPI oyConversion_s *OYEXPORT oyConversion_Copy ( oyConversion_s conversion,
oyObject_s  object 
)

Copy or Reference a Conversion object.

Function oyConversion_Copy

The function is for copying and for referencing. The reference is the most often used way, which saves resourcs and time.

Parameters
[in]conversionConversion struct object
objectNULL - means reference, the optional object triggers a real copy

◆ oyConversion_Copy__Members()

int oyConversion_Copy__Members ( oyConversion_s_ *  dst,
oyConversion_s_ *  src 
)

Custom Conversion copy constructor.

Function oyConversion_Copy__Members

◆ oyConversion_Correct()

int oyConversion_Correct ( oyConversion_s conversion,
const char *  registration,
uint32_t  flags,
oyOptions_s options 
)

Check for correctly adhering to policies.

Function oyConversion_Correct

Without any options the module selected with the Registration policy filter shall perform graph analysis and correct the graph.

// use the output
error = oyConversion_Correct( conversion, "//" OY_TYPE_STD "/icc_color", 0, 0 );
if(error > 0) error_msg();
else if(error < 0) debug_msg();
Typical Options:
  • "command"-"help" - a string option issuing a help text as message
  • "verbose" - reporting changes as message

TODO: display and selection of policy modules

See also
Defaults Handling
Parameters
conversionthe to be checked configuration
registrationthe to be used policy module
[in]flagsselect particular options:
optionsoptions to the policy module
Returns
status
  • 0 : indifferent
  • >= 1 : error
  • < 0 : issue like, no module found from registration arg
  • a message should be sent
Version
Oyranos: 0.9.7
Date
2018/01/25
Since
2009/07/24 (Oyranos: 0.1.10)
Examples:
image2pdf.c.

◆ oyConversion_CreateBasicPixels()

oyConversion_s * oyConversion_CreateBasicPixels ( oyImage_s input,
oyImage_s output,
oyOptions_s options,
oyObject_s  object 
)

Allocate and initialise a basic oyConversion_s object.

Function oyConversion_CreateBasicPixels

// create a image graph
oyConversion_CreateBasicPixels( input_image, output_image, 0, 0 );

Provided options will be passed to oyFilterNode_NewWith(). There for no options defaults will be selected.

Parameters
[in]inputthe input image data
[in]outputthe output image data
[in]optionsoptions to be passed to oyFilterCore_s Each option should be carefully named to be correctly selected by the intented filter (root, icc and output). The available options are particial defined by plugable policy modules, e.g. "oicc", and a filters own options. OY_DEFAULT_CMM_CONTEXT and OY_DEFAULT_CMM_RENDERER can contain a string to explicitely select the icc module.
objectthe optional object
Returns
the conversion context
Version
Oyranos: 0.9.6
Date
2014/06/29
Since
2008/06/26 (Oyranos: 0.1.8)
Examples:
image2pdf.c.

◆ oyConversion_CreateBasicPixelsFromBuffers()

oyConversion_s * oyConversion_CreateBasicPixelsFromBuffers ( oyProfile_s p_in,
oyPointer  buf_in,
oyPixel_t  buf_type_in,
oyProfile_s p_out,
oyPointer  buf_out,
oyPixel_t  buf_type_out,
oyOptions_s options,
int  count 
)

One dimensional color conversion context.

Function oyConversion_CreateBasicPixelsFromBuffers

The options are passed to oyConversion_CreateBasicPixels(); The function does the lookups for the profiles and the modules contexts in the Oyranos cache on the fly.

Parameters
[in]p_inthe input profile
[in]buf_inthe input channels
[in]buf_type_inthe input pixel type; channel count can be omitted
[in]p_outthe output profile
[in]buf_outthe output channels
[in]buf_type_outthe output pixel type; channel count can be omitted
[in]optionssee the same option in oyConversion_CreateBasicPixels()
[in]countthe pixel count to convert in buf_in and buf_out
Returns
the conversion context
Version
Oyranos: 0.9.5
Date
2014/02/05
Since
2011/02/22 (Oyranos: 0.3.0)
Examples:
tutorial1.c.

◆ oyConversion_CreateFromImage()

oyConversion_s * oyConversion_CreateFromImage ( oyImage_s image_in,
oyOptions_s module_options,
oyProfile_s output_profile,
oyDATATYPE_e  buf_type_out,
uint32_t  flags,
oyObject_s  obj 
)

generate a Oyranos graph from a image file name

Function oyConversion_CreateFromImage

Parameters
[in]image_ininput
[in]module_optionsoptions for icc node
[in]output_profileprofile to convert colors to;
[in]buf_type_outthe desired data type for output
[in]flagsselect particular options:
[in]objOyranos object (optional)
Returns
generated new graph, owned by caller
Version
Oyranos: 0.9.6
Date
2014/07/01
Since
2012/04/21 (Oyranos: 0.5.0)

◆ oyConversion_GetGraph()

oyFilterGraph_s * oyConversion_GetGraph ( oyConversion_s conversion)

Get the filter graph from a conversion context.

Function oyConversion_GetGraph

See also
oyFilterGraph_GetNode() to obtain a node.
Parameters
[in,out]conversionconversion object
Returns
the filter graph containing all nodes
Version
Oyranos: 0.2.1
Since
2011/01/02 (Oyranos: 0.2.1)
Date
2011/01/02

References oyFilterGraph_s::oyFilterGraph_FromNode().

◆ oyConversion_GetImage()

oyImage_s * oyConversion_GetImage ( oyConversion_s conversion,
uint32_t  flags 
)

Get a image copy at the desired position.

Function oyConversion_GetImage

Parameters
[in,out]conversionconversion object
[in]flagsOY_INPUT or OY_OUTPUT
Returns
the image
Version
Oyranos: 0.1.10
Since
2009/02/19 (Oyranos: 0.1.10)
Date
2009/02/19

◆ oyConversion_GetNode()

oyFilterNode_s * oyConversion_GetNode ( oyConversion_s conversion,
uint32_t  flags 
)

Get the filter node copy.

Function oyConversion_GetNode

Parameters
[in,out]conversionconversion object
[in]flagsOY_INPUT or OY_OUTPUT
Returns
the filter node as defined by flags
Version
Oyranos: 0.3.0
Since
2011/03/27 (Oyranos: 0.3.0)
Date
2011/03/29

◆ oyConversion_GetOnePixel()

int oyConversion_GetOnePixel ( oyConversion_s conversion,
double  x,
double  y,
oyPixelAccess_s pixel_access 
)

Compute one pixel at the given position.

Function oyConversion_GetOnePixel

Parameters
[in,out]conversionconversion object
[in]xposition x
[in]yposition y
[in,out]pixel_accesspixel iterator configuration
Returns
-1 end; 0 on success; error > 1
Version
Oyranos: 0.3.0
Since
2008/07/14 (Oyranos: 0.1.8)
Date
2011/04/11

◆ oyConversion_Init__Members()

int oyConversion_Init__Members ( oyConversion_s_ *conversion  OY_UNUSED)

Custom Conversion constructor.

Function oyConversion_Init__Members

◆ oyConversion_New()

OYAPI oyConversion_s *OYEXPORT oyConversion_New ( oyObject_s  object)

allocate a new Conversion object

Function oyConversion_New

◆ oyConversion_Release()

OYAPI int OYEXPORT oyConversion_Release ( oyConversion_s **  conversion)

release and possibly deallocate a oyConversion_s object

Function oyConversion_Release

Parameters
[in,out]conversionConversion struct object
Examples:
image2pdf.c.

◆ oyConversion_Release__Members()

void oyConversion_Release__Members ( oyConversion_s_ *  conversion)

Custom Conversion destructor.

Function oyConversion_Release__Members

◆ oyConversion_RunPixels()

int oyConversion_RunPixels ( oyConversion_s conversion,
oyPixelAccess_s pixel_access 
)

Process a pixel conversion graph.

Function oyConversion_RunPixels

Parameters
[in,out]conversionconversion object
[in,out]pixel_accessoptional custom pixel iterator configuration; The ticket can be passed in for specifying only regions of the source data.
Returns
0 on success, else error
Version
Oyranos: 0.1.10
Since
2008/07/06 (Oyranos: 0.1.8)
Date
2009/03/06

Here a very basic code snippet:

// use the output
oyConversion_RunPixels( conversion, NULL );
oyImage_s * image = oyConversion_GetImage( conversion, OY_OUTPUT );
// get the data and draw the image
for(i = 0; i < image->height; ++i)
{
image_data = oyImage_GetLineF(image)( image, i, &height, -1, &is_allocated );
// ...
if(is_allocated)
free( image_data );
}

Here a example from test2.cpp for creating a job ticket from the DAG:

// create a basic job ticket for faster repeats of oyConversion_RunPixels()
out = oyConversion_GetNode( s, OY_OUTPUT );
if(s && out)
plug = oyFilterNode_GetPlug( out, 0 );
else
error = 1;
pixel_access = oyPixelAccess_Create( 0,0, plug,
oyFilterPlug_Release( &plug );

oyFilterGraph_PrepareContexts() uses the internal oyFilterNode_SetContext_() for automatic resources resolving during DAG processing. Both oyCMMapi4_s and oyCMMapi7_s contexts are checked for if declared by oyCMMapi4_Create() context_type argument.

The function creates a very simple pixel iterator if no job ticket is passed in as pixel_access.

Write the pixel data possibly to the output image.
The oyPixelAccess_s job ticket contains a oyArray2d_s object called array holding the in memory data. After the job is done the output images pixel_data pointer is compared with the job tickets array pointer. If they are the same it is assumed that a observer of the output image will see the same processed data, otherwise oyPixelAccess_s::array must be copied to the output image. Here a example from test2.cpp for a optimisation by setting the same array in the DAG output image and the ticket:

oyArray2d_s * pdata = (oyArray2d_s*) oyImage_GetPixelData( output ); // or use oyConversion_GetImage()
oyImage_s * output_image = oyPixelAccess_GetOutputImage( pixel_access );
if(output_image != output)
fprintf( zout, "Can not optimise last output copy\n" );
oyArray2d_s * array = oyPixelAccess_GetArray( pixel_access );
if(array != pdata) // should be typical the case
oyPixelAccess_SetArray( pixel_access, (oyArray2d_s*)pdata, 0 );

See also
oyPixelAccess_Create() oyImage_GetPixelData() oyPixelAccess_GetOutputImage() oyPixelAccess_GetArray() oyPixelAccess_SetArray()

While the design of having whatever data storage in a oyImage_s is very flexible, the oyPixelAccess_s::array's in memory buffer is not. Users with very large data sets have to process the data in chunks and the oyPixelAccess_s::array allocation can remain constant.

Examples:
image2pdf.c, and tutorial1.c.

◆ oyConversion_Set()

int oyConversion_Set ( oyConversion_s conversion,
oyFilterNode_s input,
oyFilterNode_s output 
)

Set input and output of a conversion graph.

Function oyConversion_Set

Parameters
[in,out]conversionconversion object
[in]inputinput node
[in]outputoutput node
Returns
0 on success, else error
Version
Oyranos: 0.1.10
Since
2009/03/05 (Oyranos: 0.1.10)
Date
2009/03/05

◆ oyConversion_ToText()

char * oyConversion_ToText ( oyConversion_s conversion,
const char *  head_line,
int  reserved,
oyAlloc_f  allocateFunc 
)

Text description of a conversion graph.

Function oyConversion_ToText

Todo:
Should this function generate XFORMS compatible output? How?
Parameters
[in]conversionconversion object
[in]head_linetext for inclusion
[in]reservedfuture format selector (dot, xml ...)
[in]allocateFuncallocation function
Returns
the graph description
Version
Oyranos: 0.1.8
Since
2008/10/04 (Oyranos: 0.1.8)
Date
2009/03/05

Field Documentation

◆ copy

oyStruct_Copy_f oyConversion_s::copy

Copy function.

◆ oy_

oyObject_s oyConversion_s::oy_

Oyranos internal object.

Features name and hash. Do not change during object life time.

◆ release

oyStruct_Release_f oyConversion_s::release

Release function.

◆ type_

const oyOBJECT_e oyConversion_s::type_

Type of object.

The struct type tells Oyranos how to interprete hidden fields.