/* Version information. This gets parsed by build scripts as well as
* gcc so each #define line in this group must also be splittable on
* whitespace, take the form GD_*_VERSION and contain the magical
#define GD_MAJOR_VERSION 2 /*version605b5d1778*/
#define GD_MINOR_VERSION 2 /*version605b5d1778*/
#define GD_RELEASE_VERSION 5 /*version605b5d1778*/
#define GD_EXTRA_VERSION "" /*version605b5d1778*/
/* End parsable section. */
/* The version string. This is constructed from the version number
* parts above via macro abuse^Wtrickery. */
#define GDXXX_VERSION_STR(mjr, mnr, rev, ext) mjr "." mnr "." rev ext
#define GDXXX_STR(s) GDXXX_SSTR(s) /* Two levels needed to expand args. */
#define GD_VERSION_STRING \
GDXXX_VERSION_STR(GDXXX_STR(GD_MAJOR_VERSION), \
GDXXX_STR(GD_MINOR_VERSION), \
GDXXX_STR(GD_RELEASE_VERSION), \
/* Do the DLL dance: dllexport when building the DLL,
dllimport when importing from it, nothing when
not on Silly Silly Windows (tm Aardman Productions). */
/* 2.0.20: for headers */
/* 2.0.24: __stdcall also needed for Visual BASIC
and other languages. This breaks ABI compatibility
with previous DLL revs, but it's necessary. */
/* 2.0.29: WIN32 programmers can declare the NONDLL macro if they
wish to build gd as a static library or by directly including
the gd sources in a project. */
/* http://gcc.gnu.org/wiki/Visibility */
#if defined(_WIN32) || defined(CYGWIN) || defined(_WIN32_WCE)
# define BGD_EXPORT_DATA_PROT
# define BGD_EXPORT_DATA_PROT __attribute__ ((dllexport))
# define BGD_EXPORT_DATA_PROT __declspec(dllexport)
# define BGD_EXPORT_DATA_PROT __attribute__ ((dllimport))
# define BGD_EXPORT_DATA_PROT __declspec(dllimport)
# define BGD_STDCALL __stdcall
# define BGD_EXPORT_DATA_IMPL
# if defined(__GNUC__) || defined(__clang__)
# define BGD_EXPORT_DATA_PROT __attribute__ ((visibility ("default")))
# define BGD_EXPORT_DATA_IMPL __attribute__ ((visibility ("hidden")))
# define BGD_EXPORT_DATA_PROT
# define BGD_EXPORT_DATA_IMPL
#define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt BGD_STDCALL
/* VS2012+ disable keyword macroizing unless _ALLOW_KEYWORD_MACROS is set
We define inline, snprintf, and strcasecmp if they're missing
# define _ALLOW_KEYWORD_MACROS
# define strcasecmp _stricmp
extern int snprintf(char*, size_t, const char*, ...);
/* gd.h: declarations file for the graphic-draw module.
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. This software is provided "AS IS." Thomas Boutell and
* Boutell.Com, Inc. disclaim all warranties, either express or implied,
* including but not limited to implied warranties of merchantability and
* fitness for a particular purpose, with respect to this code and accompanying
/* stdio is needed for file I/O. */
/* The maximum number of palette entries in palette-based images.
In the wonderful new world of gd 2.0, you can of course have
many more colors when using truecolor mode. */
/* Image type. See functions below; you will not need to change
the elements directly. Use the provided macros to
access sx, sy, the color table, and colorsTotal for
/* If 'truecolor' is set true, the image is truecolor;
pixels are represented by integers, which
must be 32 bits wide or more.
True colors are repsented as follows:
Where 'A' (alpha channel) occupies only the
LOWER 7 BITS of the MSB. This very small
loss of alpha channel resolution allows gd 2.x
to keep backwards compatibility by allowing
signed integers to be used to represent colors,
and negative numbers to represent special cases,
#define gdAlphaTransparent 127
* Group: Color Decomposition
* Macro: gdTrueColorGetAlpha
* Gets the alpha channel value
#define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24)
* Macro: gdTrueColorGetRed
* Gets the red channel value
#define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16)
* Macro: gdTrueColorGetGreen
* Gets the green channel value
#define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8)
* Macro: gdTrueColorGetBlue
* Gets the blue channel value
#define gdTrueColorGetBlue(c) ((c) & 0x0000FF)
* When pixels are drawn the new colors are "mixed" with the background
* depending on the effect.
* Note that the effect does not apply to palette images, where pixels
* gdEffectReplace - replace pixels
* gdEffectAlphaBlend - blend pixels, see <gdAlphaBlend>
* gdEffectNormal - default mode; same as gdEffectAlphaBlend
* gdEffectOverlay - overlay pixels, see <gdLayerOverlay>
* gdEffectMultiply - overlay pixels with multiply effect, see
* - <gdImageAlphaBlending>
#define gdEffectReplace 0
#define gdEffectAlphaBlend 1
#define gdEffectOverlay 3
#define gdEffectMultiply 4
# define M_PI 3.14159265358979323846
/* This function accepts truecolor pixel values only. The
source color is composited with the destination color
based on the alpha channel value of the source color.
The resulting color is opaque. */
BGD_DECLARE(int) gdAlphaBlend (int dest, int src);
BGD_DECLARE(int) gdLayerOverlay (int dest, int src);
BGD_DECLARE(int) gdLayerMultiply (int dest, int src);
* Group: Color Quantization
* Enum: gdPaletteQuantizationMethod
* GD_QUANT_DEFAULT - GD_QUANT_LIQ if libimagequant is available,
* GD_QUANT_JQUANT otherwise.
* GD_QUANT_JQUANT - libjpeg's old median cut. Fast, but only uses 16-bit
* GD_QUANT_NEUQUANT - NeuQuant - approximation using Kohonen neural network.
* GD_QUANT_LIQ - A combination of algorithms used in libimagequant
* aiming for the highest quality at cost of speed.
* Note that GD_QUANT_JQUANT does not retain the alpha channel, and
* GD_QUANT_NEUQUANT does not support dithering.
* - <gdImageTrueColorToPaletteSetMethod>
enum gdPaletteQuantizationMethod {
* Constants: gdInterpolationMethod
* GD_BILINEAR_FIXED - fixed point bilinear
* GD_BICUBIC_FIXED - fixed point bicubic integer
* GD_CATMULLROM - Catmullrom
* GD_GENERALIZED_CUBIC - Generalized cubic
* GD_NEAREST_NEIGHBOUR - Nearest neighbour interpolation
* GD_QUADRATIC - Quadratic
* GD_WEIGHTED4 - 4 pixels weighted bilinear interpolation
* GD_LINEAR - bilinear interpolation
* - <gdImageSetInterpolationMethod>
* - <gdImageGetInterpolationMethod>
/* define struct with name and func ptr and add it to gdImageStruct gdInterpolationMethod interpolation; */
/* Interpolation function ptr */
typedef double (* interpolation_method )(double);
The data structure in which gd stores images. <gdImageCreate>,
<gdImageCreateTrueColor> and the various image file-loading functions
return a pointer to this type, and the other functions expect to
receive a pointer to this type as their first argument.
*gdImagePtr* is a pointer to *gdImage*.
(Previous versions of this library encouraged directly manipulating
the contents ofthe struct but we are attempting to move away from
this practice so the fields are no longer documented here. If you
need to poke at the internals of this struct, feel free to look at
typedef struct gdImageStruct {
/* Palette-based image pixels */
/* These are valid in palette images only. See also
'alpha', which appears later in the structure to
preserve binary backwards compatibility */
/* For backwards compatibility, this is set to the
first palette entry with 100% transparency,
and is also set and reset by the
gdImageColorTransparent function. Newer
applications can allocate palette entries
with any desired level of transparency; however,
bear in mind that many viewers, notably
many web browsers, fail to implement
full alpha channel for PNG and provide
support for full opacity or transparency only. */
struct gdImageStruct *brush;
struct gdImageStruct *tile;
int brushColorMap[gdMaxColors];
int tileColorMap[gdMaxColors];
/* New in 2.0: thickness of line. Initialized to 1. */
/* New in 2.0: alpha channel for palettes. Note that only
Macintosh Internet Explorer and (possibly) Netscape 6
really support multiple levels of transparency in
palettes, to my knowledge, as of 2/15/01. Most
common browsers will display 100% opaque and
100% transparent correctly, and do something
unpredictable and/or undesirable for levels
/* Truecolor flag and pixels. New 2.0 fields appear here at the
end to minimize breakage of existing object code. */
/* Should alpha channel be copied, or applied, each time a
pixel is drawn? This applies to truecolor images only.
No attempt is made to alpha-blend in palette images,
even if semitransparent palette entries exist.
To do that, build your image as a truecolor image,
then quantize down to 8 bits. */
/* Should the alpha channel of the image be saved? This affects
PNG at the moment; other future formats may also
have that capability. JPEG doesn't. */
/* There should NEVER BE ACCESSOR MACROS FOR ITEMS BELOW HERE, so this
part of the structure can be safely changed in new releases. */
/* 2.0.12: anti-aliased globals. 2.0.26: just a few vestiges after
switching to the fast, memory-cheap implementation from PHP-gd. */
/* 2.0.12: simple clipping rectangle. These values
must be checked for safety when set; please use
/* 2.1.0: allows to specify resolution in dpi */
/* Selects quantization method, see gdImageTrueColorToPaletteSetMethod() and gdPaletteQuantizationMethod enum. */
int paletteQuantizationMethod;
/* speed/quality trade-off. 1 = best quality, 10 = best speed. 0 = method-specific default.
Applicable to GD_QUANT_LIQ and GD_QUANT_NEUQUANT. */
int paletteQuantizationSpeed;
/* Image will remain true-color if conversion to palette cannot achieve given quality.
Value from 1 to 100, 1 = ugly, 100 = perfect. Applicable to GD_QUANT_LIQ.*/
int paletteQuantizationMinQuality;
/* Image will use minimum number of palette colors needed to achieve given quality. Must be higher than paletteQuantizationMinQuality
Value from 1 to 100, 1 = ugly, 100 = perfect. Applicable to GD_QUANT_LIQ.*/
int paletteQuantizationMaxQuality;
gdInterpolationMethod interpolation_id;
interpolation_method interpolation;
typedef gdImage *gdImagePtr;
/* Point type for use in polygon drawing. */
* Defines a point in a 2D coordinate system using floating point
* x - Floating point position (increase from left to right)
* y - Floating point Row position (increase from top to bottom)
* Pointer to a <gdPointF>
* <gdImageCreate>, <gdImageCreateTrueColor>,