#include <gandalf/image/image_pointer.h>Gandalf pointer images allow storage and manipulation of a 2D array of generic pointers, stored as void * values. Pointer images have format GAN_GREY_LEVEL_IMAGE and type GAN_POINTER. All the standard functions given above. Note that when a pointer image is freed, the pointer pixels are left ``hanging'', so they should if necessary be freed first before freeing the pointer image. This code fragment illustrates the use of pointer image functions.
Gan_Image *pImage; Gan_Vector4 *apv4Vector[5], *pv4Vector; int iCount, iRow, iCol; /* allocate 300x200 pointer image, and initialise all pointer "pixels" to NULL */ pImage = gan_image_alloc_p ( 300, 200 ); gan_image_fill_zero(pImage); /* allocate some pointers to 4-vectors */ for ( iCount = 5-1; iCount >= 0; iCount-- ) apv4Vector[iCount] = gan_malloc_object(Gan_Vector4); /* set some pointer "pixels" */ gan_image_set_pix_p ( pImage, 271, 39, apv4Vector[0] ); gan_image_set_pix_p ( pImage, 30, 120, apv4Vector[1] ); gan_image_set_pix_p ( pImage, 78, 49, apv4Vector[2] ); gan_image_set_pix_p ( pImage, 147, 120, apv4Vector[3] ); gan_image_set_pix_p ( pImage, 232, 130, apv4Vector[4] ); /* now free allocated vectors by searching for non-NULL values in the image */ for ( iRow = (int)pImage->height-1; iRow >= 0; iRow-- ) for ( iCol = (int)pImage->width-1; iCol >= 0; iCol-- ) if ( (pv4Vector = gan_image_get_pix_p ( pImage, iRow, iCol )) != NULL ) free(pv4Vector); /* free image */ gan_image_free ( pImage );