Back to index

plt-scheme  4.2.1
Classes | Defines | Typedefs | Functions
gd.h File Reference
#include <stdio.h>
#include "gd_io.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  gdImageStruct
struct  gdFont
struct  gdSource
struct  gdFTStringExtra
struct  gdPoint
struct  gdSink

Defines

#define DEFAULT_FONTPATH   "/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/TrueType:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1"
#define PATHSEPARATOR   ":"
#define gdMaxColors   256
#define gdAlphaMax   127
#define gdAlphaOpaque   0
#define gdAlphaTransparent   127
#define gdRedMax   255
#define gdGreenMax   255
#define gdBlueMax   255
#define gdTrueColorGetAlpha(c)   (((c) & 0x7F000000) >> 24)
#define gdTrueColorGetRed(c)   (((c) & 0xFF0000) >> 16)
#define gdTrueColorGetGreen(c)   (((c) & 0x00FF00) >> 8)
#define gdTrueColorGetBlue(c)   ((c) & 0x0000FF)
#define gdDashSize   4
#define gdStyled   (-2)
#define gdBrushed   (-3)
#define gdStyledBrushed   (-4)
#define gdTiled   (-5)
#define gdTransparent   (-6)
#define gdAntiAliased   (-7)
#define gdImageCreatePalette   gdImageCreate
#define gdFTEX_LINESPACE   1
#define gdFTEX_CHARMAP   2
#define gdFTEX_Unicode   0
#define gdFTEX_Shift_JIS   1
#define gdFTEX_Big5   2
#define gdTrueColor(r, g, b)
#define gdTrueColorAlpha(r, g, b, a)
#define gdArc   0
#define gdPie   gdArc
#define gdChord   1
#define gdNoFill   2
#define gdEdged   4
#define gdImageTrueColor(im)   ((im)->trueColor)
#define gdImageSX(im)   ((im)->sx)
#define gdImageSY(im)   ((im)->sy)
#define gdImageColorsTotal(im)   ((im)->colorsTotal)
#define gdImageRed(im, c)
#define gdImageGreen(im, c)
#define gdImageBlue(im, c)
#define gdImageAlpha(im, c)
#define gdImageGetTransparent(im)   ((im)->transparent)
#define gdImageGetInterlaced(im)   ((im)->interlace)
#define gdImagePalettePixel(im, x, y)   (im)->pixels[(y)][(x)]
#define gdImageTrueColorPixel(im, x, y)   (im)->tpixels[(y)][(x)]
#define GD2_CHUNKSIZE   128
#define GD2_CHUNKSIZE_MIN   64
#define GD2_CHUNKSIZE_MAX   4096
#define GD2_VERS   2
#define GD2_ID   "gd2"
#define GD2_FMT_RAW   1
#define GD2_FMT_COMPRESSED   2
#define GD_CMP_IMAGE   1 /* Actual image IS different */
#define GD_CMP_NUM_COLORS   2 /* Number of Colours in pallette differ */
#define GD_CMP_COLOR   4 /* Image colours differ */
#define GD_CMP_SIZE_X   8 /* Image width differs */
#define GD_CMP_SIZE_Y   16 /* Image heights differ */
#define GD_CMP_TRANSPARENT   32 /* Transparent colour */
#define GD_CMP_BACKGROUND   64 /* Background colour */
#define GD_CMP_INTERLACE   128 /* Interlaced setting */
#define GD_CMP_TRUECOLOR   256 /* Truecolor vs palette differs */
#define GD_RESOLUTION   96 /* pixels per inch */

Typedefs

typedef struct gdImageStruct gdImage
typedef gdImagegdImagePtr
typedef gdFontgdFontPtr
typedef struct gdSourcegdSourcePtr
typedef struct gdFTStringExtragdFTStringExtraPtr
typedef struct gdPointgdPointPtr
typedef struct gdSinkgdSinkPtr

Functions

int gdAlphaBlend (int dest, int src)
gdImagePtr gdImageCreate (int sx, int sy)
gdImagePtr gdImageCreateTrueColor (int sx, int sy)
gdImagePtr gdImageCreateFromPng (FILE *fd)
gdImagePtr gdImageCreateFromPngCtx (gdIOCtxPtr in)
gdImagePtr gdImageCreateFromWBMP (FILE *inFile)
gdImagePtr gdImageCreateFromWBMPCtx (gdIOCtx *infile)
gdImagePtr gdImageCreateFromJpeg (FILE *infile)
gdImagePtr gdImageCreateFromJpegCtx (gdIOCtx *infile)
gdImagePtr gdImageCreateFromPngSource (gdSourcePtr in)
gdImagePtr gdImageCreateFromGd (FILE *in)
gdImagePtr gdImageCreateFromGdCtx (gdIOCtxPtr in)
gdImagePtr gdImageCreateFromGd2 (FILE *in)
gdImagePtr gdImageCreateFromGd2Ctx (gdIOCtxPtr in)
gdImagePtr gdImageCreateFromGd2Part (FILE *in, int srcx, int srcy, int w, int h)
gdImagePtr gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy, int w, int h)
gdImagePtr gdImageCreateFromXpm (char *filename)
gdImagePtr gdImageCreateFromXbm (FILE *in)
void gdImageDestroy (gdImagePtr im)
void gdImageSetPixel (gdImagePtr im, int x, int y, int color)
int gdImageGetPixel (gdImagePtr im, int x, int y)
void gdImageAABlend (gdImagePtr im)
void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
void gdImageSetClip (gdImagePtr im, int x1, int y1, int x2, int y2)
void gdImageGetClip (gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P)
int gdImageBoundsSafe (gdImagePtr im, int x, int y)
void gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
void gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c, int color)
void gdImageString (gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color)
void gdImageStringUp (gdImagePtr im, gdFontPtr f, int x, int y, unsigned char *s, int color)
void gdImageString16 (gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color)
void gdImageStringUp16 (gdImagePtr im, gdFontPtr f, int x, int y, unsigned short *s, int color)
void gdFreeFontCache ()
char * gdImageStringTTF (gdImage *im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string)
char * gdImageStringFT (gdImage *im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string)
char * gdImageStringFTEx (gdImage *im, int *brect, int fg, char *fontlist, double ptsize, double angle, int x, int y, char *string, gdFTStringExtraPtr strex)
void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
void gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c)
int gdImageColorAllocate (gdImagePtr im, int r, int g, int b)
int gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a)
int gdImageColorClosest (gdImagePtr im, int r, int g, int b)
int gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, int a)
int gdImageColorClosestHWB (gdImagePtr im, int r, int g, int b)
int gdImageColorExact (gdImagePtr im, int r, int g, int b)
int gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a)
int gdImageColorResolve (gdImagePtr im, int r, int g, int b)
int gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a)
void gdImageColorDeallocate (gdImagePtr im, int color)
void gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag, int colorsWanted)
void gdImageColorTransparent (gdImagePtr im, int color)
void gdImagePaletteCopy (gdImagePtr dst, gdImagePtr src)
void gdImagePng (gdImagePtr im, FILE *out)
void gdImagePngCtx (gdImagePtr im, gdIOCtx *out)
void gdImagePngEx (gdImagePtr im, FILE *out, int level)
void gdImagePngCtxEx (gdImagePtr im, gdIOCtx *out, int level)
void gdImageWBMP (gdImagePtr image, int fg, FILE *out)
void gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx *out)
void gdFree (void *m)
voidgdImageWBMPPtr (gdImagePtr im, int *size, int fg)
void gdImageJpeg (gdImagePtr im, FILE *out, int quality)
void gdImageJpegCtx (gdImagePtr im, gdIOCtx *out, int quality)
voidgdImageJpegPtr (gdImagePtr im, int *size, int quality)
void gdImagePngToSink (gdImagePtr im, gdSinkPtr out)
void gdImageGd (gdImagePtr im, FILE *out)
void gdImageGd2 (gdImagePtr im, FILE *out, int cs, int fmt)
voidgdImagePngPtr (gdImagePtr im, int *size)
voidgdImagePngPtrEx (gdImagePtr im, int *size, int level)
voidgdImageGdPtr (gdImagePtr im, int *size)
voidgdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
void gdImageEllipse (gdImagePtr im, int cx, int cy, int w, int h, int color)
void gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)
void gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)
void gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h, int color)
void gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)
void gdImageFill (gdImagePtr im, int x, int y, int color)
void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
void gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
void gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
void gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
void gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
void gdImageCopyRotated (gdImagePtr dst, gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle)
void gdImageSetBrush (gdImagePtr im, gdImagePtr brush)
void gdImageSetTile (gdImagePtr im, gdImagePtr tile)
void gdImageSetAntiAliased (gdImagePtr im, int c)
void gdImageSetAntiAliasedDontBlend (gdImagePtr im, int c, int dont_blend)
void gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels)
void gdImageSetThickness (gdImagePtr im, int thickness)
void gdImageInterlace (gdImagePtr im, int interlaceArg)
void gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg)
void gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg)
gdIOCtxgdNewFileCtx (FILE *)
gdIOCtxgdNewDynamicCtx (int, void *)
gdIOCtxgdNewSSCtx (gdSourcePtr in, gdSinkPtr out)
voidgdDPExtractData (struct gdIOCtx *ctx, int *size)
int gdImageCompare (gdImagePtr im1, gdImagePtr im2)

Class Documentation

struct gdImageStruct

Definition at line 78 of file gd.h.

Collaboration diagram for gdImageStruct:
Class Members
int AA
int AA_color
int AA_dont_blend
unsigned char ** AA_opacity
int AA_polygon
int AAL_Bx_Ax
int AAL_By_Ay
float AAL_LAB
int AAL_LAB_2
int AAL_x1
int AAL_x2
int AAL_y1
int AAL_y2
int alpha
int alphaBlendingFlag
int blue
struct gdImageStruct * brush
int brushColorMap
int colorsTotal
int cx1
int cx2
int cy1
int cy2
int green
int interlace
int open
unsigned char ** pixels
int polyAllocated
int * polyInts
int red
int saveAlphaFlag
int * style
int styleLength
int stylePos
int sx
int sy
int thick
struct gdImageStruct * tile
int tileColorMap
int ** tpixels
int transparent
int trueColor
struct gdFont

Definition at line 169 of file gd.h.

Class Members
char * data
int h
int nchars
int offset
int w
struct gdFTStringExtra

Definition at line 317 of file gd.h.

Class Members
int charmap
int flags
double linespacing
struct gdPoint

Definition at line 342 of file gd.h.

Class Members
int x
int y

Define Documentation

#define DEFAULT_FONTPATH   "/usr/X11R6/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/truetype:/usr/X11R6/lib/X11/fonts/TTF:/usr/share/fonts/TrueType:/usr/share/fonts/truetype:/usr/openwin/lib/X11/fonts/TrueType:/usr/X11R6/lib/X11/fonts/Type1"

Definition at line 12 of file gd.h.

#define GD2_CHUNKSIZE   128

Definition at line 596 of file gd.h.

#define GD2_CHUNKSIZE_MAX   4096

Definition at line 598 of file gd.h.

#define GD2_CHUNKSIZE_MIN   64

Definition at line 597 of file gd.h.

#define GD2_FMT_COMPRESSED   2

Definition at line 604 of file gd.h.

#define GD2_FMT_RAW   1

Definition at line 603 of file gd.h.

#define GD2_ID   "gd2"

Definition at line 601 of file gd.h.

#define GD2_VERS   2

Definition at line 600 of file gd.h.

#define GD_CMP_BACKGROUND   64 /* Background colour */

Definition at line 615 of file gd.h.

#define GD_CMP_COLOR   4 /* Image colours differ */

Definition at line 611 of file gd.h.

#define GD_CMP_IMAGE   1 /* Actual image IS different */

Definition at line 609 of file gd.h.

#define GD_CMP_INTERLACE   128 /* Interlaced setting */

Definition at line 616 of file gd.h.

#define GD_CMP_NUM_COLORS   2 /* Number of Colours in pallette differ */

Definition at line 610 of file gd.h.

#define GD_CMP_SIZE_X   8 /* Image width differs */

Definition at line 612 of file gd.h.

#define GD_CMP_SIZE_Y   16 /* Image heights differ */

Definition at line 613 of file gd.h.

#define GD_CMP_TRANSPARENT   32 /* Transparent colour */

Definition at line 614 of file gd.h.

#define GD_CMP_TRUECOLOR   256 /* Truecolor vs palette differs */

Definition at line 617 of file gd.h.

#define GD_RESOLUTION   96 /* pixels per inch */

Definition at line 620 of file gd.h.

#define gdAlphaMax   127

Definition at line 60 of file gd.h.

#define gdAlphaOpaque   0

Definition at line 61 of file gd.h.

#define gdAlphaTransparent   127

Definition at line 62 of file gd.h.

#define gdAntiAliased   (-7)

Definition at line 204 of file gd.h.

#define gdArc   0

Definition at line 491 of file gd.h.

#define gdBlueMax   255

Definition at line 65 of file gd.h.

#define gdBrushed   (-3)

Definition at line 196 of file gd.h.

#define gdChord   1

Definition at line 493 of file gd.h.

#define gdDashSize   4

Definition at line 191 of file gd.h.

#define gdEdged   4

Definition at line 495 of file gd.h.

#define gdFTEX_Big5   2

Definition at line 335 of file gd.h.

#define gdFTEX_CHARMAP   2

Definition at line 329 of file gd.h.

#define gdFTEX_LINESPACE   1

Definition at line 328 of file gd.h.

#define gdFTEX_Shift_JIS   1

Definition at line 334 of file gd.h.

#define gdFTEX_Unicode   0

Definition at line 333 of file gd.h.

#define gdGreenMax   255

Definition at line 64 of file gd.h.

#define gdImageAlpha (   im,
 
)
Value:
((im)->trueColor ? gdTrueColorGetAlpha(c) : \
       (im)->alpha[(c)])

Definition at line 576 of file gd.h.

#define gdImageBlue (   im,
 
)
Value:
((im)->trueColor ? gdTrueColorGetBlue(c) : \
       (im)->blue[(c)])

Definition at line 574 of file gd.h.

#define gdImageColorsTotal (   im)    ((im)->colorsTotal)

Definition at line 569 of file gd.h.

Definition at line 212 of file gd.h.

#define gdImageGetInterlaced (   im)    ((im)->interlace)

Definition at line 579 of file gd.h.

#define gdImageGetTransparent (   im)    ((im)->transparent)

Definition at line 578 of file gd.h.

#define gdImageGreen (   im,
 
)
Value:
((im)->trueColor ? gdTrueColorGetGreen(c) : \
       (im)->green[(c)])

Definition at line 572 of file gd.h.

#define gdImagePalettePixel (   im,
  x,
  y 
)    (im)->pixels[(y)][(x)]

Definition at line 586 of file gd.h.

#define gdImageRed (   im,
 
)
Value:
((im)->trueColor ? gdTrueColorGetRed(c) : \
       (im)->red[(c)])

Definition at line 570 of file gd.h.

#define gdImageSX (   im)    ((im)->sx)

Definition at line 567 of file gd.h.

#define gdImageSY (   im)    ((im)->sy)

Definition at line 568 of file gd.h.

#define gdImageTrueColor (   im)    ((im)->trueColor)

Definition at line 565 of file gd.h.

#define gdImageTrueColorPixel (   im,
  x,
  y 
)    (im)->tpixels[(y)][(x)]

Definition at line 587 of file gd.h.

#define gdMaxColors   256

Definition at line 37 of file gd.h.

#define gdNoFill   2

Definition at line 494 of file gd.h.

#define gdPie   gdArc

Definition at line 492 of file gd.h.

#define gdRedMax   255

Definition at line 63 of file gd.h.

#define gdStyled   (-2)

Definition at line 195 of file gd.h.

#define gdStyledBrushed   (-4)

Definition at line 197 of file gd.h.

#define gdTiled   (-5)

Definition at line 198 of file gd.h.

#define gdTransparent   (-6)

Definition at line 202 of file gd.h.

#define gdTrueColor (   r,
  g,
  b 
)
Value:
(((r) << 16) + \
       ((g) << 8) + \
       (b))

Definition at line 377 of file gd.h.

#define gdTrueColorAlpha (   r,
  g,
  b,
  a 
)
Value:
(((a) << 24) + \
       ((r) << 16) + \
       ((g) << 8) + \
       (b))

Definition at line 385 of file gd.h.

#define gdTrueColorGetAlpha (   c)    (((c) & 0x7F000000) >> 24)

Definition at line 66 of file gd.h.

#define gdTrueColorGetBlue (   c)    ((c) & 0x0000FF)

Definition at line 69 of file gd.h.

#define gdTrueColorGetGreen (   c)    (((c) & 0x00FF00) >> 8)

Definition at line 68 of file gd.h.

#define gdTrueColorGetRed (   c)    (((c) & 0xFF0000) >> 16)

Definition at line 67 of file gd.h.

#define PATHSEPARATOR   ":"

Definition at line 15 of file gd.h.


Typedef Documentation

typedef gdFont* gdFontPtr

Definition at line 186 of file gd.h.

typedef gdImage* gdImagePtr

Definition at line 167 of file gd.h.

typedef struct gdSink * gdSinkPtr

Function Documentation

int gdAlphaBlend ( int  dest,
int  src 
)

Definition at line 3040 of file gd.c.

{
  /* 2.0.12: TBB: alpha in the destination should be a 
     component of the result. Thanks to Frank Warmerdam for
     pointing out the issue. */
  return ((((gdTrueColorGetAlpha (src) *
            gdTrueColorGetAlpha (dst)) / gdAlphaMax) << 24) +
         ((((gdAlphaTransparent - gdTrueColorGetAlpha (src)) *
            gdTrueColorGetRed (src) / gdAlphaMax) +
           (gdTrueColorGetAlpha (src) *
            gdTrueColorGetRed (dst)) / gdAlphaMax) << 16) +
         ((((gdAlphaTransparent - gdTrueColorGetAlpha (src)) *
            gdTrueColorGetGreen (src) / gdAlphaMax) +
           (gdTrueColorGetAlpha (src) *
            gdTrueColorGetGreen (dst)) / gdAlphaMax) << 8) +
         (((gdAlphaTransparent - gdTrueColorGetAlpha (src)) *
           gdTrueColorGetBlue (src) / gdAlphaMax) +
          (gdTrueColorGetAlpha (src) *
           gdTrueColorGetBlue (dst)) / gdAlphaMax));
}

Here is the caller graph for this function:

void* gdDPExtractData ( struct gdIOCtx ctx,
int size 
)

Definition at line 107 of file gd_io_dp.c.

{
  dynamicPtr *dp;
  dpIOCtx *dctx;
  void *data;

  dctx = (dpIOCtx *) ctx;
  dp = dctx->dp;

  /* clean up the data block and return it */
  if (dp->dataGood)
    {
      trimDynamic (dp);
      *size = dp->logicalSize;
      data = dp->data;
    }
  else
    {
      *size = 0;
      data = NULL;
      if (dp->data != NULL)
       {
         gdFree (dp->data);
       }
    }

  dp->data = NULL;
  dp->realSize = 0;
  dp->logicalSize = 0;

  return data;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdFree ( void m)

Definition at line 98 of file gdhelpers.c.

{
  free (ptr);
}

Here is the caller graph for this function:

Definition at line 1038 of file gd.c.

{
  float p_alpha, old_alpha;
  int color = im->AA_color, color_red, color_green, color_blue;
  int old_color, old_red, old_green, old_blue;
  int p_color, p_red, p_green, p_blue;
  int px, py;

  color_red = gdImageRed (im, color);
  color_green = gdImageGreen (im, color);
  color_blue = gdImageBlue (im, color);

  /* Impose the anti-aliased drawing on the image. */
  for (py = 0; py < im->sy; py++)
    {
      for (px = 0; px < im->sx; px++)
       {
         if (im->AA_opacity[py][px] != 0)
           {
             old_color = gdImageGetPixel (im, px, py);

             if ((old_color != color)
                && ((old_color != im->AA_dont_blend)
                    || (im->AA_opacity[py][px] == 255)))
              {
                /* Only blend with different colors that aren't the 
                 * dont_blend color. */
                p_alpha = (float) (im->AA_opacity[py][px]) / 255.0;
                old_alpha = 1.0 - p_alpha;

                if (p_alpha >= 1.0)
                  p_color = color;
                else
                  {
                    old_red = gdImageRed (im, old_color);
                    old_green = gdImageGreen (im, old_color);
                    old_blue = gdImageBlue (im, old_color);

                    p_red = (int) (((float) color_red * p_alpha) +
                                 ((float) old_red * old_alpha));
                    p_green = (int) (((float) color_green * p_alpha) +
                                   ((float) old_green * old_alpha));
                    p_blue = (int) (((float) color_blue * p_alpha) +
                                  ((float) old_blue * old_alpha));
                    p_color =
                     gdImageColorResolve (im, p_red, p_green, p_blue);
                  }
                gdImageSetPixel (im, px, py, p_color);
              }
           }
       }
      /* Clear the AA_opacity array behind us. */
      memset (im->AA_opacity[py], 0, im->sx);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageAlphaBlending ( gdImagePtr  im,
int  alphaBlendingArg 
)

Definition at line 3062 of file gd.c.

{
  im->alphaBlendingFlag = alphaBlendingArg;
}
void gdImageArc ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  s,
int  e,
int  color 
)

Definition at line 1650 of file gd.c.

{
  gdImageFilledArc (im, cx, cy, w, h, s, e, color, gdNoFill);
}

Here is the call graph for this function:

int gdImageBoundsSafe ( gdImagePtr  im,
int  x,
int  y 
)

Definition at line 1493 of file gd.c.

{
  return gdImageBoundsSafeMacro (im, x, y);
}
void gdImageChar ( gdImagePtr  im,
gdFontPtr  f,
int  x,
int  y,
int  c,
int  color 
)

Definition at line 1499 of file gd.c.

{
  int cx, cy;
  int px, py;
  int fline;
  cx = 0;
  cy = 0;
#ifdef CHARSET_EBCDIC
  c = ASC (c);
#endif /*CHARSET_EBCDIC */
  if ((c < f->offset) || (c >= (f->offset + f->nchars)))
    {
      return;
    }
  fline = (c - f->offset) * f->h * f->w;
  for (py = y; (py < (y + f->h)); py++)
    {
      for (px = x; (px < (x + f->w)); px++)
       {
         if (f->data[fline + cy * f->w + cx])
           {
             gdImageSetPixel (im, px, py, color);
           }
         cx++;
       }
      cx = 0;
      cy++;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageCharUp ( gdImagePtr  im,
gdFontPtr  f,
int  x,
int  y,
int  c,
int  color 
)

Definition at line 1530 of file gd.c.

{
  int cx, cy;
  int px, py;
  int fline;
  cx = 0;
  cy = 0;
#ifdef CHARSET_EBCDIC
  c = ASC (c);
#endif /*CHARSET_EBCDIC */
  if ((c < f->offset) || (c >= (f->offset + f->nchars)))
    {
      return;
    }
  fline = (c - f->offset) * f->h * f->w;
  for (py = y; (py > (y - f->w)); py--)
    {
      for (px = x; (px < (x + f->h)); px++)
       {
         if (f->data[fline + cy * f->w + cx])
           {
             gdImageSetPixel (im, px, py, color);
           }
         cy++;
       }
      cy = 0;
      cx++;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageColorAllocate ( gdImagePtr  im,
int  r,
int  g,
int  b 
)

Definition at line 444 of file gd.c.

{
  return gdImageColorAllocateAlpha (im, r, g, b, gdAlphaOpaque);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageColorAllocateAlpha ( gdImagePtr  im,
int  r,
int  g,
int  b,
int  a 
)

Definition at line 450 of file gd.c.

{
  int i;
  int ct = (-1);
  if (im->trueColor)
    {
      return gdTrueColorAlpha (r, g, b, a);
    }
  for (i = 0; (i < (im->colorsTotal)); i++)
    {
      if (im->open[i])
       {
         ct = i;
         break;
       }
    }
  if (ct == (-1))
    {
      ct = im->colorsTotal;
      if (ct == gdMaxColors)
       {
         return -1;
       }
      im->colorsTotal++;
    }
  im->red[ct] = r;
  im->green[ct] = g;
  im->blue[ct] = b;
  im->alpha[ct] = a;
  im->open[ct] = 0;
  return ct;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageColorClosest ( gdImagePtr  im,
int  r,
int  g,
int  b 
)

Definition at line 202 of file gd.c.

{
  return gdImageColorClosestAlpha (im, r, g, b, gdAlphaOpaque);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageColorClosestAlpha ( gdImagePtr  im,
int  r,
int  g,
int  b,
int  a 
)

Definition at line 208 of file gd.c.

{
  int i;
  long rd, gd, bd, ad;
  int ct = (-1);
  int first = 1;
  long mindist = 0;
  if (im->trueColor)
    {
      return gdTrueColorAlpha (r, g, b, a);
    }
  for (i = 0; (i < (im->colorsTotal)); i++)
    {
      long dist;
      if (im->open[i])
       {
         continue;
       }
      rd = (im->red[i] - r);
      gd = (im->green[i] - g);
      bd = (im->blue[i] - b);
      /* gd 2.02: whoops, was - b (thanks to David Marwood) */
      ad = (im->blue[i] - a);
      dist = rd * rd + gd * gd + bd * bd + ad * ad;
      if (first || (dist < mindist))
       {
         mindist = dist;
         ct = i;
         first = 0;
       }
    }
  return ct;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageColorClosestHWB ( gdImagePtr  im,
int  r,
int  g,
int  b 
)

Definition at line 385 of file gd.c.

{
  int i;
  /* long rd, gd, bd; */
  int ct = (-1);
  int first = 1;
  float mindist = 0;
  if (im->trueColor)
    {
      return gdTrueColor (r, g, b);
    }
  for (i = 0; (i < (im->colorsTotal)); i++)
    {
      float dist;
      if (im->open[i])
       {
         continue;
       }
      dist = HWB_Diff (im->red[i], im->green[i], im->blue[i], r, g, b);
      if (first || (dist < mindist))
       {
         mindist = dist;
         ct = i;
         first = 0;
       }
    }
  return ct;
}

Here is the call graph for this function:

Definition at line 560 of file gd.c.

{
  if (im->trueColor)
    {
      return;
    }
  /* Mark it open. */
  im->open[color] = 1;
}
int gdImageColorExact ( gdImagePtr  im,
int  r,
int  g,
int  b 
)

Definition at line 415 of file gd.c.

{
  return gdImageColorExactAlpha (im, r, g, b, gdAlphaOpaque);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageColorExactAlpha ( gdImagePtr  im,
int  r,
int  g,
int  b,
int  a 
)

Definition at line 421 of file gd.c.

{
  int i;
  if (im->trueColor)
    {
      return gdTrueColorAlpha (r, g, b, a);
    }
  for (i = 0; (i < (im->colorsTotal)); i++)
    {
      if (im->open[i])
       {
         continue;
       }
      if ((im->red[i] == r) &&
         (im->green[i] == g) && (im->blue[i] == b) && (im->alpha[i] == a))
       {
         return i;
       }
    }
  return -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageColorResolve ( gdImagePtr  im,
int  r,
int  g,
int  b 
)

Definition at line 495 of file gd.c.

{
  return gdImageColorResolveAlpha (im, r, g, b, gdAlphaOpaque);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageColorResolveAlpha ( gdImagePtr  im,
int  r,
int  g,
int  b,
int  a 
)

Definition at line 501 of file gd.c.

{
  int c;
  int ct = -1;
  int op = -1;
  long rd, gd, bd, ad, dist;
  long mindist = 4 * 255 * 255;    /* init to max poss dist */
  if (im->trueColor)
    {
      return gdTrueColorAlpha (r, g, b, a);
    }

  for (c = 0; c < im->colorsTotal; c++)
    {
      if (im->open[c])
       {
         op = c;            /* Save open slot */
         continue;          /* Color not in use */
       }
      if (c == im->transparent)
       {
         /* don't ever resolve to the color that has
          * been designated as the transparent color */
         continue;
       }
      rd = (long) (im->red[c] - r);
      gd = (long) (im->green[c] - g);
      bd = (long) (im->blue[c] - b);
      ad = (long) (im->alpha[c] - a);
      dist = rd * rd + gd * gd + bd * bd + ad * ad;
      if (dist < mindist)
       {
         if (dist == 0)
           {
             return c;             /* Return exact match color */
           }
         mindist = dist;
         ct = c;
       }
    }
  /* no exact match.  We now know closest, but first try to allocate exact */
  if (op == -1)
    {
      op = im->colorsTotal;
      if (op == gdMaxColors)
       {                    /* No room for more colors */
         return ct;         /* Return closest available color */
       }
      im->colorsTotal++;
    }
  im->red[op] = r;
  im->green[op] = g;
  im->blue[op] = b;
  im->alpha[op] = a;
  im->open[op] = 0;
  return op;                /* Return newly allocated color */
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 571 of file gd.c.

{
  if (!im->trueColor)
    {
      if (im->transparent != -1)
       {
         im->alpha[im->transparent] = gdAlphaOpaque;
       }
      if (color != -1)
       {
         im->alpha[color] = gdAlphaTransparent;
       }
    }
  im->transparent = color;
}

Definition at line 2947 of file gd.c.

{
  int x, y;
  int p1, p2;
  int cmpStatus = 0;
  int sx, sy;

  if (im1->interlace != im2->interlace)
    {
      cmpStatus |= GD_CMP_INTERLACE;
    }

  if (im1->transparent != im2->transparent)
    {
      cmpStatus |= GD_CMP_TRANSPARENT;
    }

  if (im1->trueColor != im2->trueColor)
    {
      cmpStatus |= GD_CMP_TRUECOLOR;
    }

  sx = im1->sx;
  if (im1->sx != im2->sx)
    {
      cmpStatus |= GD_CMP_SIZE_X + GD_CMP_IMAGE;
      if (im2->sx < im1->sx)
       {
         sx = im2->sx;
       }
    }

  sy = im1->sy;
  if (im1->sy != im2->sy)
    {
      cmpStatus |= GD_CMP_SIZE_Y + GD_CMP_IMAGE;
      if (im2->sy < im1->sy)
       {
         sy = im2->sy;
       }
    }

  if (im1->colorsTotal != im2->colorsTotal)
    {
      cmpStatus |= GD_CMP_NUM_COLORS;
    }

  for (y = 0; (y < sy); y++)
    {
      for (x = 0; (x < sx); x++)
       {
         p1 =
           im1->trueColor ? gdImageTrueColorPixel (im1, x,
                                              y) :
           gdImagePalettePixel (im1, x, y);
         p2 =
           im2->trueColor ? gdImageTrueColorPixel (im2, x,
                                              y) :
           gdImagePalettePixel (im2, x, y);
         if (gdImageRed (im1, p1) != gdImageRed (im2, p2))
           {
             cmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;
             break;
           }
         if (gdImageGreen (im1, p1) != gdImageGreen (im2, p2))
           {
             cmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;
             break;
           }
         if (gdImageBlue (im1, p1) != gdImageBlue (im2, p2))
           {
             cmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;
             break;
           }
#if 0
         /* Soon we'll add alpha channel to palettes */
         if (gdImageAlpha (im1, p1) != gdImageAlpha (im2, p2))
           {
             cmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;
             break;
           }
#endif
       }
      if (cmpStatus & GD_CMP_COLOR)
       {
         break;
       };
    }

  return cmpStatus;
}
void gdImageCopy ( gdImagePtr  dst,
gdImagePtr  src,
int  dstX,
int  dstY,
int  srcX,
int  srcY,
int  w,
int  h 
)

Definition at line 2015 of file gd.c.

{
  int c;
  int x, y;
  int tox, toy;
  int i;
  int colorMap[gdMaxColors];
  if (dst->trueColor)
    {
      /* 2.0: much easier when the destination is truecolor. */
      /* 2.0.10: needs a transparent-index check that is still valid if
         the source is not truecolor. Thanks to Frank Warmerdam. */
      for (y = 0; (y < h); y++)
       {
         for (x = 0; (x < w); x++)
           {
             int p = gdImageGetPixel (src, srcX + x, srcY + y);
             if (p != src->transparent)
              {
                int c = gdImageGetTrueColorPixel (src, srcX + x,
                                              srcY + y);
                gdImageSetPixel (dst, dstX + x, dstY + y, c);
              }
           }
       }
      return;
    }
  for (i = 0; (i < gdMaxColors); i++)
    {
      colorMap[i] = (-1);
    }
  toy = dstY;
  for (y = srcY; (y < (srcY + h)); y++)
    {
      tox = dstX;
      for (x = srcX; (x < (srcX + w)); x++)
       {
         int nc;
         int mapTo;
         c = gdImageGetPixel (src, x, y);
         /* Added 7/24/95: support transparent copies */
         if (gdImageGetTransparent (src) == c)
           {
             tox++;
             continue;
           }
         /* Have we established a mapping for this color? */
         if (src->trueColor)
           {
             /* 2.05: remap to the palette available in the
                destination image. This is slow and
                works badly, but it beats crashing! Thanks 
                to Padhrig McCarthy. */
             mapTo = gdImageColorResolveAlpha (dst,
                                          gdTrueColorGetRed (c),
                                          gdTrueColorGetGreen (c),
                                          gdTrueColorGetBlue (c),
                                          gdTrueColorGetAlpha (c));
           }
         else if (colorMap[c] == (-1))
           {
             /* If it's the same image, mapping is trivial */
             if (dst == src)
              {
                nc = c;
              }
             else
              {
                /* Get best match possible. This
                   function never returns error. */
                nc = gdImageColorResolveAlpha (dst,
                                           src->red[c], src->green[c],
                                           src->blue[c], src->alpha[c]);
              }
             colorMap[c] = nc;
             mapTo = colorMap[c];
           }
         else
           {
             mapTo = colorMap[c];
           }
         gdImageSetPixel (dst, tox, toy, mapTo);
         tox++;
       }
      toy++;
    }
}

Here is the call graph for this function:

void gdImageCopyMerge ( gdImagePtr  dst,
gdImagePtr  src,
int  dstX,
int  dstY,
int  srcX,
int  srcY,
int  w,
int  h,
int  pct 
)

Definition at line 2107 of file gd.c.

{

  int c, dc;
  int x, y;
  int tox, toy;
  int ncR, ncG, ncB;
  toy = dstY;
  for (y = srcY; (y < (srcY + h)); y++)
    {
      tox = dstX;
      for (x = srcX; (x < (srcX + w)); x++)
       {
         int nc;
         c = gdImageGetPixel (src, x, y);
         /* Added 7/24/95: support transparent copies */
         if (gdImageGetTransparent (src) == c)
           {
             tox++;
             continue;
           }
         /* If it's the same image, mapping is trivial */
         if (dst == src)
           {
             nc = c;
           }
         else
           {
             dc = gdImageGetPixel (dst, tox, toy);

             ncR = gdImageRed (src, c) * (pct / 100.0)
              + gdImageRed (dst, dc) * ((100 - pct) / 100.0);
             ncG = gdImageGreen (src, c) * (pct / 100.0)
              + gdImageGreen (dst, dc) * ((100 - pct) / 100.0);
             ncB = gdImageBlue (src, c) * (pct / 100.0)
              + gdImageBlue (dst, dc) * ((100 - pct) / 100.0);

             /* Find a reasonable color */
             nc = gdImageColorResolve (dst, ncR, ncG, ncB);
           }
         gdImageSetPixel (dst, tox, toy, nc);
         tox++;
       }
      toy++;
    }
}

Here is the call graph for this function:

void gdImageCopyMergeGray ( gdImagePtr  dst,
gdImagePtr  src,
int  dstX,
int  dstY,
int  srcX,
int  srcY,
int  w,
int  h,
int  pct 
)

Definition at line 2158 of file gd.c.

{

  int c, dc;
  int x, y;
  int tox, toy;
  int ncR, ncG, ncB;
  float g;
  toy = dstY;
  for (y = srcY; (y < (srcY + h)); y++)
    {
      tox = dstX;
      for (x = srcX; (x < (srcX + w)); x++)
       {
         int nc;
         c = gdImageGetPixel (src, x, y);
         /* Added 7/24/95: support transparent copies */
         if (gdImageGetTransparent (src) == c)
           {
             tox++;
             continue;
           }
         /* 
          * If it's the same image, mapping is NOT trivial since we 
          * merge with greyscale target, but if pct is 100, the grey 
          * value is not used, so it becomes trivial. pjw 2.0.12. 
          */
         if (dst == src && pct == 100)
           {
             nc = c;
           }
         else
           {
             dc = gdImageGetPixel (dst, tox, toy);
             g = 0.29900 * dst->red[dc]
              + 0.58700 * dst->green[dc] + 0.11400 * dst->blue[dc];

             ncR = gdImageRed (src, c) * (pct / 100.0)
              + g * ((100 - pct) / 100.0);
             ncG = gdImageGreen (src, c) * (pct / 100.0)
              + g * ((100 - pct) / 100.0);
             ncB = gdImageBlue (src, c) * (pct / 100.0)
              + g * ((100 - pct) / 100.0);

             /* First look for an exact match */
             nc = gdImageColorExact (dst, ncR, ncG, ncB);
             if (nc == (-1))
              {
                /* No, so try to allocate it */
                nc = gdImageColorAllocate (dst, ncR, ncG, ncB);
                /* If we're out of colors, go for the
                   closest color */
                if (nc == (-1))
                  {
                    nc = gdImageColorClosest (dst, ncR, ncG, ncB);
                  }
              }
           }
         gdImageSetPixel (dst, tox, toy, nc);
         tox++;
       }
      toy++;
    }
}

Here is the call graph for this function:

void gdImageCopyResampled ( gdImagePtr  dst,
gdImagePtr  src,
int  dstX,
int  dstY,
int  srcX,
int  srcY,
int  dstW,
int  dstH,
int  srcW,
int  srcH 
)

Definition at line 2457 of file gd.c.

{
  int x, y;
  if (!dst->trueColor)
    {
      gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH,
                       srcW, srcH);
      return;
    }
  for (y = dstY; (y < dstY + dstH); y++)
    {
      for (x = dstX; (x < dstX + dstW); x++)
       {
         float sy1, sy2, sx1, sx2;
         float sx, sy;
         float spixels = 0;
         float red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
         sy1 = ((float) y - (float) dstY) * (float) srcH / (float) dstH;
         sy2 = ((float) (y + 1) - (float) dstY) * (float) srcH /
           (float) dstH;
         sy = sy1;
         do
           {
             float yportion;
             if (floor2 (sy) == floor2 (sy1))
              {
                yportion = 1.0 - (sy - floor2 (sy));
                if (yportion > sy2 - sy1)
                  {
                    yportion = sy2 - sy1;
                  }
                sy = floor2 (sy);
              }
             else if (sy == floor2 (sy2))
              {
                yportion = sy2 - floor2 (sy2);
              }
             else
              {
                yportion = 1.0;
              }
             sx1 = ((float) x - (float) dstX) * (float) srcW / dstW;
             sx2 = ((float) (x + 1) - (float) dstX) * (float) srcW / dstW;
             sx = sx1;
             do
              {
                float xportion;
                float pcontribution;
                int p;
                if (floor2 (sx) == floor2 (sx1))
                  {
                    xportion = 1.0 - (sx - floor2 (sx));
                    if (xportion > sx2 - sx1)
                     {
                       xportion = sx2 - sx1;
                     }
                    sx = floor2 (sx);
                  }
                else if (sx == floor2 (sx2))
                  {
                    xportion = sx2 - floor2 (sx2);
                  }
                else
                  {
                    xportion = 1.0;
                  }
                pcontribution = xportion * yportion;
                /* 2.08: previously srcX and srcY were ignored. 
                   Andrew Pattison */
                p = gdImageGetTrueColorPixel (src,
                                          (int) sx + srcX,
                                          (int) sy + srcY);
                red += gdTrueColorGetRed (p) * pcontribution;
                green += gdTrueColorGetGreen (p) * pcontribution;
                blue += gdTrueColorGetBlue (p) * pcontribution;
                alpha += gdTrueColorGetAlpha (p) * pcontribution;
                spixels += xportion * yportion;
                sx += 1.0;
              }
             while (sx < sx2);
             sy += 1.0;
           }
         while (sy < sy2);
         if (spixels != 0.0)
           {
             red /= spixels;
             green /= spixels;
             blue /= spixels;
             alpha /= spixels;
           }
         /* Clamping to allow for rounding errors above */
         if (red > 255.0)
           {
             red = 255.0;
           }
         if (green > 255.0)
           {
             green = 255.0;
           }
         if (blue > 255.0)
           {
             blue = 255.0;
           }
         if (alpha > gdAlphaMax)
           {
             alpha = gdAlphaMax;
           }
         gdImageSetPixel (dst,
                        x, y,
                        gdTrueColorAlpha ((int) red,
                                        (int) green,
                                        (int) blue, (int) alpha));
       }
    }
}

Here is the call graph for this function:

void gdImageCopyResized ( gdImagePtr  dst,
gdImagePtr  src,
int  dstX,
int  dstY,
int  srcX,
int  srcY,
int  dstW,
int  dstH,
int  srcW,
int  srcH 
)

Definition at line 2225 of file gd.c.

{
  int c;
  int x, y;
  int tox, toy;
  int ydest;
  int i;
  int colorMap[gdMaxColors];
  /* Stretch vectors */
  int *stx;
  int *sty;
  /* We only need to use floating point to determine the correct
     stretch vector for one line's worth. */
  double accum;
  stx = (int *) gdMalloc (sizeof (int) * srcW);
  sty = (int *) gdMalloc (sizeof (int) * srcH);
  accum = 0;
  for (i = 0; (i < srcW); i++)
    {
      int got;
      accum += (double) dstW / (double) srcW;
      got = (int) floor (accum);
      stx[i] = got;
      accum -= got;
    }
  accum = 0;
  for (i = 0; (i < srcH); i++)
    {
      int got;
      accum += (double) dstH / (double) srcH;
      got = (int) floor (accum);
      sty[i] = got;
      accum -= got;
    }
  for (i = 0; (i < gdMaxColors); i++)
    {
      colorMap[i] = (-1);
    }
  toy = dstY;
  for (y = srcY; (y < (srcY + srcH)); y++)
    {
      for (ydest = 0; (ydest < sty[y - srcY]); ydest++)
       {
         tox = dstX;
         for (x = srcX; (x < (srcX + srcW)); x++)
           {
             int nc = 0;
             int mapTo;
             if (!stx[x - srcX])
              {
                continue;
              }
             if (dst->trueColor)
              {
                /* 2.0.9: Thorben Kundinger: Maybe the source image is not 
                   a truecolor image */
                if (!src->trueColor)
                  {
                    int tmp = gdImageGetPixel (src, x, y);
                    mapTo = gdImageGetTrueColorPixel (src, x, y);
                    if (gdImageGetTransparent (src) == tmp)
                     {
                       tox++;
                       continue;
                     }
                  }
                else
                  {
                    /* TK: old code follows */
                    mapTo = gdImageGetTrueColorPixel (src, x, y);
                    /* Added 7/24/95: support transparent copies */
                    if (gdImageGetTransparent (src) == mapTo)
                     {
                       tox++;
                       continue;
                     }
                  }
              }
             else
              {
                c = gdImageGetPixel (src, x, y);
                /* Added 7/24/95: support transparent copies */
                if (gdImageGetTransparent (src) == c)
                  {
                    tox += stx[x - srcX];
                    continue;
                  }
                if (src->trueColor)
                  {
                    /* Remap to the palette available in the
                       destination image. This is slow and
                       works badly. */
                    mapTo = gdImageColorResolveAlpha (dst,
                                                 gdTrueColorGetRed (c),
                                                 gdTrueColorGetGreen
                                                 (c),
                                                 gdTrueColorGetBlue
                                                 (c),
                                                 gdTrueColorGetAlpha
                                                 (c));
                  }
                else
                  {
                    /* Have we established a mapping for this color? */
                    if (colorMap[c] == (-1))
                     {
                       /* If it's the same image, mapping is trivial */
                       if (dst == src)
                         {
                           nc = c;
                         }
                       else
                         {
                           /* Find or create the best match */
                           /* 2.0.5: can't use gdTrueColorGetRed, etc with palette */
                           nc = gdImageColorResolveAlpha (dst,
                                                      gdImageRed (src,
                                                                c),
                                                      gdImageGreen
                                                      (src, c),
                                                      gdImageBlue (src,
                                                                 c),
                                                      gdImageAlpha
                                                      (src, c));
                         }
                       colorMap[c] = nc;
                     }
                    mapTo = colorMap[c];
                  }
              }
             for (i = 0; (i < stx[x - srcX]); i++)
              {
                gdImageSetPixel (dst, tox, toy, mapTo);
                tox++;
              }
           }
         toy++;
       }
    }
  gdFree (stx);
  gdFree (sty);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageCopyRotated ( gdImagePtr  dst,
gdImagePtr  src,
double  dstX,
double  dstY,
int  srcX,
int  srcY,
int  srcWidth,
int  srcHeight,
int  angle 
)

Definition at line 2379 of file gd.c.

{
  double dx, dy;
  double radius = sqrt (srcWidth * srcWidth + srcHeight * srcHeight);
  double aCos = cos (angle * .0174532925);
  double aSin = sin (angle * .0174532925);
  double scX = srcX + ((double) srcWidth) / 2;
  double scY = srcY + ((double) srcHeight) / 2;
  int cmap[gdMaxColors];
  int i;
  for (i = 0; (i < gdMaxColors); i++)
    {
      cmap[i] = (-1);
    }
  for (dy = dstY - radius; (dy <= dstY + radius); dy++)
    {
      for (dx = dstX - radius; (dx <= dstX + radius); dx++)
       {
         double sxd = (dx - dstX) * aCos - (dy - dstY) * aSin;
         double syd = (dy - dstY) * aCos + (dx - dstX) * aSin;
         int sx = sxd + scX;
         int sy = syd + scY;
         if ((sx >= srcX) && (sx < srcX + srcWidth) &&
             (sy >= srcY) && (sy < srcY + srcHeight))
           {
             int c = gdImageGetPixel (src, sx, sy);
             if (!src->trueColor)
              {
                /* Use a table to avoid an expensive
                   lookup on every single pixel */
                if (cmap[c] == -1)
                  {
                    cmap[c] = gdImageColorResolveAlpha (dst,
                                                   gdImageRed (src, c),
                                                   gdImageGreen (src,
                                                               c),
                                                   gdImageBlue (src,
                                                               c),
                                                   gdImageAlpha (src,
                                                               c));
                  }
                gdImageSetPixel (dst, dx, dy, cmap[c]);
              }
             else
              {
                gdImageSetPixel (dst,
                               dx, dy,
                               gdImageColorResolveAlpha (dst,
                                                      gdImageRed (src,
                                                                c),
                                                      gdImageGreen
                                                      (src, c),
                                                      gdImageBlue (src,
                                                                 c),
                                                      gdImageAlpha
                                                      (src, c)));
              }
           }
       }
    }
}

Here is the call graph for this function:

gdImagePtr gdImageCreate ( int  sx,
int  sy 
)

Definition at line 73 of file gd.c.

{
  int i;
  gdImagePtr im;
  im = (gdImage *) gdMalloc (sizeof (gdImage));
  memset (im, 0, sizeof (gdImage));
  /* Row-major ever since gd 1.3 */
  im->pixels = (unsigned char **) gdMalloc (sizeof (unsigned char *) * sy);
  im->AA_opacity =
    (unsigned char **) gdMalloc (sizeof (unsigned char *) * sy);
  im->polyInts = 0;
  im->polyAllocated = 0;
  im->brush = 0;
  im->tile = 0;
  im->style = 0;
  for (i = 0; (i < sy); i++)
    {
      /* Row-major ever since gd 1.3 */
      im->pixels[i] = (unsigned char *) gdCalloc (sx, sizeof (unsigned char));
      im->AA_opacity[i] =
       (unsigned char *) gdCalloc (sx, sizeof (unsigned char));
    }
  im->sx = sx;
  im->sy = sy;
  im->colorsTotal = 0;
  im->transparent = (-1);
  im->interlace = 0;
  im->thick = 1;
  im->AA = 0;
  im->AA_polygon = 0;
  for (i = 0; (i < gdMaxColors); i++)
    {
      im->open[i] = 1;
      im->red[i] = 0;
      im->green[i] = 0;
      im->blue[i] = 0;
    };
  im->trueColor = 0;
  im->tpixels = 0;
  im->cx1 = 0;
  im->cy1 = 0;
  im->cx2 = im->sx - 1;
  im->cy2 = im->sy - 1;
  return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 170 of file gd_gd.c.

{
  gdImagePtr im;
  gdIOCtx *in;

  in = gdNewFileCtx (inFile);
  im = gdImageCreateFromGdCtx (in);

  in->gd_free (in);

  return im;
}

Here is the call graph for this function:

Definition at line 1004 of file gd_gd2.c.

{
  fprintf (stderr, "GD2 support is not available - no libz\n");
  return NULL;
}

Definition at line 1011 of file gd_gd2.c.

{
  fprintf (stderr, "GD2 support is not available - no libz\n");
  return NULL;
}
gdImagePtr gdImageCreateFromGd2Part ( FILE *  in,
int  srcx,
int  srcy,
int  w,
int  h 
)
gdImagePtr gdImageCreateFromGd2PartCtx ( gdIOCtxPtr  in,
int  srcx,
int  srcy,
int  w,
int  h 
)

Definition at line 184 of file gd_gd.c.

{
  int sx, sy;
  int x, y;
  gdImagePtr im;

  /* Read the header */
  im = _gdCreateFromFile (in, &sx, &sy);

  if (im == NULL)
    {
      goto fail1;
    };

  /* Then the data... */
  /* 2.0.12: support truecolor properly in .gd as well as in .gd2.
     Problem reported by Andreas Pfaller. */
  if (im->trueColor)
    {
      for (y = 0; (y < sy); y++)
       {
         for (x = 0; (x < sx); x++)
           {
             int pix;
             if (!gdGetInt (&pix, in))
              {
                goto fail2;
              }
             im->tpixels[y][x] = pix;
           }
       }
    }
  else
    {
      for (y = 0; (y < sy); y++)
       {
         for (x = 0; (x < sx); x++)
           {
             int ch;
             ch = gdGetC (in);
             if (ch == EOF)
              {
                goto fail2;
              }
             /* ROW-MAJOR IN GD 1.3 */
             im->pixels[y][x] = ch;
           }
       }
    }
  return im;

fail2:
  gdImageDestroy (im);
fail1:
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageCreateFromJpeg ( FILE *  infile)

Definition at line 53 of file gd_ss.c.

{
  fprintf (stderr, "PNG support is not available\n");
  return NULL;
}
gdImagePtr gdImageCreateFromWBMP ( FILE *  inFile)

Definition at line 2578 of file gd.c.

{
  gdImagePtr im;
  int bit;
  int w, h;
  int bytes;
  int ch;
  int i, x, y;
  char *sp;
  char s[161];
  if (!fgets (s, 160, fd))
    {
      return 0;
    }
  sp = &s[0];
  /* Skip #define */
  sp = strchr (sp, ' ');
  if (!sp)
    {
      return 0;
    }
  /* Skip width label */
  sp++;
  sp = strchr (sp, ' ');
  if (!sp)
    {
      return 0;
    }
  /* Get width */
  w = atoi (sp + 1);
  if (!w)
    {
      return 0;
    }
  if (!fgets (s, 160, fd))
    {
      return 0;
    }
  sp = s;
  /* Skip #define */
  sp = strchr (sp, ' ');
  if (!sp)
    {
      return 0;
    }
  /* Skip height label */
  sp++;
  sp = strchr (sp, ' ');
  if (!sp)
    {
      return 0;
    }
  /* Get height */
  h = atoi (sp + 1);
  if (!h)
    {
      return 0;
    }
  /* Skip declaration line */
  if (!fgets (s, 160, fd))
    {
      return 0;
    }
  bytes = (w * h / 8) + 1;
  im = gdImageCreate (w, h);
  gdImageColorAllocate (im, 255, 255, 255);
  gdImageColorAllocate (im, 0, 0, 0);
  x = 0;
  y = 0;
  for (i = 0; (i < bytes); i++)
    {
      char h[3];
      unsigned int b;
      /* Skip spaces, commas, CRs, 0x */
      while (1)
       {
         ch = getc (fd);
         if (ch == EOF)
           {
             goto fail;
           }
         if (ch == 'x')
           {
             break;
           }
       }
      /* Get hex value */
      ch = getc (fd);
      if (ch == EOF)
       {
         goto fail;
       }
      h[0] = ch;
      ch = getc (fd);
      if (ch == EOF)
       {
         goto fail;
       }
      h[1] = ch;
      h[2] = '\0';
      sscanf (h, "%x", &b);
      for (bit = 1; (bit <= 128); (bit = bit << 1))
       {
         gdImageSetPixel (im, x++, y, (b & bit) ? 1 : 0);
         if (x == im->sx)
           {
             x = 0;
             y++;
             if (y == im->sy)
              {
                return im;
              }
             /* Fix 8/8/95 */
             break;
           }
       }
    }
  /* Shouldn't happen */
  fprintf (stderr, "Error: bug in gdImageCreateFromXbm!\n");
  return 0;
fail:
  gdImageDestroy (im);
  return 0;
}

Here is the call graph for this function:

gdImagePtr gdImageCreateFromXpm ( char *  filename)

Definition at line 21 of file gdxpm.c.

{
  fprintf (stderr, "libgd was not built with xpm support\n");
  return (NULL);
}

Definition at line 120 of file gd.c.

{
  int i;
  gdImagePtr im;
  im = (gdImage *) gdMalloc (sizeof (gdImage));
  memset (im, 0, sizeof (gdImage));
  im->tpixels = (int **) gdMalloc (sizeof (int *) * sy);
  im->AA_opacity =
    (unsigned char **) gdMalloc (sizeof (unsigned char *) * sy);
  im->polyInts = 0;
  im->polyAllocated = 0;
  im->brush = 0;
  im->tile = 0;
  im->style = 0;
  for (i = 0; (i < sy); i++)
    {
      im->tpixels[i] = (int *) gdCalloc (sx, sizeof (int));
      im->AA_opacity[i] =
       (unsigned char *) gdCalloc (sx, sizeof (unsigned char));
    }
  im->sx = sx;
  im->sy = sy;
  im->transparent = (-1);
  im->interlace = 0;
  im->trueColor = 1;
  /* 2.0.2: alpha blending is now on by default, and saving of alpha is
     off by default. This allows font antialiasing to work as expected
     on the first try in JPEGs -- quite important -- and also allows 
     for smaller PNGs when saving of alpha channel is not really 
     desired, which it usually isn't! */
  im->saveAlphaFlag = 0;
  im->alphaBlendingFlag = 1;
  im->thick = 1;
  im->AA = 0;
  im->AA_polygon = 0;
  im->cx1 = 0;
  im->cy1 = 0;
  im->cx2 = im->sx - 1;
  im->cy2 = im->sy - 1;
  return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageDashedLine ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Definition at line 1309 of file gd.c.

{
  int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
  int dashStep = 0;
  int on = 1;
  int wid;
  int vert;
  int thick = im->thick;

  dx = abs (x2 - x1);
  dy = abs (y2 - y1);
  if (dy <= dx)
    {
      /* More-or-less horizontal. use wid for vertical stroke */
      /* 2.0.12: Michael Schwartz: divide rather than multiply;
         TBB: but watch out for /0! */
      double as = sin (atan2 (dy, dx));
      if (as != 0)
       {
         wid = thick / as;
       }
      else
       {
         wid = 1;
       }
      vert = 1;

      d = 2 * dy - dx;
      incr1 = 2 * dy;
      incr2 = 2 * (dy - dx);
      if (x1 > x2)
       {
         x = x2;
         y = y2;
         ydirflag = (-1);
         xend = x1;
       }
      else
       {
         x = x1;
         y = y1;
         ydirflag = 1;
         xend = x2;
       }
      dashedSet (im, x, y, color, &on, &dashStep, wid, vert);
      if (((y2 - y1) * ydirflag) > 0)
       {
         while (x < xend)
           {
             x++;
             if (d < 0)
              {
                d += incr1;
              }
             else
              {
                y++;
                d += incr2;
              }
             dashedSet (im, x, y, color, &on, &dashStep, wid, vert);
           }
       }
      else
       {
         while (x < xend)
           {
             x++;
             if (d < 0)
              {
                d += incr1;
              }
             else
              {
                y--;
                d += incr2;
              }
             dashedSet (im, x, y, color, &on, &dashStep, wid, vert);
           }
       }
    }
  else
    {
      /* 2.0.12: Michael Schwartz: divide rather than multiply;
         TBB: but watch out for /0! */
      double as = sin (atan2 (dy, dx));
      if (as != 0)
       {
         wid = thick / as;
       }
      else
       {
         wid = 1;
       }
      vert = 0;

      d = 2 * dx - dy;
      incr1 = 2 * dx;
      incr2 = 2 * (dx - dy);
      if (y1 > y2)
       {
         y = y2;
         x = x2;
         yend = y1;
         xdirflag = (-1);
       }
      else
       {
         y = y1;
         x = x1;
         yend = y2;
         xdirflag = 1;
       }
      dashedSet (im, x, y, color, &on, &dashStep, wid, vert);
      if (((x2 - x1) * xdirflag) > 0)
       {
         while (y < yend)
           {
             y++;
             if (d < 0)
              {
                d += incr1;
              }
             else
              {
                x++;
                d += incr2;
              }
             dashedSet (im, x, y, color, &on, &dashStep, wid, vert);
           }
       }
      else
       {
         while (y < yend)
           {
             y++;
             if (d < 0)
              {
                d += incr1;
              }
             else
              {
                x--;
                d += incr2;
              }
             dashedSet (im, x, y, color, &on, &dashStep, wid, vert);
           }
       }
    }
}

Here is the call graph for this function:

Definition at line 163 of file gd.c.

{
  int i;
  if (im->pixels)
    {
      for (i = 0; (i < im->sy); i++)
       {
         gdFree (im->pixels[i]);
       }
      gdFree (im->pixels);
    }
  if (im->tpixels)
    {
      for (i = 0; (i < im->sy); i++)
       {
         gdFree (im->tpixels[i]);
       }
      gdFree (im->tpixels);
    }
  if (im->AA_opacity)
    {
      for (i = 0; (i < im->sy); i++)
       {
         gdFree (im->AA_opacity[i]);
       }
      gdFree (im->AA_opacity);
    }
  if (im->polyInts)
    {
      gdFree (im->polyInts);
    }
  if (im->style)
    {
      gdFree (im->style);
    }
  gdFree (im);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageEllipse ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  color 
)
void gdImageFill ( gdImagePtr  im,
int  x,
int  y,
int  color 
)

Definition at line 1828 of file gd.c.

{
  int lastBorder;
  int old;
  int leftLimit, rightLimit;
  int i;
  old = gdImageGetPixel (im, x, y);
  if (color == gdTiled)
    {
      /* Tile fill -- got to watch out! */
      int p, tileColor;
      int srcx, srcy;
      if (!im->tile)
       {
         return;
       }
      /* Refuse to flood-fill with a transparent pattern --
         I can't do it without allocating another image */
      if (gdImageGetTransparent (im->tile) != (-1))
       {
         return;
       }
      srcx = x % gdImageSX (im->tile);
      srcy = y % gdImageSY (im->tile);
      p = gdImageGetPixel (im->tile, srcx, srcy);
      if (im->trueColor)
       {
         tileColor = p;
       }
      else
       {
         if (im->tile->trueColor)
           {
             tileColor = gdImageColorResolveAlpha (im,
                                              gdTrueColorGetRed (p),
                                              gdTrueColorGetGreen (p),
                                              gdTrueColorGetBlue (p),
                                              gdTrueColorGetAlpha (p));
           }
         else
           {
             tileColor = im->tileColorMap[p];
           }
       }
      if (old == tileColor)
       {
         /* Nothing to be done */
         return;
       }
    }
  else
    {
      if (old == color)
       {
         /* Nothing to be done */
         return;
       }
    }
  /* Seek left */
  leftLimit = (-1);
  for (i = x; (i >= 0); i--)
    {
      if (gdImageGetPixel (im, i, y) != old)
       {
         break;
       }
      gdImageSetPixel (im, i, y, color);
      leftLimit = i;
    }
  if (leftLimit == (-1))
    {
      return;
    }
  /* Seek right */
  rightLimit = x;
  for (i = (x + 1); (i < im->sx); i++)
    {
      if (gdImageGetPixel (im, i, y) != old)
       {
         break;
       }
      gdImageSetPixel (im, i, y, color);
      rightLimit = i;
    }
  /* Look at lines above and below and start paints */
  /* Above */
  if (y > 0)
    {
      lastBorder = 1;
      for (i = leftLimit; (i <= rightLimit); i++)
       {
         int c;
         c = gdImageGetPixel (im, i, y - 1);
         if (lastBorder)
           {
             if (c == old)
              {
                gdImageFill (im, i, y - 1, color);
                lastBorder = 0;
              }
           }
         else if (c != old)
           {
             lastBorder = 1;
           }
       }
    }
  /* Below */
  if (y < ((im->sy) - 1))
    {
      lastBorder = 1;
      for (i = leftLimit; (i <= rightLimit); i++)
       {
         int c;
         c = gdImageGetPixel (im, i, y + 1);
         if (lastBorder)
           {
             if (c == old)
              {
                gdImageFill (im, i, y + 1, color);
                lastBorder = 0;
              }
           }
         else if (c != old)
           {
             lastBorder = 1;
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageFilledArc ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  s,
int  e,
int  color,
int  style 
)

Definition at line 1657 of file gd.c.

{
  gdPoint pts[3];
  int i;
  int lx = 0, ly = 0;
  int fx = 0, fy = 0;
  while (e < s)
    {
      e += 360;
    }
  for (i = s; (i <= e); i++)
    {
      int x, y;
      x = ((long) gdCosT[i % 360] * (long) w / (2 * 1024)) + cx;
      y = ((long) gdSinT[i % 360] * (long) h / (2 * 1024)) + cy;
      if (i != s)
       {
         if (!(style & gdChord))
           {
             if (style & gdNoFill)
              {
                gdImageLine (im, lx, ly, x, y, color);
              }
             else
              {
                /* This is expensive! */
                pts[0].x = lx;
                pts[0].y = ly;
                pts[1].x = x;
                pts[1].y = y;
                pts[2].x = cx;
                pts[2].y = cy;
                gdImageFilledPolygon (im, pts, 3, color);
              }
           }
       }
      else
       {
         fx = x;
         fy = y;
       }
      lx = x;
      ly = y;
    }
  if (style & gdChord)
    {
      if (style & gdNoFill)
       {
         if (style & gdEdged)
           {
             gdImageLine (im, cx, cy, lx, ly, color);
             gdImageLine (im, cx, cy, fx, fy, color);
           }
         gdImageLine (im, fx, fy, lx, ly, color);
       }
      else
       {
         pts[0].x = fx;
         pts[0].y = fy;
         pts[1].x = lx;
         pts[1].y = ly;
         pts[2].x = cx;
         pts[2].y = cy;
         gdImageFilledPolygon (im, pts, 3, color);
       }
    }
  else
    {
      if (style & gdNoFill)
       {
         if (style & gdEdged)
           {
             gdImageLine (im, cx, cy, lx, ly, color);
             gdImageLine (im, cx, cy, fx, fy, color);
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageFilledEllipse ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  color 
)

Definition at line 1738 of file gd.c.

{
  gdImageFilledArc (im, cx, cy, w, h, 0, 360, color, gdPie);
}

Here is the call graph for this function:

Definition at line 2746 of file gd.c.

{
  int i;
  int y;
  int miny, maxy;
  int x1, y1;
  int x2, y2;
  int ind1, ind2;
  int ints;
  int fill_color;
  if (!n)
    {
      return;
    }

  if (c == gdAntiAliased)
    fill_color = im->AA_color;
  else
    fill_color = c;

  if (!im->polyAllocated)
    {
      im->polyInts = (int *) gdMalloc (sizeof (int) * n);
      im->polyAllocated = n;
    }
  if (im->polyAllocated < n)
    {
      while (im->polyAllocated < n)
       {
         im->polyAllocated *= 2;
       }
      im->polyInts = (int *) gdRealloc (im->polyInts,
                                   sizeof (int) * im->polyAllocated);
    }
  miny = p[0].y;
  maxy = p[0].y;
  for (i = 1; (i < n); i++)
    {
      if (p[i].y < miny)
       {
         miny = p[i].y;
       }
      if (p[i].y > maxy)
       {
         maxy = p[i].y;
       }
    }
  /* Fix in 1.3: count a vertex only once */
  for (y = miny; (y <= maxy); y++)
    {
/*1.4           int interLast = 0; */
/*              int dirLast = 0; */
/*              int interFirst = 1; */
      ints = 0;
      for (i = 0; (i < n); i++)
       {
         if (!i)
           {
             ind1 = n - 1;
             ind2 = 0;
           }
         else
           {
             ind1 = i - 1;
             ind2 = i;
           }
         y1 = p[ind1].y;
         y2 = p[ind2].y;
         if (y1 < y2)
           {
             x1 = p[ind1].x;
             x2 = p[ind2].x;
           }
         else if (y1 > y2)
           {
             y2 = p[ind1].y;
             y1 = p[ind2].y;
             x2 = p[ind1].x;
             x1 = p[ind2].x;
           }
         else
           {
             continue;
           }

         /* Do the following math as float intermediately, and round to ensure
          * that Polygon and FilledPolygon for the same set of points have the
          * same footprint. */
         if ((y >= y1) && (y < y2))
           {
             im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) /
              (float) (y2 - y1) + 0.5 + x1;
           }
         else if ((y == maxy) && (y > y1) && (y <= y2))
           {
             im->polyInts[ints++] = (float) ((y - y1) * (x2 - x1)) /
              (float) (y2 - y1) + 0.5 + x1;
           }
       }
      qsort (im->polyInts, ints, sizeof (int), gdCompareInt);

      for (i = 0; (i < (ints)); i += 2)
       {
         gdImageLine (im, im->polyInts[i], y, im->polyInts[i + 1], y,
                     fill_color);
       }
    }

  /* If we are drawing this AA, then redraw the border with AA lines. */
  if (c == gdAntiAliased)
    gdImagePolygon (im, p, n, c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageFilledRectangle ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Definition at line 1989 of file gd.c.

{
  int x, y;
  /* Nick Atty: limit the points at the edge.  Note that this also
     nicely kills any plotting for rectangles completely outside the
     window as it makes the tests in the for loops fail */
  if (x1 < 0)
    x1 = 0;
  if (x1 > gdImageSX (im))
    x1 = gdImageSX (im);
  if (y1 < 0)
    y1 = 0;
  if (y1 > gdImageSY (im))
    y1 = gdImageSY (im);

  for (y = y1; (y <= y2); y++)
    {
      for (x = x1; (x <= x2); x++)
       {
         gdImageSetPixel (im, x, y, color);
       }
    }
}

Here is the call graph for this function:

void gdImageFillToBorder ( gdImagePtr  im,
int  x,
int  y,
int  border,
int  color 
)

Definition at line 1744 of file gd.c.

{
  int lastBorder;
  /* Seek left */
  int leftLimit, rightLimit;
  int i;
  leftLimit = (-1);
  if (border < 0)
    {
      /* Refuse to fill to a non-solid border */
      return;
    }
  for (i = x; (i >= 0); i--)
    {
      if (gdImageGetPixel (im, i, y) == border)
       {
         break;
       }
      gdImageSetPixel (im, i, y, color);
      leftLimit = i;
    }
  if (leftLimit == (-1))
    {
      return;
    }
  /* Seek right */
  rightLimit = x;
  for (i = (x + 1); (i < im->sx); i++)
    {
      if (gdImageGetPixel (im, i, y) == border)
       {
         break;
       }
      gdImageSetPixel (im, i, y, color);
      rightLimit = i;
    }
  /* Look at lines above and below and start paints */
  /* Above */
  if (y > 0)
    {
      lastBorder = 1;
      for (i = leftLimit; (i <= rightLimit); i++)
       {
         int c;
         c = gdImageGetPixel (im, i, y - 1);
         if (lastBorder)
           {
             if ((c != border) && (c != color))
              {
                gdImageFillToBorder (im, i, y - 1, border, color);
                lastBorder = 0;
              }
           }
         else if ((c == border) || (c == color))
           {
             lastBorder = 1;
           }
       }
    }
  /* Below */
  if (y < ((im->sy) - 1))
    {
      lastBorder = 1;
      for (i = leftLimit; (i <= rightLimit); i++)
       {
         int c;
         c = gdImageGetPixel (im, i, y + 1);
         if (lastBorder)
           {
             if ((c != border) && (c != color))
              {
                gdImageFillToBorder (im, i, y + 1, border, color);
                lastBorder = 0;
              }
           }
         else if ((c == border) || (c == color))
           {
             lastBorder = 1;
           }
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageGd ( gdImagePtr  im,
FILE *  out 
)

Definition at line 309 of file gd_gd.c.

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

Here is the call graph for this function:

void gdImageGd2 ( gdImagePtr  im,
FILE *  out,
int  cs,
int  fmt 
)
void* gdImageGd2Ptr ( gdImagePtr  im,
int  cs,
int  fmt,
int size 
)
void* gdImageGdPtr ( gdImagePtr  im,
int size 
)

Definition at line 317 of file gd_gd.c.

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

Here is the call graph for this function:

void gdImageGetClip ( gdImagePtr  im,
int x1P,
int y1P,
int x2P,
int y2P 
)

Definition at line 3107 of file gd.c.

{
  *x1P = im->cx1;
  *y1P = im->cy1;
  *x2P = im->cx2;
  *y2P = im->cy2;
}
int gdImageGetPixel ( gdImagePtr  im,
int  x,
int  y 
)

Definition at line 1002 of file gd.c.

{
  if (gdImageBoundsSafeMacro (im, x, y))
    {
      if (im->trueColor)
       {
         return im->tpixels[y][x];
       }
      else
       {
         return im->pixels[y][x];
       }
    }
  else
    {
      return 0;
    }
}

Here is the caller graph for this function:

void gdImageInterlace ( gdImagePtr  im,
int  interlaceArg 
)

Definition at line 2941 of file gd.c.

{
  im->interlace = interlaceArg;
}
void gdImageJpeg ( gdImagePtr  im,
FILE *  out,
int  quality 
)
void gdImageJpegCtx ( gdImagePtr  im,
gdIOCtx out,
int  quality 
)
void* gdImageJpegPtr ( gdImagePtr  im,
int size,
int  quality 
)
void gdImageLine ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Definition at line 1096 of file gd.c.

{
  int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag;
  int wid;
  int w, wstart;
  int thick = im->thick;

  /* 2.0.10: Nick Atty: clip to edges of drawing rectangle, return if no
     points need to be drawn */

  if (clip_1d (&x1, &y1, &x2, &y2, gdImageSX (im)) == 0)
    return;
  if (clip_1d (&y1, &x1, &y2, &x2, gdImageSY (im)) == 0)
    return;

  /* gdAntiAliased passed as color: set anti-aliased line (AAL) global vars. */
  if (color == gdAntiAliased)
    {
      im->AAL_x1 = x1;
      im->AAL_y1 = y1;
      im->AAL_x2 = x2;
      im->AAL_y2 = y2;

      /* Compute what we can for point-to-line distance calculation later. */
      im->AAL_Bx_Ax = x2 - x1;
      im->AAL_By_Ay = y2 - y1;
      im->AAL_LAB_2 =
       (im->AAL_Bx_Ax * im->AAL_Bx_Ax) + (im->AAL_By_Ay * im->AAL_By_Ay);
      im->AAL_LAB = sqrt (im->AAL_LAB_2);

      /* For AA, we must draw pixels outside the width of the line.  Keep in
       * mind that this will be curtailed by cos/sin of theta later. */
      thick += 4;
    }

  dx = abs (x2 - x1);
  dy = abs (y2 - y1);
  if (dy <= dx)
    {
      /* More-or-less horizontal. use wid for vertical stroke */
      /* Doug Claar: watch out for NaN in atan2 (2.0.5) */
      if ((dx == 0) && (dy == 0))
       {
         wid = 1;
       }
      else
       {
         /* 2.0.12: Michael Schwartz: divide rather than multiply;
            TBB: but watch out for /0! */
         double ac = cos (atan2 (dy, dx));
         if (ac != 0)
           {
             wid = thick / ac;
           }
         else
           {
             wid = 1;
           }
         if (wid == 0)
           {
             wid = 1;
           }
       }
      d = 2 * dy - dx;
      incr1 = 2 * dy;
      incr2 = 2 * (dy - dx);
      if (x1 > x2)
       {
         x = x2;
         y = y2;
         ydirflag = (-1);
         xend = x1;
       }
      else
       {
         x = x1;
         y = y1;
         ydirflag = 1;
         xend = x2;
       }

      /* Set up line thickness */
      wstart = y - wid / 2;
      for (w = wstart; w < wstart + wid; w++)
       gdImageSetPixel (im, x, w, color);

      if (((y2 - y1) * ydirflag) > 0)
       {
         while (x < xend)
           {
             x++;
             if (d < 0)
              {
                d += incr1;
              }
             else
              {
                y++;
                d += incr2;
              }
             wstart = y - wid / 2;
             for (w = wstart; w < wstart + wid; w++)
              gdImageSetPixel (im, x, w, color);
           }
       }
      else
       {
         while (x < xend)
           {
             x++;
             if (d < 0)
              {
                d += incr1;
              }
             else
              {
                y--;
                d += incr2;
              }
             wstart = y - wid / 2;
             for (w = wstart; w < wstart + wid; w++)
              gdImageSetPixel (im, x, w, color);
           }
       }
    }
  else
    {
      /* More-or-less vertical. use wid for horizontal stroke */
      /* 2.0.12: Michael Schwartz: divide rather than multiply;
         TBB: but watch out for /0! */
      double as = sin (atan2 (dy, dx));
      if (as != 0)
       {
         wid = thick / as;
       }
      else
       {
         wid = 1;
       }
      if (wid == 0)
       wid = 1;

      d = 2 * dx - dy;
      incr1 = 2 * dx;
      incr2 = 2 * (dx - dy);
      if (y1 > y2)
       {
         y = y2;
         x = x2;
         yend = y1;
         xdirflag = (-1);
       }
      else
       {
         y = y1;
         x = x1;
         yend = y2;
         xdirflag = 1;
       }

      /* Set up line thickness */
      wstart = x - wid / 2;
      for (w = wstart; w < wstart + wid; w++)
       gdImageSetPixel (im, w, y, color);

      if (((x2 - x1) * xdirflag) > 0)
       {
         while (y < yend)
           {
             y++;
             if (d < 0)
              {
                d += incr1;
              }
             else
              {
                x++;
                d += incr2;
              }
             wstart = x - wid / 2;
             for (w = wstart; w < wstart + wid; w++)
              gdImageSetPixel (im, w, y, color);
           }
       }
      else
       {
         while (y < yend)
           {
             y++;
             if (d < 0)
              {
                d += incr1;
              }
             else
              {
                x--;
                d += incr2;
              }
             wstart = x - wid / 2;
             for (w = wstart; w < wstart + wid; w++)
              gdImageSetPixel (im, w, y, color);
           }
       }
    }

  /* If this is the only line we are drawing, go ahead and blend. */
  if ((color == gdAntiAliased) && !(im->AA_polygon))
    gdImageAABlend (im);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 588 of file gd.c.

{
  int i;
  int x, y, p;
  int xlate[256];
  if (to->trueColor)
    {
      return;
    }
  if (from->trueColor)
    {
      return;
    }

  for (i = 0; i < 256; i++)
    {
      xlate[i] = -1;
    };

  for (x = 0; x < (to->sx); x++)
    {
      for (y = 0; y < (to->sy); y++)
       {
         p = gdImageGetPixel (to, x, y);
         if (xlate[p] == -1)
           {
             /* This ought to use HWB, but we don't have an alpha-aware
                version of that yet. */
             xlate[p] =
              gdImageColorClosestAlpha (from, to->red[p], to->green[p],
                                     to->blue[p], to->alpha[p]);
             /*printf("Mapping %d (%d, %d, %d, %d) to %d (%d, %d, %d, %d)\n", */
             /*      p,  to->red[p], to->green[p], to->blue[p], to->alpha[p], */
             /*      xlate[p], from->red[xlate[p]], from->green[xlate[p]], from->blue[xlate[p]], from->alpha[xlate[p]]); */
           };
         gdImageSetPixel (to, x, y, xlate[p]);
       };
    };

  for (i = 0; (i < (from->colorsTotal)); i++)
    {
      /*printf("Copying color %d (%d, %d, %d, %d)\n", i, from->red[i], from->blue[i], from->green[i], from->alpha[i]); */
      to->red[i] = from->red[i];
      to->blue[i] = from->blue[i];
      to->green[i] = from->green[i];
      to->alpha[i] = from->alpha[i];
      to->open[i] = 0;
    };

  for (i = from->colorsTotal; (i < to->colorsTotal); i++)
    {
      to->open[i] = 1;
    };

  to->colorsTotal = from->colorsTotal;

}

Here is the call graph for this function:

void gdImagePng ( gdImagePtr  im,
FILE *  out 
)
void gdImagePngCtx ( gdImagePtr  im,
gdIOCtx out 
)
void gdImagePngCtxEx ( gdImagePtr  im,
gdIOCtx out,
int  level 
)
void gdImagePngEx ( gdImagePtr  im,
FILE *  out,
int  level 
)
void* gdImagePngPtr ( gdImagePtr  im,
int size 
)
void* gdImagePngPtrEx ( gdImagePtr  im,
int size,
int  level 
)

Definition at line 47 of file gd_ss.c.

{
  fprintf (stderr, "PNG support is not available\n");
}
void gdImagePolygon ( gdImagePtr  im,
gdPointPtr  p,
int  n,
int  c 
)

Definition at line 2704 of file gd.c.

{
  int i;
  int lx, ly;
  if (!n)
    {
      return;
    }

  /* Let it be known that we are drawing a polygon so that the opacity
   * mask doesn't get cleared after each line. */
  if (c == gdAntiAliased)
    im->AA_polygon = 1;

  lx = p->x;
  ly = p->y;
  gdImageLine (im, lx, ly, p[n - 1].x, p[n - 1].y, c);
  for (i = 1; (i < n); i++)
    {
      p++;
      gdImageLine (im, lx, ly, p->x, p->y, c);
      lx = p->x;
      ly = p->y;
    }

  if (c == gdAntiAliased)
    {
      im->AA_polygon = 0;
      gdImageAABlend (im);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageRectangle ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Definition at line 1960 of file gd.c.

{
  int x1h = x1, x1v = x1, y1h = y1, y1v = y1, x2h = x2, x2v = x2, y2h = y2,
    y2v = y2;
  int thick = im->thick;
  if (thick > 1)
    {
      int half = thick / 2;
      int half1 = thick - half;

      if (y1 < y2)
       {
         y1v = y1h - half;
         y2v = y2h + half1 - 1;
       }
      else
       {
         y1v = y1h + half1 - 1;
         y2v = y2h - half;
       }
    }

  gdImageLine (im, x1h, y1h, x2h, y1h, color);
  gdImageLine (im, x1h, y2h, x2h, y2h, color);
  gdImageLine (im, x1v, y1v, x1v, y2v, color);
  gdImageLine (im, x2v, y1v, x2v, y2v, color);
}

Here is the call graph for this function:

void gdImageSaveAlpha ( gdImagePtr  im,
int  saveAlphaArg 
)

Definition at line 3068 of file gd.c.

{
  im->saveAlphaFlag = saveAlphaArg;
}

Definition at line 2925 of file gd.c.

{
  im->AA = 1;
  im->AA_color = c;
  im->AA_dont_blend = -1;
}
void gdImageSetAntiAliasedDontBlend ( gdImagePtr  im,
int  c,
int  dont_blend 
)

Definition at line 2933 of file gd.c.

{
  im->AA = 1;
  im->AA_color = c;
  im->AA_dont_blend = dont_blend;
}

Definition at line 2885 of file gd.c.

{
  int i;
  im->brush = brush;
  if ((!im->trueColor) && (!im->brush->trueColor))
    {
      for (i = 0; (i < gdImageColorsTotal (brush)); i++)
       {
         int index;
         index = gdImageColorResolveAlpha (im,
                                       gdImageRed (brush, i),
                                       gdImageGreen (brush, i),
                                       gdImageBlue (brush, i),
                                       gdImageAlpha (brush, i));
         im->brushColorMap[i] = index;
       }
    }
}

Here is the call graph for this function:

void gdImageSetClip ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2 
)

Definition at line 3074 of file gd.c.

{
  if (x1 < 0) {
    x1 = 0;
  }
  if (x1 >= im->sx) {
    x1 = im->sx - 1;
  }
  if (x2 < 0) {
    x2 = 0;
  }
  if (x2 >= im->sx) {
    x2 = im->sx - 1;
  }
  if (y1 < 0) {
    y1 = 0;
  }
  if (y1 >= im->sy) {
    y1 = im->sy - 1;
  }
  if (y2 < 0) {
    y2 = 0;
  }
  if (y2 >= im->sy) {
    y2 = im->sy - 1;
  }
  im->cx1 = x1;
  im->cy1 = y1;
  im->cx2 = x2;
  im->cy2 = y2;
}
void gdImageSetPixel ( gdImagePtr  im,
int  x,
int  y,
int  color 
)

Definition at line 724 of file gd.c.

{
  int p;
  switch (color)
    {
    case gdStyled:
      if (!im->style)
       {
         /* Refuse to draw if no style is set. */
         return;
       }
      else
       {
         p = im->style[im->stylePos++];
       }
      if (p != (gdTransparent))
       {
         gdImageSetPixel (im, x, y, p);
       }
      im->stylePos = im->stylePos % im->styleLength;
      break;
    case gdStyledBrushed:
      if (!im->style)
       {
         /* Refuse to draw if no style is set. */
         return;
       }
      p = im->style[im->stylePos++];
      if ((p != gdTransparent) && (p != 0))
       {
         gdImageSetPixel (im, x, y, gdBrushed);
       }
      im->stylePos = im->stylePos % im->styleLength;
      break;
    case gdBrushed:
      gdImageBrushApply (im, x, y);
      break;
    case gdTiled:
      gdImageTileApply (im, x, y);
      break;
    case gdAntiAliased:
      gdImageAntiAliasedApply (im, x, y);
      break;
    default:
      if (gdImageBoundsSafeMacro (im, x, y))
       {
         if (im->trueColor)
           {
             if (im->alphaBlendingFlag)
              {
                im->tpixels[y][x] = gdAlphaBlend (im->tpixels[y][x], color);
              }
             else
              {
                im->tpixels[y][x] = color;
              }
           }
         else
           {
             im->pixels[y][x] = color;
           }
       }
      break;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageSetStyle ( gdImagePtr  im,
int style,
int  noOfPixels 
)

Definition at line 2866 of file gd.c.

{
  if (im->style)
    {
      gdFree (im->style);
    }
  im->style = (int *) gdMalloc (sizeof (int) * noOfPixels);
  memcpy (im->style, style, sizeof (int) * noOfPixels);
  im->styleLength = noOfPixels;
  im->stylePos = 0;
}

Here is the call graph for this function:

void gdImageSetThickness ( gdImagePtr  im,
int  thickness 
)

Definition at line 2879 of file gd.c.

{
  im->thick = thickness;
}

Definition at line 2905 of file gd.c.

{
  int i;
  im->tile = tile;
  if ((!im->trueColor) && (!im->tile->trueColor))
    {
      for (i = 0; (i < gdImageColorsTotal (tile)); i++)
       {
         int index;
         index = gdImageColorResolveAlpha (im,
                                       gdImageRed (tile, i),
                                       gdImageGreen (tile, i),
                                       gdImageBlue (tile, i),
                                       gdImageAlpha (tile, i));
         im->tileColorMap[i] = index;
       }
    }
}

Here is the call graph for this function:

void gdImageString ( gdImagePtr  im,
gdFontPtr  f,
int  x,
int  y,
unsigned char *  s,
int  color 
)

Definition at line 1561 of file gd.c.

{
  int i;
  int l;
  l = strlen ((char *) s);
  for (i = 0; (i < l); i++)
    {
      gdImageChar (im, f, x, y, s[i], color);
      x += f->w;
    }
}

Here is the call graph for this function:

void gdImageString16 ( gdImagePtr  im,
gdFontPtr  f,
int  x,
int  y,
unsigned short *  s,
int  color 
)

Definition at line 1591 of file gd.c.

{
  int i;
  int l;
  l = strlen16 (s);
  for (i = 0; (i < l); i++)
    {
      gdImageChar (im, f, x, y, s[i], color);
      x += f->w;
    }
}

Here is the call graph for this function:

char* gdImageStringFT ( gdImage im,
int brect,
int  fg,
char *  fontlist,
double  ptsize,
double  angle,
int  x,
int  y,
char *  string 
)
char* gdImageStringFTEx ( gdImage im,
int brect,
int  fg,
char *  fontlist,
double  ptsize,
double  angle,
int  x,
int  y,
char *  string,
gdFTStringExtraPtr  strex 
)
char* gdImageStringTTF ( gdImage im,
int brect,
int  fg,
char *  fontlist,
double  ptsize,
double  angle,
int  x,
int  y,
char *  string 
)
void gdImageStringUp ( gdImagePtr  im,
gdFontPtr  f,
int  x,
int  y,
unsigned char *  s,
int  color 
)

Definition at line 1575 of file gd.c.

{
  int i;
  int l;
  l = strlen ((char *) s);
  for (i = 0; (i < l); i++)
    {
      gdImageCharUp (im, f, x, y, s[i], color);
      y -= f->w;
    }
}

Here is the call graph for this function:

void gdImageStringUp16 ( gdImagePtr  im,
gdFontPtr  f,
int  x,
int  y,
unsigned short *  s,
int  color 
)

Definition at line 1605 of file gd.c.

{
  int i;
  int l;
  l = strlen16 (s);
  for (i = 0; (i < l); i++)
    {
      gdImageCharUp (im, f, x, y, s[i], color);
      y -= f->w;
    }
}

Here is the call graph for this function:

void gdImageTrueColorToPalette ( gdImagePtr  im,
int  ditherFlag,
int  colorsWanted 
)

Definition at line 1746 of file gd_topal.c.

{
  my_cquantize_ptr cquantize = NULL;
  int i;

#ifndef ORIGINAL_LIB_JPEG
  /* Allocate the JPEG palette-storage */
  size_t arraysize;
  int maxColors = gdMaxColors;
  if (!im->trueColor)
    {
      /* Nothing to do! */
      return;
    }

  /* If we have a transparent color (the alphaless mode of transparency), we
   * must reserve a palette entry for it at the end of the palette. */
  if (im->transparent >= 0)
    {
      maxColors--;
    }
  if (colorsWanted > maxColors)
    {
      colorsWanted = maxColors;
    }
  im->pixels = gdCalloc (sizeof (unsigned char *), im->sy);
  if (!im->pixels)
    {
      /* No can do */
      goto outOfMemory;
    }
  for (i = 0; (i < im->sy); i++)
    {
      im->pixels[i] = gdCalloc (sizeof (unsigned char *), im->sx);
      if (!im->pixels[i])
       {
         goto outOfMemory;
       }
    }
#endif

#ifdef ORIGINAL_LIB_JPEG
  cquantize = (my_cquantize_ptr)
    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
                            SIZEOF (my_cquantizer));
  cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize;
  cquantize->pub.start_pass = start_pass_2_quant;
  cquantize->pub.new_color_map = new_color_map_2_quant;
  /* Make sure jdmaster didn't give me a case I can't handle */
  if (cinfo->out_color_components != 3)
    ERREXIT (cinfo, JERR_NOTIMPL);
#else
  cquantize = (my_cquantize_ptr) gdCalloc (sizeof (my_cquantizer), 1);
  if (!cquantize)
    {
      /* No can do */
      goto outOfMemory;
    }
#endif
  cquantize->fserrors = NULL;      /* flag optional arrays not allocated */
  cquantize->error_limiter = NULL;


  /* Allocate the histogram/inverse colormap storage */
#ifdef ORIGINAL_LIB_JPEG
  cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small)
    ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF (hist2d));
  for (i = 0; i < HIST_C0_ELEMS; i++)
    {
      cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large)
       ((j_common_ptr) cinfo, JPOOL_IMAGE,
        HIST_C1_ELEMS * HIST_C2_ELEMS * SIZEOF (histcell));
    }
  cquantize->needs_zeroed = TRUE;  /* histogram is garbage now */
#else
  cquantize->histogram = (hist3d) gdMalloc (HIST_C0_ELEMS * sizeof (hist2d));
  for (i = 0; i < HIST_C0_ELEMS; i++)
    {
      cquantize->histogram[i] =
       (hist2d) gdMalloc (HIST_C1_ELEMS * HIST_C2_ELEMS * sizeof (histcell));
      if (!cquantize->histogram[i])
       {
         goto outOfMemory;
       }
    }
#endif

#ifdef ORIGINAL_LIB_JPEG
  /* Allocate storage for the completed colormap, if required.
   * We do this now since it is FAR storage and may affect
   * the memory manager's space calculations.
   */
  if (cinfo->enable_2pass_quant)
    {
      /* Make sure color count is acceptable */
      int desired = cinfo->desired_number_of_colors;
      /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */
      if (desired < 8)
       ERREXIT1 (cinfo, JERR_QUANT_FEW_COLORS, 8);
      /* Make sure colormap indexes can be represented by JSAMPLEs */
      if (desired > MAXNUMCOLORS)
       ERREXIT1 (cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS);
      cquantize->sv_colormap = (*cinfo->mem->alloc_sarray)
       ((j_common_ptr) cinfo, JPOOL_IMAGE, (JDIMENSION) desired,
        (JDIMENSION) 3);
      cquantize->desired = desired;
    }
  else
    cquantize->sv_colormap = NULL;

  /* Only F-S dithering or no dithering is supported. */
  /* If user asks for ordered dither, give him F-S. */
  if (cinfo->dither_mode != JDITHER_NONE)
    cinfo->dither_mode = JDITHER_FS;

  /* Allocate Floyd-Steinberg workspace if necessary.
   * This isn't really needed until pass 2, but again it is FAR storage.
   * Although we will cope with a later change in dither_mode,
   * we do not promise to honor max_memory_to_use if dither_mode changes.
   */
  if (cinfo->dither_mode == JDITHER_FS)
    {
      cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large)
       ((j_common_ptr) cinfo, JPOOL_IMAGE,
        (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF (FSERROR))));
      /* Might as well create the error-limiting table too. */
      init_error_limit (cinfo);
    }
#else

  cquantize->fserrors = (FSERRPTR) gdMalloc (3 * sizeof (FSERROR));
  init_error_limit (im, cquantize);
  arraysize = (size_t) ((im->sx + 2) * (3 * sizeof (FSERROR)));
  /* Allocate Floyd-Steinberg workspace. */
  cquantize->fserrors = gdCalloc (arraysize, 1);
  if (!cquantize->fserrors)
    {
      goto outOfMemory;
    }
  cquantize->on_odd_row = FALSE;

  /* Do the work! */
  zeroHistogram (cquantize->histogram);
  prescan_quantize (im, cquantize);
  /* TBB 2.0.5: pass colorsWanted, not 256! */
  select_colors (im, cquantize, colorsWanted);
  zeroHistogram (cquantize->histogram);
  if (dither)
    {
      pass2_fs_dither (im, cquantize);
    }
  else
    {
      pass2_no_dither (im, cquantize);
    }
#if 0                       /* 2.0.12; we no longer attempt full alpha in palettes */
  if (cquantize->transparentIsPresent)
    {
      int mt = -1;
      int mtIndex = -1;
      for (i = 0; (i < im->colorsTotal); i++)
       {
         if (im->alpha[i] > mt)
           {
             mtIndex = i;
             mt = im->alpha[i];
           }
       }
      for (i = 0; (i < im->colorsTotal); i++)
       {
         if (im->alpha[i] == mt)
           {
             im->alpha[i] = gdAlphaTransparent;
           }
       }
    }
  if (cquantize->opaqueIsPresent)
    {
      int mo = 128;
      int moIndex = -1;
      for (i = 0; (i < im->colorsTotal); i++)
       {
         if (im->alpha[i] < mo)
           {
             moIndex = i;
             mo = im->alpha[i];
           }
       }
      for (i = 0; (i < im->colorsTotal); i++)
       {
         if (im->alpha[i] == mo)
           {
             im->alpha[i] = gdAlphaOpaque;
           }
       }
    }
#endif

  /* If we had a 'transparent' color, increment the color count so it's
   * officially in the palette and convert the transparent variable to point to
   * an index rather than a color (Its data already exists and transparent
   * pixels have already been mapped to it by this point, it is done late as to
   * avoid color matching / dithering with it). */
  if (im->transparent >= 0)
    {
      im->transparent = im->colorsTotal;
      im->colorsTotal++;
    }

  /* Success! Get rid of the truecolor image data. */
  im->trueColor = 0;
  /* Junk the truecolor pixels */
  for (i = 0; i < im->sy; i++)
    {
      gdFree (im->tpixels[i]);
    }
  gdFree (im->tpixels);
  im->tpixels = 0;
  /* Tediously free stuff. */
outOfMemory:
  if (im->trueColor)
    {
      /* On failure only */
      for (i = 0; i < im->sy; i++)
       {
         if (im->pixels[i])
           {
             gdFree (im->pixels[i]);
           }
       }
      if (im->pixels)
       {
         gdFree (im->pixels);
       }
      im->pixels = 0;
    }
  for (i = 0; i < HIST_C0_ELEMS; i++)
    {
      if (cquantize->histogram[i])
       {
         gdFree (cquantize->histogram[i]);
       }
    }
  if (cquantize->histogram)
    {
      gdFree (cquantize->histogram);
    }
  if (cquantize->fserrors)
    {
      gdFree (cquantize->fserrors);
    }
  if (cquantize->error_limiter_storage)
    {
      gdFree (cquantize->error_limiter_storage);
    }
  if (cquantize)
    {
      gdFree (cquantize);
    }

#endif
}

Here is the call graph for this function:

void gdImageWBMP ( gdImagePtr  image,
int  fg,
FILE *  out 
)
void gdImageWBMPCtx ( gdImagePtr  image,
int  fg,
gdIOCtx out 
)
void* gdImageWBMPPtr ( gdImagePtr  im,
int size,
int  fg 
)
gdIOCtx* gdNewDynamicCtx ( int  ,
void  
)

Definition at line 72 of file gd_io_dp.c.

{
  dpIOCtx *ctx;
  dynamicPtr *dp;

  ctx = (dpIOCtx *) gdMalloc (sizeof (dpIOCtx));
  if (ctx == NULL)
    {
      return NULL;
    }

  dp = newDynamic (initialSize, data);
  if (!dp)
    {
      gdFree (ctx);
      return NULL;
    };

  ctx->dp = dp;

  ctx->ctx.getC = dynamicGetchar;
  ctx->ctx.putC = dynamicPutchar;

  ctx->ctx.getBuf = dynamicGetbuf;
  ctx->ctx.putBuf = dynamicPutbuf;

  ctx->ctx.seek = dynamicSeek;
  ctx->ctx.tell = dynamicTell;

  ctx->ctx.gd_free = gdFreeDynamicCtx;

  return (gdIOCtx *) ctx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdIOCtx* gdNewFileCtx ( FILE *  )

Definition at line 57 of file gd_io_file.c.

{
  fileIOCtx *ctx;

  ctx = (fileIOCtx *) gdMalloc (sizeof (fileIOCtx));
  if (ctx == NULL)
    {
      return NULL;
    }

  ctx->f = f;

  ctx->ctx.getC = fileGetchar;
  ctx->ctx.putC = filePutchar;

  ctx->ctx.getBuf = fileGetbuf;
  ctx->ctx.putBuf = filePutbuf;

  ctx->ctx.tell = fileTell;
  ctx->ctx.seek = fileSeek;

  ctx->ctx.gd_free = gdFreeFileCtx;

  return (gdIOCtx *) ctx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdIOCtx * gdNewSSCtx ( gdSourcePtr  in,
gdSinkPtr  out 
)

Definition at line 56 of file gd_io_ss.c.

{
  ssIOCtxPtr ctx;

  ctx = (ssIOCtxPtr) gdMalloc (sizeof (ssIOCtx));
  if (ctx == NULL)
    {
      return NULL;
    }

  ctx->src = src;
  ctx->snk = snk;

  ctx->ctx.getC = sourceGetchar;
  ctx->ctx.getBuf = sourceGetbuf;

  ctx->ctx.putC = sinkPutchar;
  ctx->ctx.putBuf = sinkPutbuf;

  ctx->ctx.tell = NULL;
  ctx->ctx.seek = NULL;

  ctx->ctx.gd_free = gdFreeSsCtx;

  return (gdIOCtx *) ctx;
}

Here is the call graph for this function: