Read and write GD images.
The GD image format is a proprietary image format of libgd. It has to be regarded as being obsolete, and should only be used for development and testing purposes.
All numbers are stored in big-endian format. Note that all GD output is done in the GD 2.x format (not to be confused with the GD2 format), but input may also be in the GD 1.x format.
width | 1 word |
height | 1 word |
count | 1 byte (the number of used palette colors) |
transparent | 1 word (257 signals no transparency) |
palette | 256Ã3 bytes (RGB triplets) |
signature | 1 word (“\xFF\xFE” for truecolor, “\xFF\xFF” for palette) |
width | 1 word |
height | 1 word |
truecolor | 1 byte (always “\001”) |
transparent | 1 dword (ARGB color); “\377\377\377\377” means that no transparent color is set |
truecolor | 1 byte (always “\0”) |
count | 1 word (the number of used palette colors) |
transparent | 1 dword (palette index); “\377\377\377\377” means that no transparent color is set |
palette | 256 dwords (RGBA colors) |
Sequential pixel data; row-major from top to bottom, left to right:
GD IO | Read and write GD images. |
Functions | |
gdImageCreateFromGd | gdImageCreateFromGd is called to load images from gd format files. |
gdImageCreateFromGdPtr | |
gdImageCreateFromGdCtx | Reads in a GD image via a gdIOCtx struct. |
gdImageGd | |
gdImageGdPtr |
gdImagePtr gdImageCreateFromGd ( FILE * inFile )
gdImageCreateFromGd is called to load images from gd format files. Invoke gdImageCreateFromGd with an already opened pointer to a file containing the desired image in the gd file format, which is specific to gd and intended for very fast loading. (It is not intended for compression; for compression, use PNG or JPEG.)
gdImageCreateFromGd returns a gdImagePtr to the new image, or NULL if unable to load the image (most often because the file is corrupt or does not contain a gd format image). gdImageCreateFromGd does not close the file. You can inspect the sx and sy members of the image to determine its size. The image must eventually be destroyed using gdImageDestroy.
gdImageCreateFromGdPtr creates an image from GD data (i.e. the contents of a GD file) already in memory.
gdImageCreateFromGdCtx reads in an image using the functions in a gdIOCtx struct.
infile | The input FILE pointer |
A pointer to the new image or NULL if an error occurred.
gdImagePtr im; FILE *in; in = fopen("mygd.gd", "rb"); im = gdImageCreateFromGd(in); fclose(in); // ... Use the image ... gdImageDestroy(im);
gdImagePtr gdImageCreateFromGdPtr ( int size, void * data )
size | size of GD data in bytes. |
data | GD data (i.e. contents of a GIF file). |
Reads in GD data from memory. See gdImageCreateFromGd.
gdImagePtr gdImageCreateFromGdCtx ( gdIOCtxPtr in )
Reads in a GD image via a gdIOCtx struct. See gdImageCreateFromGd.
gdImageCreateFromGd is called to load images from gd format files.
gdImagePtr gdImageCreateFromGd ( FILE * inFile )
gdImagePtr gdImageCreateFromGdPtr ( int size, void * data )
Reads in a GD image via a gdIOCtx struct.
gdImagePtr gdImageCreateFromGdCtx ( gdIOCtxPtr in )
void gdImageGd ( gdImagePtr im, FILE * outFile )
void * gdImageGdPtr ( gdImagePtr im, int * size )
gdImageDestroy is used to free the memory associated with an image.
void gdImageDestroy ( gdImagePtr im )