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.
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) |
truecolor | 1 byte (always “\0”) |
count | 1 word (the number of used palette colors) |
transparent | 1 dword (ARGB color) |
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 )