Dali: GIF -- C API

[ Header Files | Types | Constants | Allocation and Deallcation Primitives | GIF Decoding Primtives | GIF Encoding Primtives | GIF Sequence Header Queries | GIF Sequence Header Initialization | GifImgHdr Queries | GifImgHdr Initialization | GIF Image Primitives | See Also ]

Header Files

#include <dvmgif.h>

Type Definitions

GifSeqHdr

The struct GifSeqHdr corresponds to what the GIF standards refer to as the header and logical screen descriptor.

      typedef struct GifSeqHdr {
          int ctFlag;    
          int bitsPerPixel;            
          int ctSize;
          int ctSorted;      
          int width;     
          int height;    
          int resolution;   
          int backgroundColor;
          int aspectRatio;    
          char version[3];           
      } GifSeqHdr;
  
ctFlag
1 if the sequence has a global color table, 0 otherwise.
bitsPerPixel
The number of bits per pixel of each color table entry.
ctSize
The size of the global color table. This is equal to 2^(bitsPerPixel) and the maximum size is 256.
ctSorted
1 if the global color table is sorted, 0 otherwise. Typically the color table is sorted in descreasing order of frequency.
width
Width of each frame in pixels.
height
Height of each frame in pixels.
resolution
Number of bits per primary color available to the original image.
backgroundColor
Index in the global color table of background color.
aspectRatio
Pixel aspect ratio.
version
The GIF version to which the sequence conforms. This is usually "87a" or "89a".

GifImgHdr

The struct GifImgHdr corresponds to what the GIF standards refers to as the image descriptor and graphic control extension.

      typedef struct GifImgHdr {
          int ctFlag;    
          int bitsPerPixel;            
          int ctSize;
          int ctSorted;       
          int leftPosition;
          int topPosition;
          int width;
          int height;
          int interlaced;
          int graphicControlFlag;
          int disposalMethod;
          int userInputFlag;
          int transparentColorFlag;
          int delayTime;
          int transparentColorIndex;
      } GifImgHdr;
  
ctFlag
1 if the image has a local color table. 0 if local color table is not present.
bitsPerPixel
The number of bits per pixel of each color table entry. This is valid only if ctFlag is 1.
ctSize
The size of the local color table. This is equal to 2^(bitsPerPixel) and the maximum size is 256. This is valid only if ctFlag is 1.
ctSorted
Whether the local color table is sorted or not. This is valid only if ctFlag is 1.
leftPosition, topPosition
Position (in pixel) of this image with respect to the GIF image.
width
Width of the image in pixels.
height
Height of the image in pixels.
interlaced
1 if the image is interlaced, 0 otherwise.
graphicControlFlag
1 if the image has a graphic control extension, 0 otherwise. The graphic control extension is available for GIF version "89a" only.
disposalMethod
Indicates the way in which the graphic is to be treated after being displayed. Possible values:
  • 0 - No disposal specified.
  • 1 - Do not dispose.
  • 2 - Restore to background color.
  • 3 - Restore to previous.
This is valid only if graphic control flag is 1.
userInputFlag
Indicates whether or not user input is expected before continuing. This is valid only if graphic control flag is 1.
transparentColorFlag
Indicates whether a transparency index is given in the Transparent Index field. This is valid only if graphic control flag is 1.
delayTime
If not 0, this field specifies the number of hundredths (1/100) of a second to wait before continuing with the processing of the Data Stream. This is valid only if graphic control flag is 1.
transparentColorIndex
When encountered, the corresponding pixel of the display device is not modified and processing goes on to the next pixel, if the transparent color flag is set. This is valid only if graphic control flag is 1.

Constants

Return Code

Return code from various GIF primitives. GIF_OK indicates the primitives executed succesfully. IMG_READ_ERROR indicates some occured while reading the GIF Image. IMG_SEPARATOR_ERROR indicates an invalid GIF image header. BAD_HEADER indicates there is an error in the GIF signature of the sequence header. BAD_VERSION indicates an invalid version number in the sequence header.

    #define DVM_GIF_OK 0
    #define DVM_GIF_IMG_READ_ERROR -1
    #define DVM_GIF_EOF_ERROR -2
    #define DVM_GIF_IMG_SEPARATOR_ERROR -3
    #define DVM_GIF_BAD_HEADER -4
    #define DVM_GIF_BAD_VERSION -5
    #define DVM_GIF_INTERLACED -6
    #define DVM_GIF_NOT_INTERLACED -7
    #define DVM_GIF_BAD_WIDTH -8
    #define DVM_GIF_BAD_HEIGHT -9
  

Operators

Allocation and Deallcation Primitives

GifSeqHdr *GifSeqHdrNew ()

void GifSeqHdrFree (GifSeqHdr *hdr)

GifImgHdr *GifImgHdrNew ()

void GifImgHdrFree (GifImgHdr *hdr)


GIF Decoding Primtives

int GifSeqHdrParse (BitParser* bp, GifSeqHdr* gifHdr)

int GifCtParse(BitParser* bp, int size, ImageMap *red, ImageMap *green, ImageMap *blue);

int GifImgHdrParse (BitParser *bp, GifImgHdr *hdr)

int GifImgInterlacedParse (BitParser *bp, GifSeqHdr *seqHdr, GifImgHdr *imgHdr, ByteImage *mapBuf)

int GifImgNoneInterlacedParse (BitParser *bp, GifSeqHdr *seqHdr, GifImgHdr *imgHdr, ByteImage *mapBuf)


GIF Encoding Primtives

void GifSeqHdrEncode(BitParser* bp, GifSeqHdr *gifHdr)

void GifSeqLoopEncode(BitParser *bp)

void GifSeqTrailerEncode(BitParser* bp)

void GifCtEncode(int size, ImageMap *red, ImageMap *green, ImageMap *blue, BitParser* bp);

void GifImgHdrEncode (GifImgHdr *hdr, BitParser *bp)

void GifImgEncode(GifImgHdr* imgHdr, BitParser* bp)


GIF Sequence Header Queries

int GifSeqHdrGetWidth(GifSeqHdr* seqHdr)
int GifSeqHdrGetHeight(GifSeqHdr* seqHdr)
int GifSeqHdrGetCtFlag(GifSeqHdr* seqHdr)
int GifSeqHdrGetCtSize(GifSeqHdr* seqHdr)
int GifSeqHdrGetCtSorted(GifSeqHdr* seqHdr)
int GifSeqHdrGetResolution(GifSeqHdr* seqHdr)
int GifSeqHdrGetBackgroundColor(GifSeqHdr* seqHdr)
int GifSeqHdrGetAspectRatio(GifSeqHdr* seqHdr)
int GifSeqHdrGetVersion(GifSeqHdr* seqHdr)


GIF Sequence Header Initialization

void GifSeqHdrSetWidth(GifSeqHdr* seqHdr, void width)
void GifSeqHdrSetHeight(GifSeqHdr* seqHdr, void height)
void GifSeqHdrSetCtFlag(GifSeqHdr* seqHdr, void ct_flag)
void GifSeqHdrSetCtSize(GifSeqHdr* seqHdr, void ct_size)
void GifSeqHdrSetCtSorted(GifSeqHdr* seqHdr, void ct_sorted)
void GifSeqHdrSetResolution(GifSeqHdr* seqHdr, void resolution)
void GifSeqHdrSetBackgroundColor(GifSeqHdr* seqHdr, void background_color)
void GifSeqHdrSetAspectRatio(GifSeqHdr* seqHdr, void aspect_ratio)
void GifSeqHdrSetVersion(GifSeqHdr* seqHdr, char* version)


GifImgHdr Queries

int GifImgHdrGetWidth(GifImgHdr *imgHdr)
int GifImgHdrGetHeight(GifImgHdr *imgHdr)
int GifImgHdrGetCtFlag(GifImgHdr *imgHdr)
int GifImgHdrGetBitsPerPixel(GifImgHdr *imgHdr)
int GifImgHdrGetCtSize(GifImgHdr *imgHdr)
int GifImgHdrGetLeftPosition(GifImgHdr *imgHdr)
int GifImgHdrGetTopPosition(GifImgHdr *imgHdr)
int GifImgHdrGetInterlaced(GifImgHdr *imgHdr)
int GifImgHdrGetGraphicControlFlag(GifImgHdr *imgHdr)
int GifImgHdrGetDisposalMethod(GifImgHdr *imgHdr)
int GifImgHdrGetUserInputFlag(GifImgHdr *imgHdr)
int GifImgHdrGetTransparentColorFlag(GifImgHdr *imgHdr)
int GifImgHdrGetDelayTime(GifImgHdr *imgHdr)
int GifImgHdrGetTransparentColorIndex(GifImgHdr *imgHdr)


GifImgHdr Initialization

void GifImgHdrSetWidth(GifImgHdr *imgHdr, width)
void GifImgHdrSetHeight(GifImgHdr *imgHdr, height)
void GifImgHdrSetCtFlag(GifImgHdr *imgHdr, ct_flag)
void GifImgHdrSetBitsPerPixel(GifImgHdr *imgHdr, bits_per_pixel)
void GifImgHdrSetCtSize(GifImgHdr *imgHdr, ct_size)
void GifImgHdrSetLeftPosition(GifImgHdr *imgHdr, left_position)
void GifImgHdrSetTopPosition(GifImgHdr *imgHdr, top_position)
void GifImgHdrSetInterlaced(GifImgHdr *imgHdr, interlaced)
void GifImgHdrSetGraphicControlFlag(GifImgHdr *imgHdr, graphic_control_flag)
void GifImgHdrSetDisposalMethod(GifImgHdr *imgHdr, disposal_method)
void GifImgHdrSetUserInputFlag(GifImgHdr *imgHdr, user_input_flag)
void GifImgHdrSetTransparentColorFlag(GifImgHdr *imgHdr, transparent_color_flag)
void GifImgHdrSetDelayTime(GifImgHdr *imgHdr, delay_time)
void GifImgHdrSetTransparentColorIndex(GifImgHdr *imgHdr, transparent_color_index)


GIF Image Primitives

int GifImgSkip (BitParser *bp)

int GifImgFind (BitParser *bp)


See Also

ImageMap , BitParser , ByteImage


Last updated : Saturday, November 14, 1998, 07:50 PM