[Contents] [Index] [Help] [Retrace] [Browse <] [Browse >]

In the case of a FORM ILBM, certain chunks are defined as being able to
appear in any order.  Among these are the BMHD, CMAP, and CAMG. Typically,
BMHD appears first, followed by CMAP and CAMG, but you can't make this
assumption.  The IFF and ILBM standards require you to assume these chunks
will appear in any order.  So ideally, what you'd like to do is collect
them as they arrive, but not do anything with them until you actually need
them.

This is where PropChunk() comes in.  The syntax for PropChunk() is
identical to StopChunk():

    error = PropChunk (iff, ID_ILBM, ID_BMHD);

When you call ParseIFF(), the parser will look for chunks declared with
PropChunk().  When it sees them, the parser will internally copy the
contents of the chunk into memory for you before continuing its parsing.

When you're ready to examine the contents of the chunk, you use the
function FindProp():

    StoredProperty = FindProp (iff, ID_ILBM, ID_BMHD);

FindProp() returns a pointer to a struct StoredProperty, which contains
the chunk size and data.  If the chunk was never encountered, NULL is
returned.  This permits you to process the property chunks in any order
you wish, regardless of how they appeared in the file.  This provides much
better control of data interpretation and also reduces headaches.  The
following fragment shows how ILBM BitMapHeader data could be accessed
after using ParseIFF() with PropChunk(iff, ID_ILBM, ID_BMHD):

    struct StoredProperty *sp;      /* defined in iffparse.h */
    struct BitMapHeader *bmhd;      /* defined in IFF spec   */

    if (sp = FindProp(iff, ID_ILBM, ID_BMHD))
            {
            /* If property is BMHD, sp->sp_Data is ptr to data in BMHD */
            bmhd = (struct BitMapHeader *)sp->sp_Data;
            printf("BMHD: PageWidth      = %ld\n",bmhd->PageWidth);
            }


[Back to Amiga Developer Docs]