Back to index

php5  5.3.10
Functions
gd_wbmp.c File Reference
#include <gd.h>
#include <gdfonts.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "wbmp.h"

Go to the source code of this file.

Functions

void gd_putout (int i, void *out)
int gd_getin (void *in)
void gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx *out)
gdImagePtr gdImageCreateFromWBMPCtx (gdIOCtx *infile)
gdImagePtr gdImageCreateFromWBMP (FILE *inFile)
gdImagePtr gdImageCreateFromWBMPPtr (int size, void *data)
void gdImageWBMP (gdImagePtr im, int fg, FILE *outFile)
void * gdImageWBMPPtr (gdImagePtr im, int *size, int fg)

Function Documentation

int gd_getin ( void *  in)

Definition at line 79 of file gd_wbmp.c.

{
       return (gdGetC((gdIOCtx *) in));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gd_putout ( int  i,
void *  out 
)

Definition at line 68 of file gd_wbmp.c.

{
       gdPutC(i, (gdIOCtx *) out);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageCreateFromWBMP ( FILE *  inFile)

Definition at line 169 of file gd_wbmp.c.

{
       gdImagePtr im;
       gdIOCtx *in = gdNewFileCtx(inFile);
       im = gdImageCreateFromWBMPCtx(in);
       in->gd_free(in);

       return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 127 of file gd_wbmp.c.

{
       /* FILE *wbmp_file; */
       Wbmp *wbmp;
       gdImagePtr im = NULL;
       int black, white;
       int col, row, pos;

       if (readwbmp (&gd_getin, infile, &wbmp)) {
              return NULL;
       }

       if (!(im = gdImageCreate (wbmp->width, wbmp->height))) {
              freewbmp (wbmp);
              return NULL;
       }

       /* create the background color */
       white = gdImageColorAllocate(im, 255, 255, 255);
       /* create foreground color */
       black = gdImageColorAllocate(im, 0, 0, 0);

       /* fill in image (in a wbmp 1 = white/ 0 = black) */
       pos = 0;
       for (row = 0; row < wbmp->height; row++) {
              for (col = 0; col < wbmp->width; col++) {
                     if (wbmp->bitmap[pos++] == WBMP_WHITE) {
                            gdImageSetPixel(im, col, row, white);
                     } else {
                            gdImageSetPixel(im, col, row, black);
                     }
              }
       }

       freewbmp(wbmp);

       return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageCreateFromWBMPPtr ( int  size,
void *  data 
)

Definition at line 179 of file gd_wbmp.c.

{
       gdImagePtr im;
       gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0);
       im = gdImageCreateFromWBMPCtx(in);
       in->gd_free(in);
       return im;
}

Here is the call graph for this function:

void gdImageWBMP ( gdImagePtr  im,
int  fg,
FILE *  outFile 
)

Definition at line 191 of file gd_wbmp.c.

{
       gdIOCtx *out = gdNewFileCtx(outFile);
       gdImageWBMPCtx(im, fg, out);
       out->gd_free(out);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 94 of file gd_wbmp.c.

{
       int x, y, pos;
       Wbmp *wbmp;

       /* create the WBMP */
       if ((wbmp = createwbmp (gdImageSX (image), gdImageSY (image), WBMP_WHITE)) == NULL) {
              php_gd_error("Could not create WBMP");
       }

       /* fill up the WBMP structure */
       pos = 0;
       for (y = 0; y < gdImageSY(image); y++) {
              for (x = 0; x < gdImageSX(image); x++) {
                     if (gdImageGetPixel (image, x, y) == fg) {
                            wbmp->bitmap[pos] = WBMP_BLACK;
                     }
                     pos++;
              }
       }

       /* write the WBMP to a gd file descriptor */
       if (writewbmp (wbmp, &gd_putout, out)) {
              php_gd_error("Could not save WBMP");
       }
       /* des submitted this bugfix: gdFree the memory. */
       freewbmp(wbmp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 201 of file gd_wbmp.c.

{
       void *rv;
       gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
       gdImageWBMPCtx(im, fg, out);
       rv = gdDPExtractData(out, size);
       out->gd_free(out);

       return rv;
}

Here is the call graph for this function: