| M E M _ R E A D S R C I M A G E ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
PORTA - MEM_#?
----------------------------------------------------------------------------
NAME
mem_readsrcimage() - Transforms 'struct Images' as found
in C source code into fully qualified
images.
SYNOPSIS
im = mem_readsrcimage(errptr, fname);
struct Image *mem_readsrcimage(LONG *, UBYTE *);
FUNCTION
This func. works a bit like C compiler except that it only
compiles Intuition Images along with all necessary tables
that contain bitmap and palette data.
INPUTS
errptr - Error pointer of LONG or NULL if no errors are to
be reported.
fname - Filename of C header file that contains 'Image's.
RETURNS
Returns pointer to 'Image' that may reference other 'Image'
through 'im->NextImage'. NULL will be returned on error.
BASES
SysBase, DOSBase
NOTES
All separate Image structures as found in the source file
will form a chain in the order they were found. Do not pre
reference them, just leave the 'NextImage' set to NULL.
This function tries to be smart in the way that it manages
to attach RGB4/RGB32 palettes to the image! As you know
palettes are not referenced by the Image structure so this
is somewhat guessing. Palette pointers are located after
'NextImage' member. First ULONG contains RGB4 address and
the next one RGB32.
This function does not analyze symbol syntax, so it is
possible to construct 'Image's by hand. The only rule here
is to use the very same "prefix" for all tables. Lets say
that the 'Image' structure is called 'myimage' then image
data and palettes must start with 'myimage' too. It is not
necessary to signify RGB4 or RGB32 per palette. Word width
is the factor! So in case of bitmap, data symbol should be
'myimagedata' and palette 'myimagepal4', 'myimagepal32'.
This function detects datatypes directly, no typdefs are
possible. The only datatypes supported are 'ULONG' and
'UWORD'!
Size of the table must be known at the time of parsing cus
only one pass is taken.
SEE ALSO
mem_freesrcimage()
EXAMPLE
...
struct Image *im;
struct Image *ptr;
UWORD *rgb4;
ULONG *rgb32;
if ((im = mem_readsrcimage(NULL, "picture.h")))
{
ptr = im;
while (ptr)
{
/*
* Palette can be extracted like this or by creating a
* wrapper structure. Please test the extracted address
* for NULL though!
*/
ptr++;
rgb4 = (UWORD *)*(ULONG *)ptr;
rgb32 = (ULONG *)ptr;
rgb32 = (ULONG *)*(ULONG *)++rgb32;
ptr--;
...
ptr->NextImage;
}
mem_freesrcimage(im);
}
BUGS
None known.
----------------------------------------------------------------------------
| |
| |