XBM IO

Read and write XBM images.

Summary
XBM IORead and write XBM images.
Functions
gdImageCreateFromXbmgdImageCreateFromXbm is called to load images from X bitmap format files.
gdImageXbmCtxWrites an image to an IO context in X11 bitmap format.

Functions

gdImageCreateFromXbm

gdImagePtr gdImageCreateFromXbm(FILE *fd)

gdImageCreateFromXbm is called to load images from X bitmap format files.  Invoke gdImageCreateFromXbm with an already opened pointer to a file containing the desired image.  gdImageCreateFromXbm 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 an X bitmap format image).  gdImageCreateFromXbm 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.

X11 X bitmaps (which define a char[]) as well as X10 X bitmaps (which define a short[]) are supported.

Parameters

fdThe input FILE pointer

Returns

A pointer to the new image or NULL if an error occurred.

Example

gdImagePtr im;
FILE *in;
in = fopen("myxbm.xbm", "rb");
im = gdImageCreateFromXbm(in);
fclose(in);
// ... Use the image ...
gdImageDestroy(im);

gdImageXbmCtx

void gdImageXbmCtx(gdImagePtr image,
char *file_name,
int fg,
gdIOCtx *out)

Writes an image to an IO context in X11 bitmap format.

Parameters

imageThe gdImagePtr to write.
file_nameThe prefix of the XBM’s identifiers.  Illegal characters are automatically stripped.
gdWhich color to use as forground color.  All pixels with another color are unset.
outThe gdIOCtx to write the image file to.
gdImagePtr gdImageCreateFromXbm(FILE *fd)
gdImageCreateFromXbm is called to load images from X bitmap format files.
void gdImageXbmCtx(gdImagePtr image,
char *file_name,
int fg,
gdIOCtx *out)
Writes an image to an IO context in X11 bitmap format.
The data structure in which gd stores images.
void gdImageDestroy (gdImagePtr im)
gdImageDestroy is used to free the memory associated with an image.
gdIOCtx structures hold function pointers for doing image IO.
Close