Back to index

tetex-bin  3.0
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)
 BGD_DECLARE (void)
 BGD_DECLARE (gdImagePtr)
 gdImageWBMPPtr (gdImagePtr im, int *size, int fg)

Function Documentation

Definition at line 102 of file gd_wbmp.c.

{

  int x, y, pos;
  Wbmp *wbmp;


  /* create the WBMP */
  if ((wbmp =
       createwbmp (gdImageSX (image), gdImageSY (image), WBMP_WHITE)) == NULL)
    fprintf (stderr, "Could not create WBMP\n");

  /* 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))
    fprintf (stderr, "Could not save WBMP\n");
  /* des submitted this bugfix: gdFree the memory. */
  freewbmp (wbmp);
}

Here is the call graph for this function:

Definition at line 140 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:

int gd_getin ( void in)

Definition at line 87 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 75 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:

gdImageWBMPPtr ( gdImagePtr  im,
int size,
int  fg 
)

Definition at line 220 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;
}