next up previous contents
Next: Simple image/pixel routines Up: The Image Package Previous: The Image Package   Contents


Image formats and types

Gandalf distinguishes between the external file format of an image and the an internal image format used by Gandalf to represent the image data. The former is often used to select the latter, but it is important to separate the two. The available internal Gandalf image formats are defined by the Gan_ImageFormat enumerated type, found in <gandalf/image/pixel.h>:
      typedef enum { GAN_GREY_LEVEL_IMAGE,       /* grey-level images */
                     GAN_GREY_LEVEL_ALPHA_IMAGE, /* grey-level images with alpha
                                                    channel */
                     GAN_RGB_COLOUR_IMAGE,       /* RGB colour images */
                     GAN_RGB_COLOUR_ALPHA_IMAGE, /* RGB colour images with alpha
                                                    channel */
                     GAN_VECTOR_FIELD_2D,        /* 2D image of 2D vectors */
                     GAN_VECTOR_FIELD_3D }       /* 2D image of 3D vectors */
        Gan_ImageFormat;
The formats are (hopefully) self-explanatory, and allow Gandalf to represent most useful kinds of image data. Along with the format there is also an image type, which determines what type of data is stored in each pixel of the image. The Gan_Type enumerated type is used to distinguish the image type. It allows for instance boolean, unsigned character, short integer or floating point types to be defined, and is described in Section 2.1.1. Note that not all types are supported by each format. For instance boolean images (GAN_BOOL type) are only supported as grey-level format images (format GAN_GREY_LEVEL_IMAGE), and the vector field formats GAN_VECTOR_FIELD_2D and GAN_VECTOR_FIELD_3D are currently supported only for signed types. Support for extra types can be added when required.

There is also a structure to represent a rectangular sub-window of an image, useful in many situations:

      /* Definition of a rectangular sub-part of an image.
       */
      typedef struct Gan_ImageWindow
      {
         /* offset of window relative to top-left corner of the image */
         unsigned c0, r0;

         /* dimensions of window */
         unsigned width, height;
      } Gan_ImageWindow;

Apart from the standard simple C types, boolean and pointer image types are supported. These are described in Sections 4.4 and 4.5.


next up previous contents
Next: Simple image/pixel routines Up: The Image Package Previous: The Image Package   Contents
2006-03-17