gd.c

Summary
gd.c
Functions
gdSetErrorMethod
gdClearErrorMethod
gdImageGetTrueColorPixel
gdImageCreategdImageCreate is called to create palette-based images, with no more than 256 colors.
gdImageCreateTrueColorgdImageCreateTrueColor is called to create truecolor images, with an essentially unlimited number of colors.
gdImageDestroygdImageDestroy is used to free the memory associated with an image.
gdImageColorClosest
gdImageColorClosestAlpha
gdImageColorClosestHWB
gdImageColorExact
gdImageColorExactAlpha
gdImageColorAllocate
gdImageColorAllocateAlpha
gdImageColorResolvegdImageColorResolve is an alternative for the code fragment
gdImageColorResolveAlpha
gdImageColorDeallocate
gdImageColorTransparent
gdImagePaletteCopy
gdImageColorReplace
gdImageColorReplaceThreshold
gdImageColorReplaceArray
gdImageColorReplaceCallback
gdImageSetPixel
gdImageGetPixel
gdImageGetTrueColorPixel
gdImageAABlendNO-OP, kept for library compatibility.
gdImageLineBresenham as presented in Foley & Van Dam.
gdImageDashedLine
gdImageBoundsSafe
gdImageChar
gdImageCharUp
gdImageString
gdImageStringUp
gdImageString16
gdImageStringUp16
gdImageArc
gdImageFilledArc
gdImageEllipse
gdImageFilledEllipse
gdImageFillToBorder
gdImageFill
gdImageRectangle
gdImageFilledRectangle
gdImageClone
gdImageCopy
gdImageCopyMergeThis function is a substitute for real alpha channel operations, so it doesn’t pay attention to the alpha channel.
gdImageCopyMergeGrayThis function is a substitute for real alpha channel operations, so it doesn’t pay attention to the alpha channel.
gdImageCopyResized
gdImageCopyRotated
gdImageCopyResampled
gdImagePolygon
gdImageOpenPolygon
gdImageFilledPolygon
gdImageSetStyle
gdImageSetThickness
gdImageSetBrush
gdImageSetTile
gdImageSetAntiAliased
gdImageSetAntiAliasedDontBlend
gdImageInterlace
gdImageCompare
gdAlphaBlend
gdLayerOverlay
gdLayerMultiplyApply ‘multiply’ effect.
gdImageAlphaBlending
gdImageSaveAlpha
gdImageSetClip
gdImageGetClip
gdImageSetResolution
gdImagePaletteToTrueColorConvert a palette image to true color.

Functions

gdSetErrorMethod

void gdSetErrorMethod(gdErrorMethod error_method)

gdClearErrorMethod

void gdClearErrorMethod(void)

gdImageGetTrueColorPixel

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

gdImageCreate

gdImagePtr gdImageCreate (int sx,
int sy)

gdImageCreate is called to create palette-based images, with no more than 256 colors.  The image must eventually be destroyed using gdImageDestroy().

Parameters

sxThe image width.
syThe image height.

Returns

A pointer to the new image or NULL if an error occurred.

Example

gdImagePtr im;
im = gdImageCreate(64, 64);
// ... Use the image ...
gdImageDestroy(im);

See Also

gdImageCreateTrueColor

gdImageCreateTrueColor

gdImagePtr gdImageCreateTrueColor (int sx,
int sy)

gdImageCreateTrueColor is called to create truecolor images, with an essentially unlimited number of colors.  Invoke gdImageCreateTrueColor with the x and y dimensions of the desired image.  gdImageCreateTrueColor returns a gdImagePtr to the new image, or NULL if unable to allocate the image.  The image must eventually be destroyed using <gdImageDestroy>().

Truecolor images are always filled with black at creation time.  There is no concept of a “background” color index.

Parameters

sxThe image width.
syThe image height.

Returns

A pointer to the new image or NULL if an error occurred.

Example

gdImagePtr im;
im = gdImageCreateTrueColor(64, 64);
// ... Use the image ...
gdImageDestroy(im);

See Also

gdImageCreateTrueColor

gdImageDestroy

void gdImageDestroy (gdImagePtr im)

gdImageDestroy is used to free the memory associated with an image.  It is important to invoke gdImageDestroy before exiting your program or assigning a new image to a gdImagePtr variable.

Parameters

imPointer to the gdImage to delete.

Returns

Nothing.

Example

gdImagePtr im;
im = gdImageCreate(10, 10);
// ... Use the image ...
// Now destroy it
gdImageDestroy(im);

gdImageColorClosest

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

gdImageColorClosestAlpha

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

gdImageColorClosestHWB

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

gdImageColorExact

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

gdImageColorExactAlpha

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

gdImageColorAllocate

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

gdImageColorAllocateAlpha

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

gdImageColorResolve

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

gdImageColorResolve is an alternative for the code fragment

if ((color=gdImageColorExact(im,R,G,B)) < 0)
  if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
    color=gdImageColorClosest(im,R,G,B);

in a single function.  Its advantage is that it is guaranteed to return a color index in one search over the color table.

gdImageColorResolveAlpha

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

gdImageColorDeallocate

void gdImageColorDeallocate (gdImagePtr im,
int color)

gdImageColorTransparent

void gdImageColorTransparent (gdImagePtr im,
int color)

gdImagePaletteCopy

void gdImagePaletteCopy (gdImagePtr to,
gdImagePtr from)

gdImageColorReplace

int gdImageColorReplace (gdImagePtr im,
int src,
int dst)

gdImageColorReplaceThreshold

int gdImageColorReplaceThreshold (gdImagePtr im,
int src,
int dst,
float threshold)

gdImageColorReplaceArray

int gdImageColorReplaceArray (gdImagePtr im,
int len,
int *src,
int *dst)

gdImageColorReplaceCallback

int gdImageColorReplaceCallback (gdImagePtr im,
gdCallbackImageColor callback)

gdImageSetPixel

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

gdImageGetPixel

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

gdImageGetTrueColorPixel

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

gdImageAABlend

void gdImageAABlend (gdImagePtr im)

NO-OP, kept for library compatibility.

gdImageLine

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

Bresenham as presented in Foley & Van Dam.

gdImageDashedLine

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

gdImageBoundsSafe

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

gdImageChar

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

gdImageCharUp

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

gdImageString

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

gdImageStringUp

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

gdImageString16

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

gdImageStringUp16

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

gdImageArc

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

gdImageFilledArc

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

gdImageEllipse

void gdImageEllipse(gdImagePtr im,
int mx,
int my,
int w,
int h,
int c)

gdImageFilledEllipse

void gdImageFilledEllipse (gdImagePtr im,
int mx,
int my,
int w,
int h,
int c)

gdImageFillToBorder

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

gdImageFill

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

gdImageRectangle

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

gdImageFilledRectangle

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

gdImageClone

gdImagePtr gdImageClone (gdImagePtr src)

gdImageCopy

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

gdImageCopyMerge

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

This function is a substitute for real alpha channel operations, so it doesn’t pay attention to the alpha channel.

gdImageCopyMergeGray

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

This function is a substitute for real alpha channel operations, so it doesn’t pay attention to the alpha channel.

gdImageCopyResized

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

gdImageCopyRotated

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

gdImageCopyResampled

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

gdImagePolygon

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

gdImageOpenPolygon

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

gdImageFilledPolygon

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

gdImageSetStyle

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

gdImageSetThickness

void gdImageSetThickness (gdImagePtr im,
int thickness)

gdImageSetBrush

void gdImageSetBrush (gdImagePtr im,
gdImagePtr brush)

gdImageSetTile

void gdImageSetTile (gdImagePtr im,
gdImagePtr tile)

gdImageSetAntiAliased

void gdImageSetAntiAliased (gdImagePtr im,
int c)

gdImageSetAntiAliasedDontBlend

void gdImageSetAntiAliasedDontBlend (gdImagePtr im,
int c,
int dont_blend)

gdImageInterlace

void gdImageInterlace (gdImagePtr im,
int interlaceArg)

gdImageCompare

int gdImageCompare (gdImagePtr im1,
gdImagePtr im2)

gdAlphaBlend

int gdAlphaBlend (int dst,
int src)

gdLayerOverlay

int gdLayerOverlay (int dst,
int src)

gdLayerMultiply

int gdLayerMultiply (int dst,
int src)

Apply ‘multiply’ effect.

gdImageAlphaBlending

void gdImageAlphaBlending (gdImagePtr im,
int alphaBlendingArg)

gdImageSaveAlpha

void gdImageSaveAlpha (gdImagePtr im,
int saveAlphaArg)

gdImageSetClip

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

gdImageGetClip

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

gdImageSetResolution

void gdImageSetResolution(gdImagePtr im,
const unsigned int res_x,
const unsigned int res_y)

gdImagePaletteToTrueColor

int gdImagePaletteToTrueColor(gdImagePtr src)

Convert a palette image to true color.

void gdSetErrorMethod(gdErrorMethod error_method)
void gdClearErrorMethod(void)
int gdImageGetTrueColorPixel (gdImagePtr im,
int x,
int y)
gdImagePtr gdImageCreate (int sx,
int sy)
gdImageCreate is called to create palette-based images, with no more than 256 colors.
gdImagePtr gdImageCreateTrueColor (int sx,
int sy)
gdImageCreateTrueColor is called to create truecolor images, with an essentially unlimited number of colors.
void gdImageDestroy (gdImagePtr im)
gdImageDestroy is used to free the memory associated with an image.
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 gdImageColorAllocate (gdImagePtr im,
int r,
int g,
int b)
int gdImageColorAllocateAlpha (gdImagePtr im,
int r,
int g,
int b,
int a)
int gdImageColorResolve (gdImagePtr im,
int r,
int g,
int b)
gdImageColorResolve is an alternative for the code fragment
int gdImageColorResolveAlpha (gdImagePtr im,
int r,
int g,
int b,
int a)
void gdImageColorDeallocate (gdImagePtr im,
int color)
void gdImageColorTransparent (gdImagePtr im,
int color)
void gdImagePaletteCopy (gdImagePtr to,
gdImagePtr from)
int gdImageColorReplace (gdImagePtr im,
int src,
int dst)
int gdImageColorReplaceThreshold (gdImagePtr im,
int src,
int dst,
float threshold)
int gdImageColorReplaceArray (gdImagePtr im,
int len,
int *src,
int *dst)
int gdImageColorReplaceCallback (gdImagePtr im,
gdCallbackImageColor callback)
void gdImageSetPixel (gdImagePtr im,
int x,
int y,
int color)
int gdImageGetPixel (gdImagePtr im,
int x,
int y)
void gdImageAABlend (gdImagePtr im)
NO-OP, kept for library compatibility.
void gdImageLine (gdImagePtr im,
int x1,
int y1,
int x2,
int y2,
int color)
Bresenham as presented in Foley & Van Dam.
void gdImageDashedLine (gdImagePtr im,
int x1,
int y1,
int x2,
int y2,
int color)
int gdImageBoundsSafe (gdImagePtr im,
int x,
int y)
void gdImageChar (gdImagePtr im,
gdFontPtr f,
int x,
int y,
int c,
int color)
void gdImageCharUp (gdImagePtr im,
gdFontPtr f,
int x,
int y,
int c,
int color)
void gdImageString (gdImagePtr im,
gdFontPtr f,
int x,
int y,
unsigned char *s,
int color)
void gdImageStringUp (gdImagePtr im,
gdFontPtr f,
int x,
int y,
unsigned char *s,
int color)
void gdImageString16 (gdImagePtr im,
gdFontPtr f,
int x,
int y,
unsigned short *s,
int color)
void gdImageStringUp16 (gdImagePtr im,
gdFontPtr f,
int x,
int y,
unsigned short *s,
int color)
void gdImageArc (gdImagePtr im,
int cx,
int cy,
int w,
int h,
int s,
int e,
int color)
void gdImageFilledArc (gdImagePtr im,
int cx,
int cy,
int w,
int h,
int s,
int e,
int color,
int style)
void gdImageEllipse(gdImagePtr im,
int mx,
int my,
int w,
int h,
int c)
void gdImageFilledEllipse (gdImagePtr im,
int mx,
int my,
int w,
int h,
int c)
void gdImageFillToBorder (gdImagePtr im,
int x,
int y,
int border,
int color)
void gdImageFill(gdImagePtr im,
int x,
int y,
int nc)
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)
gdImagePtr gdImageClone (gdImagePtr src)
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)
This function is a substitute for real alpha channel operations, so it doesn’t pay attention to the alpha channel.
void gdImageCopyMergeGray (gdImagePtr dst,
gdImagePtr src,
int dstX,
int dstY,
int srcX,
int srcY,
int w,
int h,
int pct)
This function is a substitute for real alpha channel operations, so it doesn’t pay attention to the alpha channel.
void gdImageCopyResized (gdImagePtr dst,
gdImagePtr src,
int dstX,
int dstY,
int srcX,
int srcY,
int dstW,
int dstH,
int srcW,
int srcH)
void gdImageCopyRotated (gdImagePtr dst,
gdImagePtr src,
double dstX,
double dstY,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
int angle)
void gdImageCopyResampled (gdImagePtr dst,
gdImagePtr src,
int dstX,
int dstY,
int srcX,
int srcY,
int dstW,
int dstH,
int srcW,
int srcH)
void gdImagePolygon (gdImagePtr im,
gdPointPtr p,
int n,
int c)
void gdImageOpenPolygon (gdImagePtr im,
gdPointPtr p,
int n,
int c)
void gdImageFilledPolygon (gdImagePtr im,
gdPointPtr p,
int n,
int c)
void gdImageSetStyle (gdImagePtr im,
int *style,
int noOfPixels)
void gdImageSetThickness (gdImagePtr im,
int thickness)
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 gdImageInterlace (gdImagePtr im,
int interlaceArg)
int gdImageCompare (gdImagePtr im1,
gdImagePtr im2)
int gdAlphaBlend (int dst,
int src)
int gdLayerOverlay (int dst,
int src)
int gdLayerMultiply (int dst,
int src)
Apply ‘multiply’ effect.
void gdImageAlphaBlending (gdImagePtr im,
int alphaBlendingArg)
void gdImageSaveAlpha (gdImagePtr im,
int saveAlphaArg)
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 gdImageSetResolution(gdImagePtr im,
const unsigned int res_x,
const unsigned int res_y)
int gdImagePaletteToTrueColor(gdImagePtr src)
Convert a palette image to true color.
The data structure in which gd stores images.
Close