LibGd 2.4.0-dev
GD Graphics library
Loading...
Searching...
No Matches
Functions
WBMP

Wireless Bitmap reading and writing support. More...

Collaboration diagram for WBMP:

Functions

void gdImageWBMP (gdImagePtr image, int fg, FILE *out)
 Write an image as WBMP data to a stdio file.
 
void gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtxPtr out)
 Write an image as WBMP data to a gdIOCtx.
 
void * gdImageWBMPPtr (gdImagePtr im, int *size, int fg)
 Write an image as WBMP data to a newly allocated memory buffer.
 

WBMP Reading

gdImagePtr gdImageCreateFromWBMP (FILE *inFile)
 Create an image from a WBMP stdio file.
 
gdImagePtr gdImageCreateFromWBMPCtx (gdIOCtxPtr infile)
 Create an image from WBMP data read through a gdIOCtx.
 
gdImagePtr gdImageCreateFromWBMPPtr (int size, void *data)
 Create an image from a WBMP memory buffer.
 

Detailed Description

Wireless Bitmap reading and writing support.

WBMP support reads Wireless Bitmap Type 0 images into palette-based gd images with white and black colors. WBMP output writes a 1-bit image: pixels whose color matches the foreground color parameter are written as black, and all other pixels are written as white.

gdImagePtr im, roundtrip;
int white, black;
void *data;
int size;
im = gdImageCreate(100, 100);
if (im == NULL) {
exit(1);
}
white = gdImageColorAllocate(im, 255, 255, 255);
black = gdImageColorAllocate(im, 0, 0, 0);
gdImageFilledRectangle(im, 0, 0, 99, 99, white);
gdImageRectangle(im, 20, 20, 79, 79, black);
data = gdImageWBMPPtr(im, &size, black);
if (data == NULL) {
gdImageDestroy(im);
exit(1);
}
roundtrip = gdImageCreateFromWBMPPtr(size, data);
gdFree(data);
gdImageDestroy(roundtrip);
gdImageDestroy(im);
void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
Draws a rectangle.
Definition gd.c:2239
void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)
Draws a filled rectangle.
Definition gd.c:2403
void * gdImageWBMPPtr(gdImagePtr im, int *size, int fg)
Write an image as WBMP data to a newly allocated memory buffer.
Definition gd_wbmp.c:198
gdImagePtr gdImageCreateFromWBMPPtr(int size, void *data)
Create an image from a WBMP memory buffer.
Definition gd_wbmp.c:177
Write an image as JPEG data to a gdIOCtx.

Function Documentation

◆ gdImageCreateFromWBMP()

gdImagePtr gdImageCreateFromWBMP ( FILE *  inFile)

Create an image from a WBMP stdio file.

gdImageCreateFromWBMP() does not close inFile. The returned image is caller-owned and must be destroyed with gdImageDestroy.

Parameters
inFilePointer to the input FILE stream.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageCreateFromWBMPCtx()

gdImagePtr gdImageCreateFromWBMPCtx ( gdIOCtxPtr  infile)

Create an image from WBMP data read through a gdIOCtx.

gdImageCreateFromWBMPCtx() does not close infile. The returned image is caller-owned and must be destroyed with gdImageDestroy.

Parameters
infilePointer to the gdIOCtx input context.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageCreateFromWBMPPtr()

gdImagePtr gdImageCreateFromWBMPPtr ( int  size,
void *  data 
)

Create an image from a WBMP memory buffer.

The data buffer is borrowed for the duration of the call. The returned image is caller-owned and must be destroyed with gdImageDestroy.

Parameters
sizeSize of the WBMP memory buffer in bytes.
dataPointer to the WBMP memory buffer.
Returns
Returns a gdImagePtr on success, or NULL on failure.

◆ gdImageWBMP()

void gdImageWBMP ( gdImagePtr  image,
int  fg,
FILE *  out 
)

Write an image as WBMP data to a stdio file.

gdImageWBMP() does not close out. The image is borrowed for the duration of the call. Pixels whose color equals fg are written as black; all other pixels are written as white.

Parameters
imageThe image to write.
fgForeground color value to write as black.
outPointer to the output FILE stream.

◆ gdImageWBMPCtx()

void gdImageWBMPCtx ( gdImagePtr  image,
int  fg,
gdIOCtxPtr  out 
)

Write an image as WBMP data to a gdIOCtx.

gdImageWBMPCtx() does not close out. The image is borrowed for the duration of the call. Pixels whose color equals fg are written as black; all other pixels are written as white.

Parameters
imageThe image to write.
fgForeground color value to write as black.
outPointer to the gdIOCtx output context.

◆ gdImageWBMPPtr()

void * gdImageWBMPPtr ( gdImagePtr  im,
int *  size,
int  fg 
)

Write an image as WBMP data to a newly allocated memory buffer.

The image is borrowed for the duration of the call. Pixels whose color equals fg are written as black; all other pixels are written as white. The returned buffer is caller-owned and must be freed with gdFree().

Parameters
imThe image to write.
sizePointer to an integer that receives the returned buffer size.
fgForeground color value to write as black.
Returns
Returns a pointer to the newly allocated WBMP buffer, or NULL on failure.