The System Library contains functions to convert memory types.
However do not expect to find a function to convert structures
which are very dissimilar, as
If the meaning one can give of a conversion is not evident or not unique,
a conversion procedure has to be implemented as a module rather than
as a system function.
Conversion function summaries follow the following rule :
out = (Y) mw_x_to_y(in,old) where
x is the internal C type of the
y the internal C type of the requested output
out (letters in lowercase) and
Y the cast to the output
(internal C type of
out with first letter in uppercase).
In the last argument
old you may put the name of a variable of type
in such a case, the memory allocation will be reused for
out (the pointer
old will have the same address than
out). This is especially useful
when converting lot of images with same size, to avoid memory blowup.
If you do not want to use this possibility, just put
NULL as the last argument :
out will be allocated.
In addition to the various
mw_x_to_y() undocumented conversion
functions, there exists an ``all-purpose'' conversion function called
mw_conv_internal_type() and documented next page.
mw_conv_internal_type - Convert any possible internal type to another one
void *mwstruct; /* Any type of MegaWave2 structure */
char *typein; /* Type of the input <mwstruct> */
char *typeout; /* Type of the output structure */
This function may be used instead of the
mw_x_to_y() various functions
to convert any possible internal type
b, even if the
mw_a_to_b() function does not exist : the system creates
mw_conv_internal_type() by analyzing existing
functions, by finding the shortest path between two internal types, say
b, and by calling appropriate
mw_c_to_b() if those functions exist).
mwstruct is a variable of internal C type given by the
typein (use lower letters only).
The output of the function is a variable of internal C type given by the
NULL if the conversion is impossible.
Do not forget to cast the output to the right type.
Ccimage in; Cimage out1; Fimage out2; /* The line */ out1 = (Cimage) mw_conv_internal_type(in,"ccimage","cimage"); /* is equivalent to */ out1 = (Cimage) mw_ccimage_to_cimage(in); if (out1==NULL) mwerror(FATAL,1,"Cannot convert Ccimage to Cimage !\n"); /* But to convert a Ccimage to a Fimage you shall use */ out2 = (Fimage) mw_conv_internal_type(in,"ccimage","fimage"); /* Since the following function does not exist at this time */ out2 = (Fimage) mw_ccimage_to_fimage(in); if (out2==NULL) mwerror(FATAL,1,"Cannot convert Ccimage to Fimage !\n");