Back to index

php5  5.3.10
Classes | Defines | Typedefs | Enumerations | Functions
gd.h File Reference
#include "php_compat.h"
#include <stdio.h>
#include "gd_io.h"

Go to the source code of this file.

Classes

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

Defines

#define GD_MAJOR_VERSION   2
#define GD_MINOR_VERSION   0
#define GD_RELEASE_VERSION   35
#define GD_EXTRA_VERSION   ""
#define GD_VERSION_STRING   "2.0.35"
#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 gdEffectReplace   0
#define gdEffectAlphaBlend   1
#define gdEffectNormal   2
#define gdEffectOverlay   3
#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_RESOLUTION   4
#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 */
#define gdImageBoundsSafe(im, x, y)   (!((((y) < (im)->cy1) || ((y) > (im)->cy2)) || (((x) < (im)->cx1) || ((x) > (im)->cx2))))

Typedefs

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

Enumerations

enum  gdPixelateMode { GD_PIXELATE_UPPERLEFT, GD_PIXELATE_AVERAGE, GD_PIXELATE_UPPERLEFT, GD_PIXELATE_AVERAGE }

Functions

void php_gd_error_ex (int type, const char *format,...)
void php_gd_error (const char *format,...)
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, int ignore_warning)
gdImagePtr gdImageCreateFromJpegCtx (gdIOCtx *infile, int ignore_warning)
int gdJpegGetVersionInt ()
const char * gdPngGetVersionString ()
const char * gdJpegGetVersionString ()
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 gdImageCreateFromXbm (FILE *fd)
void gdImageXbmCtx (gdImagePtr image, char *file_name, int fg, gdIOCtx *out)
gdImagePtr gdImageCreateFromXpm (char *filename)
void gdImageDestroy (gdImagePtr im)
void gdImageSetPixel (gdImagePtr im, int x, int y, int color)
int gdImageGetTrueColorPixel (gdImagePtr im, int x, int y)
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 gdImageAALine (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)
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 gdFontCacheMutexSetup ()
void gdFontCacheMutexShutdown ()
int gdFontCacheSetup (void)
void gdFontCacheShutdown (void)
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)
gdImagePtr gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag, int colorsWanted)
void gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag, int colorsWanted)
int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
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 gdImageGif (gdImagePtr im, FILE *out)
void gdImageGifCtx (gdImagePtr im, gdIOCtx *out)
void gdImagePngEx (gdImagePtr im, FILE *out, int level, int basefilter)
void gdImagePngCtxEx (gdImagePtr im, gdIOCtx *out, int level, int basefilter)
void gdImageWBMP (gdImagePtr image, int fg, FILE *out)
void gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx *out)
void gdFree (void *m)
void * gdImageWBMPPtr (gdImagePtr im, int *size, int fg)
void gdImageJpeg (gdImagePtr im, FILE *out, int quality)
void gdImageJpegCtx (gdImagePtr im, gdIOCtx *out, int quality)
void * gdImageJpegPtr (gdImagePtr im, int *size, int quality)
gdImagePtr gdImageCreateFromGif (FILE *fd)
gdImagePtr gdImageCreateFromGifCtx (gdIOCtxPtr in)
gdImagePtr gdImageCreateFromGifSource (gdSourcePtr in)
void gdImagePngToSink (gdImagePtr im, gdSinkPtr out)
void gdImageGd (gdImagePtr im, FILE *out)
void gdImageGd2 (gdImagePtr im, FILE *out, int cs, int fmt)
void * gdImagePngPtr (gdImagePtr im, int *size)
void * gdImageGdPtr (gdImagePtr im, int *size)
void * gdImagePngPtrEx (gdImagePtr im, int *size, int level, int basefilter)
void * gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size)
void gdImageEllipse (gdImagePtr im, int cx, int cy, int w, int h, int c)
 Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse) Function added by Pierre-Alain Joye 02/08/2003 (paj@p.nosp@m.earf.nosp@m.r.org) See the ellipse function simplification for the equation as well as the midpoint algorithm.
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)
gdImagePtr gdImageRotate90 (gdImagePtr src, int ignoretransparent)
gdImagePtr gdImageRotate180 (gdImagePtr src, int ignoretransparent)
gdImagePtr gdImageRotate270 (gdImagePtr src, int ignoretransparent)
gdImagePtr gdImageRotate45 (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
gdImagePtr gdImageRotate (gdImagePtr src, double dAngle, int clrBack, int ignoretransparent)
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 gdImageAntialias (gdImagePtr im, int antialias)
void gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg)
int gdImagePixelate (gdImagePtr im, int block_size, const unsigned int mode)
gdIOCtxgdNewFileCtx (FILE *)
gdIOCtxgdNewDynamicCtx (int, void *)
gdIOCtxgdNewDynamicCtxEx (int size, void *data, int freeFlag)
gdIOCtxgdNewSSCtx (gdSourcePtr in, gdSinkPtr out)
void * gdDPExtractData (struct gdIOCtx *ctx, int *size)
int gdImageNegate (gdImagePtr src)
int gdImageGrayScale (gdImagePtr src)
int gdImageBrightness (gdImagePtr src, int brightness)
int gdImageContrast (gdImagePtr src, double contrast)
int gdImageColor (gdImagePtr src, const int red, const int green, const int blue, const int alpha)
int gdImageConvolution (gdImagePtr src, float ft[3][3], float filter_div, float offset)
int gdImageEdgeDetectQuick (gdImagePtr src)
int gdImageGaussianBlur (gdImagePtr im)
int gdImageSelectiveBlur (gdImagePtr src)
int gdImageEmboss (gdImagePtr im)
int gdImageMeanRemoval (gdImagePtr im)
int gdImageSmooth (gdImagePtr im, float weight)
int gdImageCompare (gdImagePtr im1, gdImagePtr im2)

Class Documentation

struct gdImageStruct

Definition at line 104 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 antialias
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 195 of file gd.h.

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

Definition at line 348 of file gd.h.

Class Members
int charmap
int flags
int hdpi
double linespacing
int vdpi
struct gdPoint

Definition at line 377 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 30 of file gd.h.

#define GD2_CHUNKSIZE   128

Definition at line 632 of file gd.h.

#define GD2_CHUNKSIZE_MAX   4096

Definition at line 634 of file gd.h.

#define GD2_CHUNKSIZE_MIN   64

Definition at line 633 of file gd.h.

#define GD2_FMT_COMPRESSED   2

Definition at line 639 of file gd.h.

#define GD2_FMT_RAW   1

Definition at line 638 of file gd.h.

#define GD2_ID   "gd2"

Definition at line 637 of file gd.h.

#define GD2_VERS   2

Definition at line 636 of file gd.h.

#define GD_CMP_BACKGROUND   64 /* Background colour */

Definition at line 686 of file gd.h.

#define GD_CMP_COLOR   4 /* Image colours differ */

Definition at line 682 of file gd.h.

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

Definition at line 680 of file gd.h.

#define GD_CMP_INTERLACE   128 /* Interlaced setting */

Definition at line 687 of file gd.h.

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

Definition at line 681 of file gd.h.

#define GD_CMP_SIZE_X   8 /* Image width differs */

Definition at line 683 of file gd.h.

#define GD_CMP_SIZE_Y   16 /* Image heights differ */

Definition at line 684 of file gd.h.

#define GD_CMP_TRANSPARENT   32 /* Transparent colour */

Definition at line 685 of file gd.h.

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

Definition at line 688 of file gd.h.

#define GD_EXTRA_VERSION   ""

Definition at line 17 of file gd.h.

#define GD_MAJOR_VERSION   2

Definition at line 14 of file gd.h.

#define GD_MINOR_VERSION   0

Definition at line 15 of file gd.h.

#define GD_RELEASE_VERSION   35

Definition at line 16 of file gd.h.

#define GD_RESOLUTION   96 /* pixels per inch */

Definition at line 691 of file gd.h.

#define GD_VERSION_STRING   "2.0.35"

Definition at line 18 of file gd.h.

#define gdAlphaMax   127

Definition at line 81 of file gd.h.

#define gdAlphaOpaque   0

Definition at line 82 of file gd.h.

#define gdAlphaTransparent   127

Definition at line 83 of file gd.h.

#define gdAntiAliased   (-7)

Definition at line 228 of file gd.h.

#define gdArc   0

Definition at line 535 of file gd.h.

#define gdBlueMax   255

Definition at line 86 of file gd.h.

#define gdBrushed   (-3)

Definition at line 220 of file gd.h.

#define gdChord   1

Definition at line 537 of file gd.h.

#define gdDashSize   4

Definition at line 215 of file gd.h.

#define gdEdged   4

Definition at line 539 of file gd.h.

#define gdEffectAlphaBlend   1

Definition at line 92 of file gd.h.

#define gdEffectNormal   2

Definition at line 93 of file gd.h.

#define gdEffectOverlay   3

Definition at line 94 of file gd.h.

#define gdEffectReplace   0

Definition at line 91 of file gd.h.

#define gdFTEX_Big5   2

Definition at line 367 of file gd.h.

#define gdFTEX_CHARMAP   2

Definition at line 361 of file gd.h.

#define gdFTEX_LINESPACE   1

Definition at line 360 of file gd.h.

#define gdFTEX_RESOLUTION   4

Definition at line 362 of file gd.h.

#define gdFTEX_Shift_JIS   1

Definition at line 366 of file gd.h.

#define gdFTEX_Unicode   0

Definition at line 365 of file gd.h.

#define gdGreenMax   255

Definition at line 85 of file gd.h.

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

Definition at line 611 of file gd.h.

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

Definition at line 609 of file gd.h.

#define gdImageBoundsSafe (   im,
  x,
 
)    (!((((y) < (im)->cy1) || ((y) > (im)->cy2)) || (((x) < (im)->cx1) || ((x) > (im)->cx2))))

Definition at line 698 of file gd.h.

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

Definition at line 604 of file gd.h.

Definition at line 236 of file gd.h.

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

Definition at line 614 of file gd.h.

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

Definition at line 613 of file gd.h.

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

Definition at line 607 of file gd.h.

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

Definition at line 621 of file gd.h.

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

Definition at line 605 of file gd.h.

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

Definition at line 602 of file gd.h.

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

Definition at line 603 of file gd.h.

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

Definition at line 600 of file gd.h.

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

Definition at line 622 of file gd.h.

#define gdMaxColors   256

Definition at line 58 of file gd.h.

#define gdNoFill   2

Definition at line 538 of file gd.h.

#define gdPie   gdArc

Definition at line 536 of file gd.h.

#define gdRedMax   255

Definition at line 84 of file gd.h.

#define gdStyled   (-2)

Definition at line 219 of file gd.h.

#define gdStyledBrushed   (-4)

Definition at line 221 of file gd.h.

#define gdTiled   (-5)

Definition at line 222 of file gd.h.

#define gdTransparent   (-6)

Definition at line 226 of file gd.h.

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

Definition at line 410 of file gd.h.

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

Definition at line 418 of file gd.h.

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

Definition at line 87 of file gd.h.

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

Definition at line 90 of file gd.h.

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

Definition at line 89 of file gd.h.

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

Definition at line 88 of file gd.h.

#define PATHSEPARATOR   ":"

Definition at line 31 of file gd.h.


Typedef Documentation

typedef gdFont* gdFontPtr

Definition at line 210 of file gd.h.

typedef struct gdImageStruct gdImage
typedef gdImage* gdImagePtr

Definition at line 193 of file gd.h.

typedef struct gdPoint * gdPointPtr
typedef struct gdSink * gdSinkPtr
typedef struct gdSource * gdSourcePtr

Enumeration Type Documentation

Enumerator:
GD_PIXELATE_UPPERLEFT 
GD_PIXELATE_AVERAGE 
GD_PIXELATE_UPPERLEFT 
GD_PIXELATE_AVERAGE 

Definition at line 588 of file gd.h.


Function Documentation

int gdAlphaBlend ( int  dest,
int  src 
)

Definition at line 2877 of file gd.c.

                                    {
    int src_alpha = gdTrueColorGetAlpha(src);
    int dst_alpha, alpha, red, green, blue;
    int src_weight, dst_weight, tot_weight;

/* -------------------------------------------------------------------- */
/*      Simple cases we want to handle fast.                            */
/* -------------------------------------------------------------------- */
    if( src_alpha == gdAlphaOpaque )
        return src;

    dst_alpha = gdTrueColorGetAlpha(dst);
    if( src_alpha == gdAlphaTransparent )
        return dst;
    if( dst_alpha == gdAlphaTransparent )
        return src;

/* -------------------------------------------------------------------- */
/*      What will the source and destination alphas be?  Note that      */
/*      the destination weighting is substantially reduced as the       */
/*      overlay becomes quite opaque.                                   */
/* -------------------------------------------------------------------- */
    src_weight = gdAlphaTransparent - src_alpha;
    dst_weight = (gdAlphaTransparent - dst_alpha) * src_alpha / gdAlphaMax;
    tot_weight = src_weight + dst_weight;
    
/* -------------------------------------------------------------------- */
/*      What red, green and blue result values will we use?             */
/* -------------------------------------------------------------------- */
    alpha = src_alpha * dst_alpha / gdAlphaMax;

    red = (gdTrueColorGetRed(src) * src_weight
           + gdTrueColorGetRed(dst) * dst_weight) / tot_weight;
    green = (gdTrueColorGetGreen(src) * src_weight
           + gdTrueColorGetGreen(dst) * dst_weight) / tot_weight;
    blue = (gdTrueColorGetBlue(src) * src_weight
           + gdTrueColorGetBlue(dst) * dst_weight) / tot_weight;

/* -------------------------------------------------------------------- */
/*      Return merged result.                                           */
/* -------------------------------------------------------------------- */
    return ((alpha << 24) + (red << 16) + (green << 8) + blue);

}

Here is the caller graph for this function:

void* gdDPExtractData ( struct gdIOCtx ctx,
int size 
)

Definition at line 95 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 && dp->freeOK) {
                     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:

int gdFontCacheSetup ( void  )
void gdFontCacheShutdown ( void  )
void gdFree ( void *  m)

Here is the caller graph for this function:

void gdImageAABlend ( gdImagePtr  im)

Definition at line 1006 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 gdImageAALine ( gdImagePtr  im,
int  x1,
int  y1,
int  x2,
int  y2,
int  color 
)

Definition at line 1285 of file gd.c.

{
       /* keep them as 32bits */
       long x, y, inc;
       long dx, dy,tmp;

       if (y1 < 0 && y2 < 0) {
              return;
       }
       if (y1 < 0) {
              x1 += (y1 * (x1 - x2)) / (y2 - y1);
              y1 = 0;
       }
       if (y2 < 0) {
              x2 += (y2 * (x1 - x2)) / (y2 - y1);
              y2 = 0;
       }

       /* bottom edge */
       if (y1 >= im->sy && y2 >= im->sy) {
              return;
       }
       if (y1 >= im->sy) {
              x1 -= ((im->sy - y1) * (x1 - x2)) / (y2 - y1);
              y1 = im->sy - 1;
       }
       if (y2 >= im->sy) {
              x2 -= ((im->sy - y2) * (x1 - x2)) / (y2 - y1);
              y2 = im->sy - 1;
       }

       /* left edge */
       if (x1 < 0 && x2 < 0) {
              return;
       }
       if (x1 < 0) {
              y1 += (x1 * (y1 - y2)) / (x2 - x1);
              x1 = 0;
       }
       if (x2 < 0) {
              y2 += (x2 * (y1 - y2)) / (x2 - x1);
              x2 = 0;
       }
       /* right edge */
       if (x1 >= im->sx && x2 >= im->sx) {
              return;
       }
       if (x1 >= im->sx) {
              y1 -= ((im->sx - x1) * (y1 - y2)) / (x2 - x1);
              x1 = im->sx - 1;
       }
       if (x2 >= im->sx) {
              y2 -= ((im->sx - x2) * (y1 - y2)) / (x2 - x1);
              x2 = im->sx - 1;
       }

       dx = x2 - x1;
       dy = y2 - y1;

       if (dx == 0 && dy == 0) {
              return;
       }
       if (abs(dx) > abs(dy)) {
              if (dx < 0) {
                     tmp = x1;
                     x1 = x2;
                     x2 = tmp;
                     tmp = y1;
                     y1 = y2;
                     y2 = tmp;
                     dx = x2 - x1;
                     dy = y2 - y1;
              }
              x = x1 << 16;
              y = y1 << 16;
              inc = (dy * 65536) / dx;
              while ((x >> 16) <= x2) {
                     gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (y >> 8) & 0xFF);
                     if ((y >> 16) + 1 < im->sy) {
                            gdImageSetAAPixelColor(im, x >> 16, (y >> 16) + 1,col, (~y >> 8) & 0xFF);
                     }
                     x += (1 << 16);
                     y += inc;
              }
       } else {
              if (dy < 0) {
                     tmp = x1;
                     x1 = x2;
                     x2 = tmp;
                     tmp = y1;
                     y1 = y2;
                     y2 = tmp;
                     dx = x2 - x1;
                     dy = y2 - y1;
              }
              x = x1 << 16;
              y = y1 << 16;
              inc = (dx * 65536) / dy;
              while ((y>>16) <= y2) {
                     gdImageSetAAPixelColor(im, x >> 16, y >> 16, col, (x >> 8) & 0xFF);
                     if ((x >> 16) + 1 < im->sx) {
                            gdImageSetAAPixelColor(im, (x >> 16) + 1, (y >> 16),col, (~x >> 8) & 0xFF);
                     }
                     x += inc;
                     y += (1<<16);
              }
       }
}

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 2922 of file gd.c.

{
       im->alphaBlendingFlag = alphaBlendingArg;
}

Here is the caller graph for this function:

void gdImageAntialias ( gdImagePtr  im,
int  antialias 
)

Definition at line 2927 of file gd.c.

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

Definition at line 1664 of file gd.c.

{
       if ((s % 360) == (e % 360)) {
              gdImageEllipse(im, cx, cy, w, h, color);
       } else {
              gdImageFilledArc(im, cx, cy, w, h, s, e, color, gdNoFill);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int gdImageBrightness ( gdImagePtr  src,
int  brightness 
)

Definition at line 82 of file gd_filter.c.

{
       int x, y;
       int r,g,b,a;
       int new_pxl, pxl;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;
       f = GET_PIXEL_FUNCTION(src);

       if (src==NULL || (brightness < -255 || brightness>255)) {
              return 0;
       }

       if (brightness==0) {
              return 1;
       }

       for (y=0; y<src->sy; ++y) {
              for (x=0; x<src->sx; ++x) {
                     pxl = f (src, x, y);

                     r = gdImageRed(src, pxl);
                     g = gdImageGreen(src, pxl);
                     b = gdImageBlue(src, pxl);
                     a = gdImageAlpha(src, pxl);

                     r = r + brightness;
                     g = g + brightness;
                     b = b + brightness;

                     r = (r > 255)? 255 : ((r < 0)? 0:r);
                     g = (g > 255)? 255 : ((g < 0)? 0:g);
                     b = (b > 255)? 255 : ((b < 0)? 0:b);

                     new_pxl = gdImageColorAllocateAlpha(src, (int)r, (int)g, (int)b, a);
                     if (new_pxl == -1) {
                            new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a);
                     }
                     gdImageSetPixel (src, x, y, new_pxl);
              }
       }
       return 1;
}

Here is the caller graph for this function:

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

Definition at line 1538 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 1564 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 gdImageColor ( gdImagePtr  src,
const int  red,
const int  green,
const int  blue,
const int  alpha 
)

Definition at line 187 of file gd_filter.c.

{
       int x, y;
       int new_pxl, pxl;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;

       if (src == NULL) {
              return 0;
       }

       f = GET_PIXEL_FUNCTION(src);

       for (y=0; y<src->sy; ++y) {
              for (x=0; x<src->sx; ++x) {
                     int r,g,b,a;

                     pxl = f(src, x, y);
                     r = gdImageRed(src, pxl);
                     g = gdImageGreen(src, pxl);
                     b = gdImageBlue(src, pxl);
                     a = gdImageAlpha(src, pxl);

                     r = r + red;
                     g = g + green;
                     b = b + blue;
                     a = a + alpha;

                     r = (r > 255)? 255 : ((r < 0)? 0 : r);
                     g = (g > 255)? 255 : ((g < 0)? 0 : g);
                     b = (b > 255)? 255 : ((b < 0)? 0 : b);
                     a = (a > 127)? 127 : ((a < 0)? 0 : a);

                     new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);
                     if (new_pxl == -1) {
                            new_pxl = gdImageColorClosestAlpha(src, r, g, b, a);
                     }
                     gdImageSetPixel (src, x, y, new_pxl);
              }
       }
       return 1;
}

Here is the caller graph for this function:

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

Definition at line 475 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 480 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 257 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 262 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->alpha[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 428 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:

void gdImageColorDeallocate ( gdImagePtr  im,
int  color 
)

Definition at line 583 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 453 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 458 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 caller graph for this function:

Definition at line 15 of file gd_color.c.

{
       unsigned long *buf; /* stores our calculations */
       unsigned long *bp; /* buf ptr */
       int color, rgb;
       int x,y;
       int count;

       if( !im1->trueColor ) {
              return -1; /* im1 must be True Color */
       }
       if( im2->trueColor ) {
              return -2; /* im2 must be indexed */
       }
       if( (im1->sx != im2->sx) || (im1->sy != im2->sy) ) {
              return -3; /* the images are meant to be the same dimensions */
       }
       if (im2->colorsTotal<1) {
              return -4; /* At least 1 color must be allocated */
       }

       buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
       memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );

       for (x=0; x<im1->sx; x++) {
              for( y=0; y<im1->sy; y++ ) {
                     color = im2->pixels[y][x];
                     rgb = im1->tpixels[y][x];
                     bp = buf + (color * 5);
                     (*(bp++))++;
                     *(bp++) += gdTrueColorGetRed(rgb);
                     *(bp++) += gdTrueColorGetGreen(rgb);
                     *(bp++) += gdTrueColorGetBlue(rgb);
                     *(bp++) += gdTrueColorGetAlpha(rgb);
              }
       }
       bp = buf;
       for (color=0; color<im2->colorsTotal; color++) {
              count = *(bp++);
              if( count > 0 ) {
                     im2->red[color]             = *(bp++) / count;
                     im2->green[color]    = *(bp++) / count;
                     im2->blue[color]     = *(bp++) / count;
                     im2->alpha[color]    = *(bp++) / count;
              } else {
                     bp += 4;
              }
       }
       gdFree(buf);
       return 0;
}
int gdImageColorResolve ( gdImagePtr  im,
int  r,
int  g,
int  b 
)

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

void gdImageColorTransparent ( gdImagePtr  im,
int  color 
)

Definition at line 592 of file gd.c.

{
       if (!im->trueColor) {
              if (im->transparent != -1) {
                     im->alpha[im->transparent] = gdAlphaOpaque;
              }
              if (color > -1 && color < im->colorsTotal && color < gdMaxColors) {
                     im->alpha[color] = gdAlphaTransparent;
              } else {
                     return;
              }
       }
       im->transparent = color;
}

Here is the caller graph for this function:

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

Here is the caller graph for this function:

int gdImageContrast ( gdImagePtr  src,
double  contrast 
)

Definition at line 127 of file gd_filter.c.

{
       int x, y;
       int r,g,b,a;
       double rf,gf,bf;
       int new_pxl, pxl;
       typedef int (*FuncPtr)(gdImagePtr, int, int);

       FuncPtr f;
       f = GET_PIXEL_FUNCTION(src);

       if (src==NULL) {
              return 0;
       }

       contrast = (double)(100.0-contrast)/100.0;
       contrast = contrast*contrast;

       for (y=0; y<src->sy; ++y) {
              for (x=0; x<src->sx; ++x) {
                     pxl = f(src, x, y);

                     r = gdImageRed(src, pxl);
                     g = gdImageGreen(src, pxl);
                     b = gdImageBlue(src, pxl);
                     a = gdImageAlpha(src, pxl);

                     rf = (double)r/255.0;
                     rf = rf-0.5;
                     rf = rf*contrast;
                     rf = rf+0.5;
                     rf = rf*255.0;

                     bf = (double)b/255.0;
                     bf = bf-0.5;
                     bf = bf*contrast;
                     bf = bf+0.5;
                     bf = bf*255.0;

                     gf = (double)g/255.0;
                     gf = gf-0.5;
                     gf = gf*contrast;
                     gf = gf+0.5;
                     gf = gf*255.0;

                     rf = (rf > 255.0)? 255.0 : ((rf < 0.0)? 0.0:rf);
                     gf = (gf > 255.0)? 255.0 : ((gf < 0.0)? 0.0:gf);
                     bf = (bf > 255.0)? 255.0 : ((bf < 0.0)? 0.0:bf);

                     new_pxl = gdImageColorAllocateAlpha(src, (int)rf, (int)gf, (int)bf, a);
                     if (new_pxl == -1) {
                            new_pxl = gdImageColorClosestAlpha(src, (int)rf, (int)gf, (int)bf, a);
                     }
                     gdImageSetPixel (src, x, y, new_pxl);
              }
       }
       return 1;
}

Here is the caller graph for this function:

int gdImageConvolution ( gdImagePtr  src,
float  ft[3][3],
float  filter_div,
float  offset 
)

Definition at line 230 of file gd_filter.c.

{
       int         x, y, i, j, new_a;
       float       new_r, new_g, new_b;
       int         new_pxl, pxl=0;
       gdImagePtr  srcback;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;

       if (src==NULL) {
              return 0;
       }

       /* We need the orinal image with each safe neoghb. pixel */
       srcback = gdImageCreateTrueColor (src->sx, src->sy);
       if (srcback==NULL) {
              return 0;
       }

       gdImageSaveAlpha(srcback, 1);
       new_pxl = gdImageColorAllocateAlpha(srcback, 0, 0, 0, 127);
       gdImageFill(srcback, 0, 0, new_pxl);

       gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);

       f = GET_PIXEL_FUNCTION(src);

       for ( y=0; y<src->sy; y++) {
              for(x=0; x<src->sx; x++) {
                     new_r = new_g = new_b = 0;
                     new_a = gdImageAlpha(srcback, pxl);

                     for (j=0; j<3; j++) {
                            int yv = MIN(MAX(y - 1 + j, 0), src->sy - 1);
                            for (i=0; i<3; i++) {
                                    pxl = f(srcback, MIN(MAX(x - 1 + i, 0), src->sx - 1), yv);
                                   new_r += (float)gdImageRed(srcback, pxl) * filter[j][i];
                                   new_g += (float)gdImageGreen(srcback, pxl) * filter[j][i];
                                   new_b += (float)gdImageBlue(srcback, pxl) * filter[j][i];
                            }
                     }

                     new_r = (new_r/filter_div)+offset;
                     new_g = (new_g/filter_div)+offset;
                     new_b = (new_b/filter_div)+offset;

                     new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);
                     new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);
                     new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);

                     new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
                     if (new_pxl == -1) {
                            new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
                     }
                     gdImageSetPixel (src, x, y, new_pxl);
              }
       }
       gdImageDestroy(srcback);
       return 1;
}

Here is the caller graph for this function:

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

Definition at line 2151 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.
               */

              if (src->trueColor) {
                     for (y = 0; (y < h); y++) {
                            for (x = 0; (x < w); x++) {
                                   int c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y);
                                   gdImageSetPixel (dst, dstX + x, dstY + y, c);
                            }
                     }
              } else {
                     /* source is palette based */
                     for (y = 0; (y < h); y++) {
                            for (x = 0; (x < w); x++) {
                                   int c = gdImageGetPixel (src, srcX + x, srcY + y);
                                   if (c != src->transparent) {
                                          gdImageSetPixel(dst, dstX + x, dstY + y, gdTrueColorAlpha(src->red[c], src->green[c], src->blue[c], src->alpha[c]));
                                   }
                            }
                     }
              }
              return;
       }

       /* Destination is palette based */
       if (src->trueColor) { /* But source is truecolor (Ouch!) */
              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);

                            /* Get best match possible. */
                            nc = gdImageColorResolveAlpha(dst, gdTrueColorGetRed(c), gdTrueColorGetGreen(c), gdTrueColorGetBlue(c), gdTrueColorGetAlpha(c));

                            gdImageSetPixel(dst, tox, toy, nc);
                            tox++;
                     }
                     toy++;
              }
              return;
       }

       /* Palette based to palette based */
       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:

Here is the caller 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 2250 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 = (int)(gdImageRed (src, c) * (pct / 100.0) + gdImageRed (dst, dc) * ((100 - pct) / 100.0));
                            ncG = (int)(gdImageGreen (src, c) * (pct / 100.0) + gdImageGreen (dst, dc) * ((100 - pct) / 100.0));
                            ncB = (int)(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:

Here is the caller 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 2290 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.29900f * gdImageRed(dst, dc)) + (0.58700f * gdImageGreen(dst, dc)) + (0.11400f * gdImageBlue(dst, dc));

                            ncR = (int)(gdImageRed (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0));
                            ncG = (int)(gdImageGreen (src, c) * (pct / 100.0f) + g * ((100 - pct) / 100.0));
                            ncB = (int)(gdImageBlue (src, c) * (pct / 100.0f) + 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:

Here is the caller 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;
       double sy1, sy2, sx1, sx2;

       if (!dst->trueColor) {
              gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
              return;
       }
       for (y = dstY; (y < dstY + dstH); y++) {
              sy1 = ((double) y - (double) dstY) * (double) srcH / (double) dstH;
              sy2 = ((double) (y + 1) - (double) dstY) * (double) srcH / (double) dstH;
              for (x = dstX; (x < dstX + dstW); x++) {
                     double sx, sy;
                     double spixels = 0;
                     double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
                     double alpha_factor, alpha_sum = 0.0, contrib_sum = 0.0;
                     sx1 = ((double) x - (double) dstX) * (double) srcW / dstW;
                     sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / dstW;
                     sy = sy1;
                     do {
                            double yportion;
                            if (floor_cast(sy) == floor_cast(sy1)) {
                                   yportion = 1.0f - (sy - floor_cast(sy));
                                   if (yportion > sy2 - sy1) {
                                          yportion = sy2 - sy1;
                                   }
                                   sy = floor_cast(sy);
                            } else if (sy == floorf(sy2)) {
                                   yportion = sy2 - floor_cast(sy2);
                            } else {
                                   yportion = 1.0f;
                            }
                            sx = sx1;
                            do {
                                   double xportion;
                                   double pcontribution;
                                   int p;
                                   if (floorf(sx) == floor_cast(sx1)) {
                                          xportion = 1.0f - (sx - floor_cast(sx));
                                          if (xportion > sx2 - sx1) {
                                                 xportion = sx2 - sx1;
                                          }
                                          sx = floor_cast(sx);
                                   } else if (sx == floorf(sx2)) {
                                          xportion = sx2 - floor_cast(sx2);
                                   } else {
                                          xportion = 1.0f;
                                   }
                                   pcontribution = xportion * yportion;
                                   p = gdImageGetTrueColorPixel(src, (int) sx + srcX, (int) sy + srcY);

                                   alpha_factor = ((gdAlphaMax - gdTrueColorGetAlpha(p))) * pcontribution;
                                   red += gdTrueColorGetRed (p) * alpha_factor;
                                   green += gdTrueColorGetGreen (p) * alpha_factor;
                                   blue += gdTrueColorGetBlue (p) * alpha_factor;
                                   alpha += gdTrueColorGetAlpha (p) * pcontribution;
                                   alpha_sum += alpha_factor;
                                   contrib_sum += pcontribution;
                                   spixels += xportion * yportion;
                                   sx += 1.0f;
                            }
                            while (sx < sx2);

                            sy += 1.0f;
                     }

                     while (sy < sy2);

                     if (spixels != 0.0f) {
                            red /= spixels;
                            green /= spixels;
                            blue /= spixels;
                            alpha /= spixels;
                            alpha += 0.5;
                     }
                     if ( alpha_sum != 0.0f) {
                            if( contrib_sum != 0.0f) {
                                   alpha_sum /= contrib_sum;
                            }
                            red /= alpha_sum;
                            green /= alpha_sum;
                            blue /= alpha_sum;
                     }
                     /* Clamping to allow for rounding errors above */
                     if (red > 255.0f) {
                            red = 255.0f;
                     }
                     if (green > 255.0f) {
                            green = 255.0f;
                     }
                     if (blue > 255.0f) {
                            blue = 255.0f;
                     }
                     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:

Here is the caller 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 2344 of file gd.c.

{
       int c;
       int x, y;
       int tox, toy;
       int ydest;
       int i;
       int colorMap[gdMaxColors];
       /* Stretch vectors */
       int *stx, *sty;
       /* We only need to use floating point to determine the correct stretch vector for one line's worth. */
       double accum;
       
       if (overflow2(sizeof(int), srcW)) {
              return;
       }
       if (overflow2(sizeof(int), srcH)) {
              return;
       }

       stx = (int *) gdMalloc (sizeof (int) * srcW);
       sty = (int *) gdMalloc (sizeof (int) * srcH);
       accum = 0;

       /* Fixed by Mao Morimoto 2.0.16 */
       for (i = 0; (i < srcW); i++) {
              stx[i] = dstW * (i+1) / srcW - dstW * i / srcW ;
       }
       for (i = 0; (i < srcH); i++) {
              sty[i] = dstH * (i+1) / srcH - dstH * i / srcH ;
       }
       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) {
                                                 /* 2.0.21, TK: not tox++ */
                                                 tox += stx[x - srcX];
                                                 continue;
                                          }
                                   } else {
                                          /* TK: old code follows */
                                          mapTo = gdImageGetTrueColorPixel (src, x, y);
                                          /* Added 7/24/95: support transparent copies */
                                          if (gdImageGetTransparent (src) == mapTo) {
                                                 /* 2.0.21, TK: not tox++ */
                                                 tox += stx[x - srcX];
                                                 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:

gdImagePtr gdImageCreate ( int  sx,
int  sy 
)

Definition at line 123 of file gd.c.

{
       int i;
       gdImagePtr im;

       if (overflow2(sx, sy)) {
              return NULL;
       }

       if (overflow2(sizeof(unsigned char *), sy)) {
              return NULL;
       }

       im = (gdImage *) gdCalloc(1, 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 142 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:

Here is the caller graph for this function:

Definition at line 227 of file gd_gd2.c.

{
       gdIOCtx *in = gdNewFileCtx(inFile);
       gdImagePtr im;

       im = gdImageCreateFromGd2Ctx(in);

       in->gd_free(in);

       return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 249 of file gd_gd2.c.

{
       int sx, sy;
       int i;
       int ncx, ncy, nc, cs, cx, cy;
       int x, y, ylo, yhi, xlo, xhi;
       int vers, fmt;
       t_chunk_info *chunkIdx = NULL;     /* So we can gdFree it with impunity. */
       unsigned char *chunkBuf = NULL;    /* So we can gdFree it with impunity. */
       int chunkNum = 0;
       int chunkMax = 0;
       uLongf chunkLen;
       int chunkPos = 0;
       int compMax = 0;
       int bytesPerPixel;
       char *compBuf = NULL;              /* So we can gdFree it with impunity. */

       gdImagePtr im;

       /* Get the header */
       if (!(im = _gd2CreateFromFile(in, &sx, &sy, &cs, &vers, &fmt, &ncx, &ncy, &chunkIdx))) {
               return 0;
       }

       bytesPerPixel = im->trueColor ? 4 : 1;
       nc = ncx * ncy;

       if (gd2_compressed(fmt)) {
              /* Find the maximum compressed chunk size. */
              compMax = 0;
              for (i = 0; (i < nc); i++) {
                     if (chunkIdx[i].size > compMax) {
                            compMax = chunkIdx[i].size;
                     }
              }
              compMax++;

              /* Allocate buffers */
              chunkMax = cs * bytesPerPixel * cs;
              if (chunkMax <= 0) {
                     return 0;
              }
              chunkBuf = gdCalloc(chunkMax, 1);
              compBuf = gdCalloc(compMax, 1);

              GD2_DBG(php_gd_error("Largest compressed chunk is %d bytes", compMax));
       }

       /* Read the data... */
       for (cy = 0; (cy < ncy); cy++) {
              for (cx = 0; (cx < ncx); cx++) {
                     ylo = cy * cs;
                     yhi = ylo + cs;
                     if (yhi > im->sy) {
                            yhi = im->sy;
                     }

                     GD2_DBG(php_gd_error("Processing Chunk %d (%d, %d), y from %d to %d", chunkNum, cx, cy, ylo, yhi));

                     if (gd2_compressed(fmt)) {
                            chunkLen = chunkMax;

                            if (!_gd2ReadChunk(chunkIdx[chunkNum].offset, compBuf, chunkIdx[chunkNum].size, (char *) chunkBuf, &chunkLen, in)) {
                                   GD2_DBG(php_gd_error("Error reading comproessed chunk"));
                                   goto fail2;
                            }

                            chunkPos = 0;
                     }

                     for (y = ylo; (y < yhi); y++) {
                            xlo = cx * cs;
                            xhi = xlo + cs;
                            if (xhi > im->sx) {
                                   xhi = im->sx;
                            }

                            if (!gd2_compressed(fmt)) {
                                   for (x = xlo; x < xhi; x++) {
                                          if (im->trueColor) {
                                                 if (!gdGetInt(&im->tpixels[y][x], in)) {
                                                        im->tpixels[y][x] = 0;
                                                 }
                                          } else {
                                                 int ch;
                                                 if (!gdGetByte(&ch, in)) {
                                                        ch = 0;
                                                 }
                                                 im->pixels[y][x] = ch;
                                          }
                                   }
                            } else {
                                   for (x = xlo; x < xhi; x++) {
                                          if (im->trueColor) {
                                                 /* 2.0.1: work around a gcc bug by being verbose. TBB */
                                                 int a = chunkBuf[chunkPos++] << 24;
                                                 int r = chunkBuf[chunkPos++] << 16;
                                                 int g = chunkBuf[chunkPos++] << 8;
                                                 int b = chunkBuf[chunkPos++];
                                                 im->tpixels[y][x] = a + r + g + b;
                                          } else {
                                                 im->pixels[y][x] = chunkBuf[chunkPos++];
                                          }
                                   }
                            }
                     }
                     chunkNum++;
              }
       }

       GD2_DBG(php_gd_error("Freeing memory"));

       if (chunkBuf) {
              gdFree(chunkBuf);
       }
       if (compBuf) {
              gdFree(compBuf);
       }
       if (chunkIdx) {
              gdFree(chunkIdx);
       }

       GD2_DBG(php_gd_error("Done"));

       return im;

fail2:
       gdImageDestroy(im);
       if (chunkBuf) {
              gdFree(chunkBuf);
       }
       if (compBuf) {
              gdFree(compBuf);
       }
       if (chunkIdx) {
              gdFree(chunkIdx);
       }

       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageCreateFromGd2Part ( FILE *  in,
int  srcx,
int  srcy,
int  w,
int  h 
)

Definition at line 400 of file gd_gd2.c.

{
       gdImagePtr im;
       gdIOCtx *in = gdNewFileCtx(inFile);

       im = gdImageCreateFromGd2PartCtx(in, srcx, srcy, w, h);

       in->gd_free(in);

       return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageCreateFromGd2PartCtx ( gdIOCtxPtr  in,
int  srcx,
int  srcy,
int  w,
int  h 
)

Here is the caller graph for this function:

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

Definition at line 112 of file gd_gif_in.c.

{
       gdIOCtx              *fd = gdNewFileCtx(fdFile);
       gdImagePtr           im = 0;

       im = gdImageCreateFromGifCtx(fd);

       fd->gd_free(fd);

       return im;
}

Here is the call graph for this function:

Definition at line 125 of file gd_gif_in.c.

{
       int BitPixel;
#if 0
       int ColorResolution;
       int Background;
       int AspectRatio;
#endif
       int Transparent = (-1);
       unsigned char   buf[16];
       unsigned char   c;
       unsigned char   ColorMap[3][MAXCOLORMAPSIZE];
       unsigned char   localColorMap[3][MAXCOLORMAPSIZE];
       int             imw, imh, screen_width, screen_height;
       int             gif87a, useGlobalColormap;
       int             bitPixel;
       int           i;
       /*1.4//int             imageCount = 0; */

       int ZeroDataBlock = FALSE;
       int haveGlobalColormap;
       gdImagePtr im = 0;

       /*1.4//imageNumber = 1; */
       if (! ReadOK(fd,buf,6)) {
              return 0;
       }
       if (strncmp((char *)buf,"GIF",3) != 0) {
              return 0;
       }

       if (memcmp((char *)buf+3, "87a", 3) == 0) {
              gif87a = 1;
       } else if (memcmp((char *)buf+3, "89a", 3) == 0) {
              gif87a = 0;
       } else {
              return 0;
       }

       if (! ReadOK(fd,buf,7)) {
              return 0;
       }

       BitPixel        = 2<<(buf[4]&0x07);
#if 0
       ColorResolution = (int) (((buf[4]&0x70)>>3)+1);
       Background      = buf[5];
       AspectRatio     = buf[6];
#endif
       screen_width = imw = LM_to_uint(buf[0],buf[1]);
       screen_height = imh = LM_to_uint(buf[2],buf[3]);

       haveGlobalColormap = BitSet(buf[4], LOCALCOLORMAP);    /* Global Colormap */
       if (haveGlobalColormap) {
              if (ReadColorMap(fd, BitPixel, ColorMap)) {
                     return 0;
              }
       }

       for (;;) {
              int top, left;
              int width, height;

              if (! ReadOK(fd,&c,1)) {
                     return 0;
              }
              if (c == ';') {         /* GIF terminator */
                     goto terminated;
              }

              if (c == '!') {         /* Extension */
                     if (! ReadOK(fd,&c,1)) {
                            return 0;
                     }
                     DoExtension(fd, c, &Transparent, &ZeroDataBlock);
                     continue;
              }

              if (c != ',') {         /* Not a valid start character */
                     continue;
              }

              /*1.4//++imageCount; */

              if (! ReadOK(fd,buf,9)) {
                     return 0;
              }

              useGlobalColormap = ! BitSet(buf[8], LOCALCOLORMAP);

              bitPixel = 1<<((buf[8]&0x07)+1);
              left = LM_to_uint(buf[0], buf[1]);
              top = LM_to_uint(buf[2], buf[3]);
              width = LM_to_uint(buf[4], buf[5]);
              height = LM_to_uint(buf[6], buf[7]);

              if (left + width > screen_width || top + height > screen_height) {
                     if (VERBOSE) {
                            printf("Frame is not confined to screen dimension.\n");
                     }
                     return 0;
              }

              if (!(im = gdImageCreate(width, height))) {
                     return 0;
              }
              im->interlace = BitSet(buf[8], INTERLACE);
              if (!useGlobalColormap) {
                     if (ReadColorMap(fd, bitPixel, localColorMap)) { 
                            gdImageDestroy(im);
                            return 0;
                     }
                     ReadImage(im, fd, width, height, localColorMap, 
                                   BitSet(buf[8], INTERLACE), &ZeroDataBlock);
              } else {
                     if (!haveGlobalColormap) {
                            gdImageDestroy(im);
                            return 0;
                     }
                     ReadImage(im, fd, width, height,
                                          ColorMap, 
                                          BitSet(buf[8], INTERLACE), &ZeroDataBlock);
              }
              if (Transparent != (-1)) {
                     gdImageColorTransparent(im, Transparent);
              }
              goto terminated;
       }

terminated:
       /* Terminator before any image was declared! */
       if (!im) {
              return 0;
       }
       if (!im->colorsTotal) {
              gdImageDestroy(im);
              return 0;
       }
       /* Check for open colors at the end, so
          we can reduce colorsTotal and ultimately
          BitsPerPixel */
       for (i=((im->colorsTotal-1)); (i>=0); i--) {
              if (im->open[i]) {
                     im->colorsTotal--;
              } else {
                     break;
              }
       }
       return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 99 of file gd_gif_in.c.

{
       gdIOCtx         *in = gdNewSSCtx(inSource, NULL);
       gdImagePtr      im;

       im = gdImageCreateFromGifCtx(in);

       in->gd_free(in);

       return im;
}

Here is the call graph for this function:

gdImagePtr gdImageCreateFromJpeg ( FILE *  infile,
int  ignore_warning 
)

Here is the caller graph for this function:

gdImagePtr gdImageCreateFromJpegCtx ( gdIOCtx infile,
int  ignore_warning 
)

Here is the caller graph for this function:

Here is the caller graph for this function:

Definition at line 43 of file gd_ss.c.

{
       php_gd_error("PNG support is not available");
       return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageCreateFromWBMP ( FILE *  inFile)

Definition at line 169 of file gd_wbmp.c.

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

       return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 127 of file gd_wbmp.c.

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

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

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

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

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

       freewbmp(wbmp);

       return im;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 33 of file xbm.c.

{
       char fline[MAX_XBM_LINE_SIZE];
       char iname[MAX_XBM_LINE_SIZE];
       char *type;
       int value;
       unsigned int width = 0, height = 0;
       int fail = 0;
       int max_bit = 0;

       gdImagePtr im;
       int bytes = 0, i;
       int bit, x = 0, y = 0;
       int ch;
       char h[8];
       unsigned int b;

       rewind(fd);
       while (fgets(fline, MAX_XBM_LINE_SIZE, fd)) {
              fline[MAX_XBM_LINE_SIZE-1] = '\0';
              if (strlen(fline) == MAX_XBM_LINE_SIZE-1) {
                     return 0;
              }
              if (sscanf(fline, "#define %s %d", iname, &value) == 2) {
                     if (!(type = strrchr(iname, '_'))) {
                            type = iname;
                     } else {
                            type++;
                     }

                     if (!strcmp("width", type)) {
                            width = (unsigned int) value;
                     }
                     if (!strcmp("height", type)) {
                            height = (unsigned int) value;
                     }
              } else {
                     if ( sscanf(fline, "static unsigned char %s = {", iname) == 1
                       || sscanf(fline, "static char %s = {", iname) == 1)
                     {
                            max_bit = 128;
                     } else if (sscanf(fline, "static unsigned short %s = {", iname) == 1
                                   || sscanf(fline, "static short %s = {", iname) == 1)
                     {
                            max_bit = 32768;
                     }
                     if (max_bit) {
                            bytes = (width * height / 8) + 1;
                            if (!bytes) {
                                   return 0;
                            }
                            if (!(type = strrchr(iname, '_'))) {
                                   type = iname;
                            } else {
                                   type++;
                            }
                            if (!strcmp("bits[]", type)) {
                                   break;
                            }
                     }
              }
       }
       if (!bytes || !max_bit) {
              return 0;
       }

       if(!(im = gdImageCreate(width, height))) {
              return 0;
       }
       gdImageColorAllocate(im, 255, 255, 255);
       gdImageColorAllocate(im, 0, 0, 0);
       h[2] = '\0';
       h[4] = '\0';
       for (i = 0; i < bytes; i++) {
              while (1) {
                     if ((ch=getc(fd)) == EOF) {
                            fail = 1;
                            break;
                     }
                     if (ch == 'x') {
                            break;
                     }
              }
              if (fail) {
                     break;
              }
              /* Get hex value */
              if ((ch=getc(fd)) == EOF) {
                     break;
              }
              h[0] = ch;
              if ((ch=getc(fd)) == EOF) {
                     break;
              }
              h[1] = ch;
              if (max_bit == 32768) {
                     if ((ch=getc(fd)) == EOF) {
                            break;
                     }
                     h[2] = ch;
                     if ((ch=getc(fd)) == EOF) {
                            break;
                     }
                     h[3] = ch;
              }
              sscanf(h, "%x", &b);
              for (bit = 1; bit <= max_bit; bit = bit << 1) {
                     gdImageSetPixel(im, x++, y, (b & bit) ? 1 : 0);
                     if (x == im->sx) {
                            x = 0;
                            y++;
                            if (y == im->sy) {
                                   return im;
                            }
                            break;
                     }
              }
       }

       php_gd_error("EOF before image was complete");
       gdImageDestroy(im);
       return 0;
}

Here is the call graph for this function:

gdImagePtr gdImageCreateFromXpm ( char *  filename)
gdImagePtr gdImageCreatePaletteFromTrueColor ( gdImagePtr  im,
int  ditherFlag,
int  colorsWanted 
)

Definition at line 1759 of file gd_topal.c.

{
       gdImagePtr nim;
       gdImageTrueColorToPaletteBody(im, dither, colorsWanted, &nim);
       return nim;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 174 of file gd.c.

{
       int i;
       gdImagePtr im;

       if (overflow2(sx, sy)) {
              return NULL;
       }

       if (overflow2(sizeof(unsigned char *), sy)) {
              return NULL;
       }
       
       if (overflow2(sizeof(int), sx)) {
              return NULL;
       }

       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 1396 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;
              }
              wid = (int)(thick * sin(atan2(dy, dx)));
              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:

void gdImageDestroy ( gdImagePtr  im)

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

Definition at line 410 of file gd_filter.c.

{
       float filter[3][3] = {{-1.0,0.0,-1.0},
                            {0.0,4.0,0.0},
                            {-1.0,0.0,-1.0}};

       return gdImageConvolution(src, filter, 1, 127);
}

Here is the caller graph for this function:

void gdImageEllipse ( gdImagePtr  im,
int  cx,
int  cy,
int  w,
int  h,
int  c 
)

Integer Ellipse functions (gdImageEllipse and gdImageFilledEllipse) Function added by Pierre-Alain Joye 02/08/2003 (paj@p.nosp@m.earf.nosp@m.r.org) See the ellipse function simplification for the equation as well as the midpoint algorithm.

Definition at line 17 of file gd_arc.c.

{
       int x=0,mx1=0,mx2=0,my1=0,my2=0;
       long aq,bq,dx,dy,r,rx,ry,a,b;

       a=w>>1;
       b=h>>1;
       gdImageSetPixel(im,mx+a, my, c);
       gdImageSetPixel(im,mx-a, my, c);
       mx1 = mx-a;my1 = my;
       mx2 = mx+a;my2 = my;

       aq = a * a;
       bq = b * b;
       dx = aq << 1;
       dy = bq << 1;
       r  = a * bq;
       rx = r << 1;
       ry = 0;
       x = a;
       while (x > 0){
              if (r > 0) {
                     my1++;my2--;
                     ry +=dx;
                     r  -=ry;
              }
              if (r <= 0){
                     x--;
                     mx1++;mx2--;
                     rx -=dy;
                     r  +=rx;
              }
              gdImageSetPixel(im,mx1, my1, c);
              gdImageSetPixel(im,mx1, my2, c);
              gdImageSetPixel(im,mx2, my1, c);
              gdImageSetPixel(im,mx2, my2, c);
       }
}

Here is the caller graph for this function:

Definition at line 428 of file gd_filter.c.

{
/*
       float filter[3][3] = {{1.0,1.0,1.0},
                            {0.0,0.0,0.0},
                            {-1.0,-1.0,-1.0}};
*/
       float filter[3][3] = {{ 1.5, 0.0, 0.0},
                             { 0.0, 0.0, 0.0},
                             { 0.0, 0.0,-1.5}};

       return gdImageConvolution(im, filter, 1, 127);
}

Here is the caller graph for this function:

void gdImageFill ( gdImagePtr  im,
int  x,
int  y,
int  color 
)

Definition at line 1858 of file gd.c.

{
       int l, x1, x2, dy;
       int oc;   /* old pixel value */
       int wx2,wy2;

       int alphablending_bak;

       /* stack of filled segments */
       /* struct seg stack[FILL_MAX],*sp = stack;; */
       struct seg *stack = NULL;
       struct seg *sp;

       if (!im->trueColor && nc > (im->colorsTotal -1)) {
              return;
       }

       alphablending_bak = im->alphaBlendingFlag;       
       im->alphaBlendingFlag = 0;

       if (nc==gdTiled){
              _gdImageFillTiled(im,x,y,nc);
              im->alphaBlendingFlag = alphablending_bak;
              return;
       }

       wx2=im->sx;wy2=im->sy;
       oc = gdImageGetPixel(im, x, y);
       if (oc==nc || x<0 || x>wx2 || y<0 || y>wy2) {
              im->alphaBlendingFlag = alphablending_bak;       
              return;
       }

       /* Do not use the 4 neighbors implementation with
        * small images
        */
       if (im->sx < 4) {
              int ix = x, iy = y, c;
              do {
                     do {
                            c = gdImageGetPixel(im, ix, iy);
                            if (c != oc) {
                                   goto done;
                            }
                            gdImageSetPixel(im, ix, iy, nc);
                     } while(ix++ < (im->sx -1));
                     ix = x;
              } while(iy++ < (im->sy -1));
              goto done;
       }

       stack = (struct seg *)safe_emalloc(sizeof(struct seg), ((int)(im->sy*im->sx)/4), 1);
       sp = stack;

       /* required! */
       FILL_PUSH(y,x,x,1);
       /* seed segment (popped 1st) */
       FILL_PUSH(y+1, x, x, -1);
       while (sp>stack) {
              FILL_POP(y, x1, x2, dy);

              for (x=x1; x>=0 && gdImageGetPixel(im,x, y)==oc; x--) {
                     gdImageSetPixel(im,x, y, nc);
              }
              if (x>=x1) {
                     goto skip;
              }
              l = x+1;

                /* leak on left? */
              if (l<x1) {
                     FILL_PUSH(y, l, x1-1, -dy);
              }
              x = x1+1;
              do {
                     for (; x<=wx2 && gdImageGetPixel(im,x, y)==oc; x++) {
                            gdImageSetPixel(im, x, y, nc);
                     }
                     FILL_PUSH(y, l, x-1, dy);
                     /* leak on right? */
                     if (x>x2+1) {
                            FILL_PUSH(y, x2+1, x-1, -dy);
                     }
skip:                for (x++; x<=x2 && (gdImageGetPixel(im, x, y)!=oc); x++);

                     l = x;
              } while (x<=x2);
       }

       efree(stack);

done:
       im->alphaBlendingFlag = alphablending_bak;       
}

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 1673 of file gd.c.

{
       gdPoint pts[3];
       int i;
       int lx = 0, ly = 0;
       int fx = 0, fy = 0;


    if ((s % 360)  == (e % 360)) {
              s = 0; e = 360;
       } else {
              if (s > 360) {
                     s = s % 360;
              }

              if (e > 360) {
                     e = e % 360;
              }

              while (s < 0) {
                     s += 360;
              }

              while (e < s) {
                     e += 360;
              }
              if (s == e) {
                     s = 0; 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 56 of file gd_arc.c.

{
       int x=0,mx1=0,mx2=0,my1=0,my2=0;
       long aq,bq,dx,dy,r,rx,ry,a,b;
       int i;
       int old_y1,old_y2;

       a=w>>1;
       b=h>>1;

       for (x = mx-a; x <= mx+a; x++) {
              gdImageSetPixel(im, x, my, c);
       }

       mx1 = mx-a;my1 = my;
       mx2 = mx+a;my2 = my;

       aq = a * a;
       bq = b * b;
       dx = aq << 1;
       dy = bq << 1;
       r  = a * bq;
       rx = r << 1;
       ry = 0;
       x = a;
       old_y2=-2;
       old_y1=-2;
       while (x > 0){
              if (r > 0) {
                     my1++;my2--;
                     ry +=dx;
                     r  -=ry;
              }
              if (r <= 0){
                     x--;
                     mx1++;mx2--;
                     rx -=dy;
                     r  +=rx;
              }
              if(old_y2!=my2){
                     for(i=mx1;i<=mx2;i++){
                            gdImageSetPixel(im,i,my1,c);
                     }
              }
              if(old_y2!=my2){
                     for(i=mx1;i<=mx2;i++){
                            gdImageSetPixel(im,i,my2,c);
                     }
              }
              old_y2 = my2;
              old_y1 = my1;
       }
}

Here is the call graph for this function:

void gdImageFilledPolygon ( gdImagePtr  im,
gdPointPtr  p,
int  n,
int  c 
)

Definition at line 2608 of file gd.c.

{
       int i;
       int y;
       int miny, maxy, pmaxy;
       int x1, y1;
       int x2, y2;
       int ind1, ind2;
       int ints;
       int fill_color;

       if (n <= 0) {
              return;
       }

       if (overflow2(sizeof(int), 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;
              }
              if (overflow2(sizeof(int), im->polyAllocated)) {
                     return;
              }
              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;
              }
       }
       pmaxy = maxy;
       /* 2.0.16: Optimization by Ilia Chipitsine -- don't waste time offscreen */
       if (miny < 0) {
              miny = 0;
       }
       if (maxy >= gdImageSY(im)) {
              maxy = gdImageSY(im) - 1;
       }

       /* 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 == pmaxy && y == y2) {
                            im->polyInts[ints++] = x2;
                     }
              }
              qsort(im->polyInts, ints, sizeof(int), gdCompareInt);

              for (i = 0; i < ints - 1; 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 2106 of file gd.c.

{
       int x, y;


       if (x1 == x2 && y1 == y2) {
              gdImageSetPixel(im, x1, y1, color);
              return;
       }

       if (x1 > x2) {
              x = x1;
              x1 = x2;
              x2 = x;
       }

       if (y1 > y2) {
              y = y1;
              y1 = y2;
              y2 = y;
       }

       if (x1 < 0) {
              x1 = 0;
       }

       if (x2 >= gdImageSX(im)) {
              x2 = gdImageSX(im) - 1;
       }

       if (y1 < 0) {
              y1 = 0;
       }

       if (y2 >= gdImageSY(im)) {
              y2 = gdImageSY(im) - 1;
       }

       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:

Here is the caller graph for this function:

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

Definition at line 1756 of file gd.c.

{
       int lastBorder;
       /* Seek left */
       int leftLimit = -1, rightLimit;
       int i, restoreAlphaBlending = 0;

       if (border < 0) {
              /* Refuse to fill to a non-solid border */
              return;
       }

       restoreAlphaBlending = im->alphaBlendingFlag;
       im->alphaBlendingFlag = 0;

       if (x >= im->sx) {
              x = im->sx - 1;
       }
       if (y >= im->sy) {
              y = im->sy - 1;
       }

       for (i = x; i >= 0; i--) {
              if (gdImageGetPixel(im, i, y) == border) {
                     break;
              }
              gdImageSetPixel(im, i, y, color);
              leftLimit = i;
       }
       if (leftLimit == -1) {
              im->alphaBlendingFlag = restoreAlphaBlending;
              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 = 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 = 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;
                     }
              }
       }
       im->alphaBlendingFlag = restoreAlphaBlending;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 419 of file gd_filter.c.

{
       float filter[3][3] = {{1.0,2.0,1.0},
                            {2.0,4.0,2.0},
                            {1.0,2.0,1.0}};

       return gdImageConvolution(im, filter, 16, 0);
}

Here is the caller graph for this function:

void gdImageGd ( gdImagePtr  im,
FILE *  out 
)

Definition at line 265 of file gd_gd.c.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 810 of file gd_gd2.c.

{
       gdIOCtx *out = gdNewFileCtx(outFile);

       _gdImageGd2(im, out, cs, fmt);

       out->gd_free(out);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* gdImageGd2Ptr ( gdImagePtr  im,
int  cs,
int  fmt,
int size 
)

Definition at line 819 of file gd_gd2.c.

{
       void *rv;
       gdIOCtx *out = gdNewDynamicCtx(2048, NULL);

       _gdImageGd2(im, out, cs, fmt);
       rv = gdDPExtractData(out, size);
       out->gd_free(out);

       return rv;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void* gdImageGdPtr ( gdImagePtr  im,
int size 
)

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

Here is the caller graph for this function:

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

Definition at line 3004 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 993 of file gd.c.

{
       if (gdImageBoundsSafe(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:

Definition at line 778 of file gd.c.

{
       int p = gdImageGetPixel(im, x, y);

       if (!im->trueColor)  {
              return gdTrueColorAlpha(im->red[p], im->green[p], im->blue[p], (im->transparent == p) ? gdAlphaTransparent : im->alpha[p]);
       } else {
              return p;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageGif ( gdImagePtr  im,
FILE *  out 
)

Definition at line 109 of file gd_gif_out.c.

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

Here is the call graph for this function:

void gdImageGifCtx ( gdImagePtr  im,
gdIOCtx out 
)

Here is the caller graph for this function:

Definition at line 49 of file gd_filter.c.

{
       int x, y;
       int r,g,b,a;
       int new_pxl, pxl;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;
       f = GET_PIXEL_FUNCTION(src);

       if (src==NULL) {
              return 0;
       }

       for (y=0; y<src->sy; ++y) {
              for (x=0; x<src->sx; ++x) {
                     pxl = f (src, x, y);
                     r = gdImageRed(src, pxl);
                     g = gdImageGreen(src, pxl);
                     b = gdImageBlue(src, pxl);
                     a = gdImageAlpha(src, pxl);
                     r = g = b = (int) (.299 * r + .587 * g + .114 * b);

                     new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);
                     if (new_pxl == -1) {
                            new_pxl = gdImageColorClosestAlpha(src, r, g, b, a);
                     }
                     gdImageSetPixel (src, x, y, new_pxl);
              }
       }
       return 1;
}

Here is the caller graph for this function:

void gdImageInterlace ( gdImagePtr  im,
int  interlaceArg 
)

Definition at line 2777 of file gd.c.

{
       im->interlace = interlaceArg;
}

Here is the caller graph for this function:

void gdImageJpeg ( gdImagePtr  im,
FILE *  out,
int  quality 
)

Here is the caller graph for this function:

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 1089 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;

       if (color == gdAntiAliased) {
              /* 
                 gdAntiAliased passed as color: use the much faster, much cheaper
                 and equally attractive gdImageAALine implementation. That
                 clips too, so don't clip twice.
                 */
              gdImageAALine(im, x1, y1, x2, y2, im->AA_color); 
              return;
       }

       /* 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)) || !clip_1d(&y1,&x1,&y2,&x2,gdImageSY(im))) {
              return;
       }

       dx = abs (x2 - x1);
       dy = abs (y2 - y1);

       if (dx == 0) {
              gdImageVLine(im, x1, y1, y2, color);
              return;
       } else if (dy == 0) {
              gdImageHLine(im, y1, x1, x2, color);
              return;
       }

       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);
                            }
                     }
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 442 of file gd_filter.c.

{
       float filter[3][3] = {{-1.0,-1.0,-1.0},
                            {-1.0,9.0,-1.0},
                            {-1.0,-1.0,-1.0}};

       return gdImageConvolution(im, filter, 1, 0);
}

Here is the caller graph for this function:

Definition at line 16 of file gd_filter.c.

{
       int x, y;
       int r,g,b,a;
       int new_pxl, pxl;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;

       if (src==NULL) {
              return 0;
       }

       f = GET_PIXEL_FUNCTION(src);

       for (y=0; y<src->sy; ++y) {
              for (x=0; x<src->sx; ++x) {
                     pxl = f (src, x, y);
                     r = gdImageRed(src, pxl);
                     g = gdImageGreen(src, pxl);
                     b = gdImageBlue(src, pxl);
                     a = gdImageAlpha(src, pxl);

                     new_pxl = gdImageColorAllocateAlpha(src, 255-r, 255-g, 255-b, a);
                     if (new_pxl == -1) {
                            new_pxl = gdImageColorClosestAlpha(src, 255-r, 255-g, 255-b, a);
                     }
                     gdImageSetPixel (src, x, y, new_pxl);
              }
       }
       return 1;
}

Here is the caller graph for this function:

void gdImagePaletteCopy ( gdImagePtr  dst,
gdImagePtr  src 
)

Definition at line 607 of file gd.c.

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

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

       for (y = 0; y < to->sy; y++) {
              for (x = 0; x < to->sx; x++) {
                     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]);
                     }
                     gdImageSetPixel(to, x, y, xlate[p]);
              }
       }

       for (i = 0; i < from->colorsTotal; 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:

Here is the caller graph for this function:

int gdImagePixelate ( gdImagePtr  im,
int  block_size,
const unsigned int  mode 
)

Definition at line 3 of file gd_pixelate.c.

{
       int x, y;

       if (block_size <= 0) {
              return 0;
       } else if (block_size == 1) {
              return 1;
       }
       switch (mode) {
       case GD_PIXELATE_UPPERLEFT:
              for (y = 0; y < im->sy; y += block_size) {
                     for (x = 0; x < im->sx; x += block_size) {
                            if (gdImageBoundsSafe(im, x, y)) {
                                   int c = gdImageGetPixel(im, x, y);
                                   gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c);
                            }
                     }
              }
              break;
       case GD_PIXELATE_AVERAGE:
              for (y = 0; y < im->sy; y += block_size) {
                     for (x = 0; x < im->sx; x += block_size) {
                            int a, r, g, b, c;
                            int total;
                            int cx, cy;

                            a = r = g = b = c = total = 0;
                            /* sampling */
                            for (cy = 0; cy < block_size; cy++) {
                                   for (cx = 0; cx < block_size; cx++) {
                                          if (!gdImageBoundsSafe(im, x + cx, y + cy)) {
                                                 continue;
                                          }
                                          c = gdImageGetPixel(im, x + cx, y + cy);
                                          a += gdImageAlpha(im, c);
                                          r += gdImageRed(im, c);
                                          g += gdImageGreen(im, c);
                                          b += gdImageBlue(im, c);
                                          total++;
                                   }
                            }
                            /* drawing */
                            if (total > 0) {
                                   c = gdImageColorResolveAlpha(im, r / total, g / total, b / total, a / total);
                                   gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c);
                            }
                     }
              }
              break;
       default:
              return 0;
       }
       return 1;
}

Here is the caller graph for this function:

void gdImagePng ( gdImagePtr  im,
FILE *  out 
)

Here is the caller graph for this function:

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

Here is the caller graph for this function:

void* gdImagePngPtrEx ( gdImagePtr  im,
int size,
int  level,
int  basefilter 
)
void gdImagePngToSink ( gdImagePtr  im,
gdSinkPtr  out 
)

Definition at line 39 of file gd_ss.c.

{
       php_gd_error("PNG support is not available");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImagePolygon ( gdImagePtr  im,
gdPointPtr  p,
int  n,
int  c 
)

Definition at line 2559 of file gd.c.

{
       int i;
       int lx, ly;
       typedef void (*image_line)(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
       image_line draw_line;

       if (n <= 0) {
              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;
       }

       if ( im->antialias) {
              draw_line = gdImageAALine;
       } else {
              draw_line = gdImageLine;
       }
       lx = p->x;
       ly = p->y;
       draw_line(im, lx, ly, p[n - 1].x, p[n - 1].y, c);
       for (i = 1; i < n; i++) {
              p++;
              draw_line(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 2030 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;
       int half1 = 1;
       int t;

       if (x1 == x2 && y1 == y2 && thick == 1) {
              gdImageSetPixel(im, x1, y1, color);
              return;
       }

       if (y2 < y1) {
              t=y1;
              y1 = y2;
              y2 = t;

              t = x1;
              x1 = x2;
              x2 = t;
       }

       x1h = x1; x1v = x1; y1h = y1; y1v = y1; x2h = x2; x2v = x2; y2h = y2; y2v = y2;
       if (thick > 1) {
              int cx, cy, x1ul, y1ul, x2lr, y2lr;
              int half = thick >> 1;
              half1 = thick - half;
              x1ul = x1 - half;
              y1ul = y1 - half;
              
              x2lr = x2 + half;
              y2lr = y2 + half;

              cy = y1ul + thick;
              while (cy-- > y1ul) {
                     cx = x1ul - 1;
                     while (cx++ < x2lr) {
                            gdImageSetPixel(im, cx, cy, color);
                     }
              }

              cy = y2lr - thick;
              while (cy++ < y2lr) {
                     cx = x1ul - 1;
                     while (cx++ < x2lr) {
                            gdImageSetPixel(im, cx, cy, color);
                     }
              }

              cy = y1ul + thick - 1;
              while (cy++ < y2lr -thick) {
                     cx = x1ul - 1;
                     while (cx++ < x1ul + thick) {
                            gdImageSetPixel(im, cx, cy, color);
                     }
              }

              cy = y1ul + thick - 1;
              while (cy++ < y2lr -thick) {
                     cx = x2lr - thick - 1;
                     while (cx++ < x2lr) {
                            gdImageSetPixel(im, cx, cy, color);
                     }
              }

              return;
       } else {
              y1v = y1h + 1;
              y2v = y2h - 1;
              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:

gdImagePtr gdImageRotate ( gdImagePtr  src,
double  dAngle,
int  clrBack,
int  ignoretransparent 
)

Definition at line 502 of file gd_rotate.c.

{
       gdImagePtr pMidImg;
       gdImagePtr rotatedImg;

       if (src == NULL) {
              return NULL;
       }

       if (!gdImageTrueColor(src) && (clrBack < 0 || clrBack>=gdImageColorsTotal(src))) {
              return NULL;
       }

       while (dAngle >= 360.0) {
              dAngle -= 360.0;
       }

       while (dAngle < 0) {
              dAngle += 360.0;
       }

       if (dAngle == 90.00) {
              return gdImageRotate90(src, ignoretransparent);
       }
       if (dAngle == 180.00) {
              return gdImageRotate180(src, ignoretransparent);
       }
       if(dAngle == 270.00) {
              return gdImageRotate270 (src, ignoretransparent);
       }

       if ((dAngle > 45.0) && (dAngle <= 135.0)) {
              pMidImg = gdImageRotate90 (src, ignoretransparent);
              dAngle -= 90.0;
       } else if ((dAngle > 135.0) && (dAngle <= 225.0)) {
              pMidImg = gdImageRotate180 (src, ignoretransparent);
              dAngle -= 180.0;
       } else if ((dAngle > 225.0) && (dAngle <= 315.0)) {
              pMidImg = gdImageRotate270 (src, ignoretransparent);
              dAngle -= 270.0;
       } else {
              return gdImageRotate45 (src, dAngle, clrBack, ignoretransparent);
       }

       if (pMidImg == NULL) {
              return NULL;
       }

       rotatedImg = gdImageRotate45 (pMidImg, dAngle, clrBack, ignoretransparent);
       gdImageDestroy(pMidImg);

       return rotatedImg;
}
gdImagePtr gdImageRotate180 ( gdImagePtr  src,
int  ignoretransparent 
)

Definition at line 251 of file gd_rotate.c.

{
       int uY, uX;
       int c,r,g,b,a;
       gdImagePtr dst;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;

       if (src->trueColor) {
              f = gdImageGetTrueColorPixel;
       } else {
              f = gdImageGetPixel;
       }
       dst = gdImageCreateTrueColor(src->sx, src->sy);
       dst->transparent = src->transparent;

       if (dst != NULL) {
              int old_blendmode = dst->alphaBlendingFlag;
              dst->alphaBlendingFlag = 0;

              gdImagePaletteCopy (dst, src);

              for (uY = 0; uY<src->sy; uY++) {
                     for (uX = 0; uX<src->sx; uX++) {
                            c = f (src, uX, uY);
                            if (!src->trueColor) {
                                   r = gdImageRed(src,c);
                                   g = gdImageGreen(src,c);
                                   b = gdImageBlue(src,c);
                                   a = gdImageAlpha(src,c);
                                   c = gdTrueColorAlpha(r, g, b, a);
                            }

                            if (ignoretransparent && c == dst->transparent) {
                                   gdImageSetPixel(dst, (dst->sx - uX - 1), (dst->sy - uY - 1), dst->transparent);
                            } else {
                                   gdImageSetPixel(dst, (dst->sx - uX - 1), (dst->sy - uY - 1), c);
                            }
                     }
              }
              dst->alphaBlendingFlag = old_blendmode;
       }

       return dst;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageRotate270 ( gdImagePtr  src,
int  ignoretransparent 
)

Definition at line 298 of file gd_rotate.c.

{
       int uY, uX;
       int c,r,g,b,a;
       gdImagePtr dst;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;

       if (src->trueColor) {
              f = gdImageGetTrueColorPixel;
       } else {
              f = gdImageGetPixel;
       }
       dst = gdImageCreateTrueColor (src->sy, src->sx);
       dst->transparent = src->transparent;

       if (dst != NULL) {
              int old_blendmode = dst->alphaBlendingFlag;
              dst->alphaBlendingFlag = 0;

              gdImagePaletteCopy (dst, src);

              for (uY = 0; uY<src->sy; uY++) {
                     for (uX = 0; uX<src->sx; uX++) {
                            c = f (src, uX, uY);
                            if (!src->trueColor) {
                                   r = gdImageRed(src,c);
                                   g = gdImageGreen(src,c);
                                   b = gdImageBlue(src,c);
                                   a = gdImageAlpha(src,c);
                                   c = gdTrueColorAlpha(r, g, b, a);
                            }

                            if (ignoretransparent && c == dst->transparent) {
                                   gdImageSetPixel(dst, (dst->sx - uY - 1), uX, dst->transparent);
                            } else {
                                   gdImageSetPixel(dst, (dst->sx - uY - 1), uX, c);
                            }
                     }
              }
              dst->alphaBlendingFlag = old_blendmode;
       }

       return dst;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageRotate45 ( gdImagePtr  src,
double  dAngle,
int  clrBack,
int  ignoretransparent 
)

Definition at line 344 of file gd_rotate.c.

{
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       gdImagePtr dst1,dst2,dst3;
       FuncPtr f;
       double dRadAngle, dSinE, dTan, dShear;
       double dOffset;     /* Variable skew offset */
       int u, iShear, newx, newy;
       int clrBackR, clrBackG, clrBackB, clrBackA;

       /* See GEMS I for the algorithm details */
       dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
       dSinE = sin (dRadAngle);
       dTan = tan (dRadAngle / 2.0);

       newx = (int)(src->sx + src->sy * fabs(dTan));
       newy = src->sy;

       /* 1st shear */
       if (src->trueColor) {
              f = gdImageGetTrueColorPixel;
       } else {
              f = gdImageGetPixel;
       }

       dst1 = gdImageCreateTrueColor(newx, newy);
       /******* Perform 1st shear (horizontal) ******/
       if (dst1 == NULL) {
              return NULL;
       }
#ifdef HAVE_GD_BUNDLED
       dst1->alphaBlendingFlag = gdEffectReplace;
#else
       gdImageAlphaBlending(dst1, 0);
#endif
       if (dAngle == 0.0) {
              /* Returns copy of src */
              gdImageCopy (dst1, src,0,0,0,0,src->sx,src->sy);
              return dst1;
       }

       gdImagePaletteCopy (dst1, src);

       if (ignoretransparent) {
              if (gdImageTrueColor(src)) {
                     dst1->transparent = src->transparent;
              } else {

                     dst1->transparent = gdTrueColorAlpha(gdImageRed(src, src->transparent), gdImageBlue(src, src->transparent), gdImageGreen(src, src->transparent), 127);
              }
       }

       dRadAngle = dAngle * ROTATE_DEG2RAD; /* Angle in radians */
       dSinE = sin (dRadAngle);
       dTan = tan (dRadAngle / 2.0);

       for (u = 0; u < dst1->sy; u++) {
              if (dTan >= 0.0) {
                     dShear = ((double)(u + 0.5)) * dTan;
              } else {
                     dShear = ((double)(u - dst1->sy) + 0.5) * dTan;
              }

              iShear = (int)floor(dShear);
              gdImageSkewX(dst1, src, u, iShear, (dShear - iShear), clrBack, ignoretransparent);
       }

       /*
       The 1st shear may use the original clrBack as color index
       Convert it once here
       */
       if(!src->trueColor) {
              clrBackR = gdImageRed(src, clrBack);
              clrBackG = gdImageGreen(src, clrBack);
              clrBackB = gdImageBlue(src, clrBack);
              clrBackA = gdImageAlpha(src, clrBack);
              clrBack =  gdTrueColorAlpha(clrBackR, clrBackG, clrBackB, clrBackA);
       }
       /* 2nd shear */
       newx = dst1->sx;

       if (dSinE > 0.0) {
              dOffset = (src->sx-1) * dSinE;
       } else {
              dOffset = -dSinE *  (src->sx - newx);
       }

       newy = (int) ((double) src->sx * fabs( dSinE ) + (double) src->sy * cos (dRadAngle))+1;

       if (src->trueColor) {
              f = gdImageGetTrueColorPixel;
       } else {
              f = gdImageGetPixel;
       }
       dst2 = gdImageCreateTrueColor(newx, newy);
       if (dst2 == NULL) {
              gdImageDestroy(dst1);
              return NULL;
       }

#ifdef HAVE_GD_BUNDLED
       dst2->alphaBlendingFlag = gdEffectReplace;
#else
       gdImageAlphaBlending(dst2, 0);
#endif

       if (ignoretransparent) {
              dst2->transparent = dst1->transparent;
       }

       for (u = 0; u < dst2->sx; u++, dOffset -= dSinE) {
              iShear = (int)floor (dOffset);
              gdImageSkewY(dst2, dst1, u, iShear, (dOffset - (double)iShear), clrBack, ignoretransparent);
       }

       /* 3rd shear */
       gdImageDestroy(dst1);

       newx = (int) ((double)src->sy * fabs (dSinE) + (double)src->sx * cos (dRadAngle)) + 1;
       newy = dst2->sy;

       if (src->trueColor) {
              f = gdImageGetTrueColorPixel;
       } else {
              f = gdImageGetPixel;
       }
       dst3 = gdImageCreateTrueColor(newx, newy);
       if (dst3 == NULL) {
              gdImageDestroy(dst2);
              return NULL;
       }

#ifdef HAVE_GD_BUNDLED
       dst3->alphaBlendingFlag = gdEffectReplace;
#else
       gdImageAlphaBlending(dst3, 0);
#endif

       if (ignoretransparent) {
              dst3->transparent = dst2->transparent;
       }

       if (dSinE >= 0.0) {
              dOffset = (double)(src->sx - 1) * dSinE * -dTan;
       } else {
              dOffset = dTan * ((double)(src->sx - 1) * -dSinE + (double)(1 - newy));
       }

       for (u = 0; u < dst3->sy; u++, dOffset += dTan) {
              int iShear = (int)floor(dOffset);
              gdImageSkewX(dst3, dst2, u, iShear, (dOffset - iShear), clrBack, ignoretransparent);
       }

       gdImageDestroy(dst2);

       return dst3;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdImagePtr gdImageRotate90 ( gdImagePtr  src,
int  ignoretransparent 
)

Definition at line 205 of file gd_rotate.c.

{
       int uY, uX;
       int c,r,g,b,a;
       gdImagePtr dst;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;

       if (src->trueColor) {
              f = gdImageGetTrueColorPixel;
       } else {
              f = gdImageGetPixel;
       }
       dst = gdImageCreateTrueColor(src->sy, src->sx);
       dst->transparent = src->transparent;

       if (dst != NULL) {
              int old_blendmode = dst->alphaBlendingFlag;
              dst->alphaBlendingFlag = 0;

              gdImagePaletteCopy (dst, src);

              for (uY = 0; uY<src->sy; uY++) {
                     for (uX = 0; uX<src->sx; uX++) {
                            c = f (src, uX, uY);
                            if (!src->trueColor) {
                                   r = gdImageRed(src,c);
                                   g = gdImageGreen(src,c);
                                   b = gdImageBlue(src,c);
                                   a = gdImageAlpha(src,c);
                                   c = gdTrueColorAlpha(r, g, b, a);
                            }
                            if (ignoretransparent && c == dst->transparent) {
                                   gdImageSetPixel(dst, uY, (dst->sy - uX - 1), dst->transparent);
                            } else {
                                   gdImageSetPixel(dst, uY, (dst->sy - uX - 1), c);
                            }
                     }
              }
              dst->alphaBlendingFlag = old_blendmode;
       }

       return dst;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void gdImageSaveAlpha ( gdImagePtr  im,
int  saveAlphaArg 
)

Definition at line 2934 of file gd.c.

{
       im->saveAlphaFlag = saveAlphaArg;
}

Here is the caller graph for this function:

Definition at line 291 of file gd_filter.c.

{
       int         x, y, i, j;
       float       new_r, new_g, new_b;
       int         new_pxl, cpxl, pxl, new_a=0;
       float flt_r [3][3];
       float flt_g [3][3];
       float flt_b [3][3];
       float flt_r_sum, flt_g_sum, flt_b_sum;

       gdImagePtr srcback;
       typedef int (*FuncPtr)(gdImagePtr, int, int);
       FuncPtr f;

       if (src==NULL) {
              return 0;
       }

       /* We need the orinal image with each safe neoghb. pixel */
       srcback = gdImageCreateTrueColor (src->sx, src->sy);
       if (srcback==NULL) {
              return 0;
       }
       gdImageCopy(srcback, src,0,0,0,0,src->sx,src->sy);

       f = GET_PIXEL_FUNCTION(src);

       for(y = 0; y<src->sy; y++) {
              for (x=0; x<src->sx; x++) {
                    flt_r_sum = flt_g_sum = flt_b_sum = 0.0;
                     cpxl = f(src, x, y);

                     for (j=0; j<3; j++) {
                            for (i=0; i<3; i++) {
                                   if ((j == 1) && (i == 1)) {
                                          flt_r[1][1] = flt_g[1][1] = flt_b[1][1] = 0.5;
                                   } else {
                                          pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
                                          new_a = gdImageAlpha(srcback, pxl);

                                          new_r = ((float)gdImageRed(srcback, cpxl)) - ((float)gdImageRed (srcback, pxl));

                                          if (new_r < 0.0f) {
                                                 new_r = -new_r;
                                          }
                                          if (new_r != 0) {
                                                 flt_r[j][i] = 1.0f/new_r;
                                          } else {
                                                 flt_r[j][i] = 1.0f;
                                          }

                                          new_g = ((float)gdImageGreen(srcback, cpxl)) - ((float)gdImageGreen(srcback, pxl));

                                          if (new_g < 0.0f) {
                                                 new_g = -new_g;
                                          }
                                          if (new_g != 0) {
                                                 flt_g[j][i] = 1.0f/new_g;
                                          } else {
                                                 flt_g[j][i] = 1.0f;
                                          }

                                          new_b = ((float)gdImageBlue(srcback, cpxl)) - ((float)gdImageBlue(srcback, pxl));

                                          if (new_b < 0.0f) {
                                                 new_b = -new_b;
                                          }
                                          if (new_b != 0) {
                                                 flt_b[j][i] = 1.0f/new_b;
                                          } else {
                                                 flt_b[j][i] = 1.0f;
                                          }
                                   }

                                   flt_r_sum += flt_r[j][i];
                                   flt_g_sum += flt_g[j][i];
                                   flt_b_sum += flt_b [j][i];
                            }
                     }

                     for (j=0; j<3; j++) {
                            for (i=0; i<3; i++) {
                                   if (flt_r_sum != 0.0) {
                                          flt_r[j][i] /= flt_r_sum;
                                   }
                                   if (flt_g_sum != 0.0) {
                                          flt_g[j][i] /= flt_g_sum;
                                   }
                                   if (flt_b_sum != 0.0) {
                                          flt_b [j][i] /= flt_b_sum;
                                   }
                            }
                     }

                     new_r = new_g = new_b = 0.0;

                     for (j=0; j<3; j++) {
                            for (i=0; i<3; i++) {
                                   pxl = f(src, x-(3>>1)+i, y-(3>>1)+j);
                                   new_r += (float)gdImageRed(srcback, pxl) * flt_r[j][i];
                                   new_g += (float)gdImageGreen(srcback, pxl) * flt_g[j][i];
                                   new_b += (float)gdImageBlue(srcback, pxl) * flt_b[j][i];
                            }
                     }

                     new_r = (new_r > 255.0f)? 255.0f : ((new_r < 0.0f)? 0.0f:new_r);
                     new_g = (new_g > 255.0f)? 255.0f : ((new_g < 0.0f)? 0.0f:new_g);
                     new_b = (new_b > 255.0f)? 255.0f : ((new_b < 0.0f)? 0.0f:new_b);
                     new_pxl = gdImageColorAllocateAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
                     if (new_pxl == -1) {
                            new_pxl = gdImageColorClosestAlpha(src, (int)new_r, (int)new_g, (int)new_b, new_a);
                     }
                     gdImageSetPixel (src, x, y, new_pxl);
              }
       }
       gdImageDestroy(srcback);
       return 1;
}

Here is the caller graph for this function:

void gdImageSetAntiAliased ( gdImagePtr  im,
int  c 
)

Definition at line 2762 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 2769 of file gd.c.

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

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

Here is the caller graph for this function:

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

Definition at line 2972 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 716 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 (gdImageBoundsSafe(im, x, y)) {
                            if (im->trueColor) {
                                   switch (im->alphaBlendingFlag) {
                                          default:
                                          case gdEffectReplace:
                                                 im->tpixels[y][x] = color;
                                                 break;
                                          case gdEffectAlphaBlend:
                                                 im->tpixels[y][x] = gdAlphaBlend(im->tpixels[y][x], color);
                                                 break;
                                          case gdEffectNormal:
                                                 im->tpixels[y][x] = gdAlphaBlend(im->tpixels[y][x], color);
                                                 break;
                                          case gdEffectOverlay :
                                                 im->tpixels[y][x] = gdLayerOverlay(im->tpixels[y][x], color);
                                                 break;
                                   }
                            } 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 2720 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:

Here is the caller graph for this function:

void gdImageSetThickness ( gdImagePtr  im,
int  thickness 
)

Definition at line 2731 of file gd.c.

{
       im->thick = thickness;
}
void gdImageSetTile ( gdImagePtr  im,
gdImagePtr  tile 
)

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

int gdImageSmooth ( gdImagePtr  im,
float  weight 
)

Definition at line 451 of file gd_filter.c.

{
       float filter[3][3] = {{1.0,1.0,1.0},
                            {1.0,0.0,1.0},
                            {1.0,1.0,1.0}};

       filter[1][1] = weight;

       return gdImageConvolution(im, filter, weight+8, 0);
}

Here is the caller graph for this function:

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

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

Here is the caller graph for this function:

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

Definition at line 1614 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 
)

Definition at line 56 of file gdft.c.

{
       return "libgd was not built with FreeType font support\n";
}

Here is the caller graph for this function:

char* gdImageStringFTEx ( gdImage im,
int brect,
int  fg,
char *  fontlist,
double  ptsize,
double  angle,
int  x,
int  y,
char *  string,
gdFTStringExtraPtr  strex 
)

Definition at line 48 of file gdft.c.

{
       return "libgd was not built with FreeType font support\n";
}
char* gdImageStringTTF ( gdImage im,
int brect,
int  fg,
char *  fontlist,
double  ptsize,
double  angle,
int  x,
int  y,
char *  string 
)

Definition at line 39 of file gdft.c.

{
       /* 2.0.6: valid return */
       return gdImageStringFT (im, brect, fg, fontlist, ptsize, angle, x, y, string);
}

Here is the call graph for this function:

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

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

Here is the caller graph for this function:

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

Definition at line 1625 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 1766 of file gd_topal.c.

{
       gdImageTrueColorToPaletteBody(im, dither, colorsWanted, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 191 of file gd_wbmp.c.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 94 of file gd_wbmp.c.

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

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 201 of file gd_wbmp.c.

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

       return rv;
}

Here is the call graph for this function:

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

Definition at line 174 of file xbm.c.

{
       int x, y, c, b, sx, sy, p;
       char *name, *f;
       size_t i, l;

       name = file_name;
       if ((f = strrchr(name, '/')) != NULL) name = f+1;
       if ((f = strrchr(name, '\\')) != NULL) name = f+1;
       name = estrdup(name);
       if ((f = strrchr(name, '.')) != NULL && !strcasecmp(f, ".XBM")) *f = '\0';
       if ((l = strlen(name)) == 0) {
              efree(name);
              name = estrdup("image");
       } else {
              for (i=0; i<l; i++) {
                     /* only in C-locale isalnum() would work */
                     if (!isupper(name[i]) && !islower(name[i]) && !isdigit(name[i])) {
                            name[i] = '_';
                     }
              }
       }

       gdCtxPrintf(out, "#define %s_width %d\n", name, gdImageSX(image));
       gdCtxPrintf(out, "#define %s_height %d\n", name, gdImageSY(image));
       gdCtxPrintf(out, "static unsigned char %s_bits[] = {\n  ", name);

       efree(name);

       b = 1;
       p = 0;
       c = 0;
       sx = gdImageSX(image);
       sy = gdImageSY(image);
       for (y = 0; y < sy; y++) {
              for (x = 0; x < sx; x++) {
                     if (gdImageGetPixel(image, x, y) == fg) {
                            c |= b;
                     }
                     if ((b == 128) || (x == sx && y == sy)) {
                            b = 1;
                            if (p) {
                                   gdCtxPrintf(out, ", ");
                                   if (!(p%12)) {
                                          gdCtxPrintf(out, "\n  ");
                                          p = 12;
                                   }
                            }
                            p++;
                            gdCtxPrintf(out, "0x%02X", c);
                            c = 0;
                     } else {
                            b <<= 1;
                     }
              }
       }
       gdCtxPrintf(out, "};\n");
}

Here is the call graph for this function:

const char* gdJpegGetVersionString ( )
gdIOCtx* gdNewDynamicCtx ( int  ,
void *   
)

Definition at line 65 of file gd_io_dp.c.

{
       return gdNewDynamicCtxEx(initialSize, data, 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gdIOCtx* gdNewDynamicCtxEx ( int  size,
void *  data,
int  freeFlag 
)

Definition at line 70 of file gd_io_dp.c.

{
       dpIOCtx *ctx;
       dynamicPtr *dp;

       ctx = (dpIOCtx *) gdMalloc (sizeof (dpIOCtx));

       dp = newDynamic(initialSize, data, freeOKFlag);

       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 49 of file gd_io_file.c.

{
       fileIOCtx *ctx;

       ctx = (fileIOCtx *) gdMalloc(sizeof (fileIOCtx));

       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 50 of file gd_io_ss.c.

{
       ssIOCtxPtr ctx;

       ctx = (ssIOCtxPtr) gdMalloc (sizeof (ssIOCtx));

       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:

Here is the caller graph for this function:

const char* gdPngGetVersionString ( )
void php_gd_error ( const char *  format,
  ... 
)

Definition at line 112 of file gd.c.

{
       va_list args;

       TSRMLS_FETCH();

       va_start(args, format);
       php_verror(NULL, "", E_WARNING, format, args TSRMLS_CC);
       va_end(args);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void php_gd_error_ex ( int  type,
const char *  format,
  ... 
)

Definition at line 101 of file gd.c.

{
       va_list args;

       TSRMLS_FETCH();

       va_start(args, format);
       php_verror(NULL, "", type, format, args TSRMLS_CC);
       va_end(args);
}

Here is the call graph for this function:

Here is the caller graph for this function: