commit 52c42cdea17a6d0ed5461296970aaa43812be193
parent 159ef135cef5a6e63411b5b4bb0a3e71884e030c
Author: ByteProject <stefan.vogt@byteproject.net>
Date: Tue, 4 Mar 2014 22:35:47 +0100
upgrading bundled libgd binary for OS X to 2.1
Diffstat:
15 files changed, 2684 insertions(+), 869 deletions(-)
diff --git a/lib/MacOSX/libgd/include/entities.h b/lib/MacOSX/libgd/include/entities.h
@@ -11,263 +11,263 @@
extern "C" {
#endif
-static struct entities_s {
- char *name;
- int value;
-} entities[] = {
- {"AElig", 198},
- {"Aacute", 193},
- {"Acirc", 194},
- {"Agrave", 192},
- {"Alpha", 913},
- {"Aring", 197},
- {"Atilde", 195},
- {"Auml", 196},
- {"Beta", 914},
- {"Ccedil", 199},
- {"Chi", 935},
- {"Dagger", 8225},
- {"Delta", 916},
- {"ETH", 208},
- {"Eacute", 201},
- {"Ecirc", 202},
- {"Egrave", 200},
- {"Epsilon", 917},
- {"Eta", 919},
- {"Euml", 203},
- {"Gamma", 915},
- {"Iacute", 205},
- {"Icirc", 206},
- {"Igrave", 204},
- {"Iota", 921},
- {"Iuml", 207},
- {"Kappa", 922},
- {"Lambda", 923},
- {"Mu", 924},
- {"Ntilde", 209},
- {"Nu", 925},
- {"OElig", 338},
- {"Oacute", 211},
- {"Ocirc", 212},
- {"Ograve", 210},
- {"Omega", 937},
- {"Omicron", 927},
- {"Oslash", 216},
- {"Otilde", 213},
- {"Ouml", 214},
- {"Phi", 934},
- {"Pi", 928},
- {"Prime", 8243},
- {"Psi", 936},
- {"Rho", 929},
- {"Scaron", 352},
- {"Sigma", 931},
- {"THORN", 222},
- {"Tau", 932},
- {"Theta", 920},
- {"Uacute", 218},
- {"Ucirc", 219},
- {"Ugrave", 217},
- {"Upsilon", 933},
- {"Uuml", 220},
- {"Xi", 926},
- {"Yacute", 221},
- {"Yuml", 376},
- {"Zeta", 918},
- {"aacute", 225},
- {"acirc", 226},
- {"acute", 180},
- {"aelig", 230},
- {"agrave", 224},
- {"alefsym", 8501},
- {"alpha", 945},
- {"amp", 38},
- {"and", 8743},
- {"ang", 8736},
- {"aring", 229},
- {"asymp", 8776},
- {"atilde", 227},
- {"auml", 228},
- {"bdquo", 8222},
- {"beta", 946},
- {"brvbar", 166},
- {"bull", 8226},
- {"cap", 8745},
- {"ccedil", 231},
- {"cedil", 184},
- {"cent", 162},
- {"chi", 967},
- {"circ", 710},
- {"clubs", 9827},
- {"cong", 8773},
- {"copy", 169},
- {"crarr", 8629},
- {"cup", 8746},
- {"curren", 164},
- {"dArr", 8659},
- {"dagger", 8224},
- {"darr", 8595},
- {"deg", 176},
- {"delta", 948},
- {"diams", 9830},
- {"divide", 247},
- {"eacute", 233},
- {"ecirc", 234},
- {"egrave", 232},
- {"empty", 8709},
- {"emsp", 8195},
- {"ensp", 8194},
- {"epsilon", 949},
- {"equiv", 8801},
- {"eta", 951},
- {"eth", 240},
- {"euml", 235},
- {"euro", 8364},
- {"exist", 8707},
- {"fnof", 402},
- {"forall", 8704},
- {"frac12", 189},
- {"frac14", 188},
- {"frac34", 190},
- {"frasl", 8260},
- {"gamma", 947},
- {"ge", 8805},
- {"gt", 62},
- {"hArr", 8660},
- {"harr", 8596},
- {"hearts", 9829},
- {"hellip", 8230},
- {"iacute", 237},
- {"icirc", 238},
- {"iexcl", 161},
- {"igrave", 236},
- {"image", 8465},
- {"infin", 8734},
- {"int", 8747},
- {"iota", 953},
- {"iquest", 191},
- {"isin", 8712},
- {"iuml", 239},
- {"kappa", 954},
- {"lArr", 8656},
- {"lambda", 955},
- {"lang", 9001},
- {"laquo", 171},
- {"larr", 8592},
- {"lceil", 8968},
- {"ldquo", 8220},
- {"le", 8804},
- {"lfloor", 8970},
- {"lowast", 8727},
- {"loz", 9674},
- {"lrm", 8206},
- {"lsaquo", 8249},
- {"lsquo", 8216},
- {"lt", 60},
- {"macr", 175},
- {"mdash", 8212},
- {"micro", 181},
- {"middot", 183},
- {"minus", 8722},
- {"mu", 956},
- {"nabla", 8711},
- {"nbsp", 160},
- {"ndash", 8211},
- {"ne", 8800},
- {"ni", 8715},
- {"not", 172},
- {"notin", 8713},
- {"nsub", 8836},
- {"ntilde", 241},
- {"nu", 957},
- {"oacute", 243},
- {"ocirc", 244},
- {"oelig", 339},
- {"ograve", 242},
- {"oline", 8254},
- {"omega", 969},
- {"omicron", 959},
- {"oplus", 8853},
- {"or", 8744},
- {"ordf", 170},
- {"ordm", 186},
- {"oslash", 248},
- {"otilde", 245},
- {"otimes", 8855},
- {"ouml", 246},
- {"para", 182},
- {"part", 8706},
- {"permil", 8240},
- {"perp", 8869},
- {"phi", 966},
- {"pi", 960},
- {"piv", 982},
- {"plusmn", 177},
- {"pound", 163},
- {"prime", 8242},
- {"prod", 8719},
- {"prop", 8733},
- {"psi", 968},
- {"quot", 34},
- {"rArr", 8658},
- {"radic", 8730},
- {"rang", 9002},
- {"raquo", 187},
- {"rarr", 8594},
- {"rceil", 8969},
- {"rdquo", 8221},
- {"real", 8476},
- {"reg", 174},
- {"rfloor", 8971},
- {"rho", 961},
- {"rlm", 8207},
- {"rsaquo", 8250},
- {"rsquo", 8217},
- {"sbquo", 8218},
- {"scaron", 353},
- {"sdot", 8901},
- {"sect", 167},
- {"shy", 173},
- {"sigma", 963},
- {"sigmaf", 962},
- {"sim", 8764},
- {"spades", 9824},
- {"sub", 8834},
- {"sube", 8838},
- {"sum", 8721},
- {"sup", 8835},
- {"sup1", 185},
- {"sup2", 178},
- {"sup3", 179},
- {"supe", 8839},
- {"szlig", 223},
- {"tau", 964},
- {"there4", 8756},
- {"theta", 952},
- {"thetasym", 977},
- {"thinsp", 8201},
- {"thorn", 254},
- {"tilde", 732},
- {"times", 215},
- {"trade", 8482},
- {"uArr", 8657},
- {"uacute", 250},
- {"uarr", 8593},
- {"ucirc", 251},
- {"ugrave", 249},
- {"uml", 168},
- {"upsih", 978},
- {"upsilon", 965},
- {"uuml", 252},
- {"weierp", 8472},
- {"xi", 958},
- {"yacute", 253},
- {"yen", 165},
- {"yuml", 255},
- {"zeta", 950},
- {"zwj", 8205},
- {"zwnj", 8204},
-};
+ static struct entities_s {
+ char *name;
+ int value;
+ } entities[] = {
+ {"AElig", 198},
+ {"Aacute", 193},
+ {"Acirc", 194},
+ {"Agrave", 192},
+ {"Alpha", 913},
+ {"Aring", 197},
+ {"Atilde", 195},
+ {"Auml", 196},
+ {"Beta", 914},
+ {"Ccedil", 199},
+ {"Chi", 935},
+ {"Dagger", 8225},
+ {"Delta", 916},
+ {"ETH", 208},
+ {"Eacute", 201},
+ {"Ecirc", 202},
+ {"Egrave", 200},
+ {"Epsilon", 917},
+ {"Eta", 919},
+ {"Euml", 203},
+ {"Gamma", 915},
+ {"Iacute", 205},
+ {"Icirc", 206},
+ {"Igrave", 204},
+ {"Iota", 921},
+ {"Iuml", 207},
+ {"Kappa", 922},
+ {"Lambda", 923},
+ {"Mu", 924},
+ {"Ntilde", 209},
+ {"Nu", 925},
+ {"OElig", 338},
+ {"Oacute", 211},
+ {"Ocirc", 212},
+ {"Ograve", 210},
+ {"Omega", 937},
+ {"Omicron", 927},
+ {"Oslash", 216},
+ {"Otilde", 213},
+ {"Ouml", 214},
+ {"Phi", 934},
+ {"Pi", 928},
+ {"Prime", 8243},
+ {"Psi", 936},
+ {"Rho", 929},
+ {"Scaron", 352},
+ {"Sigma", 931},
+ {"THORN", 222},
+ {"Tau", 932},
+ {"Theta", 920},
+ {"Uacute", 218},
+ {"Ucirc", 219},
+ {"Ugrave", 217},
+ {"Upsilon", 933},
+ {"Uuml", 220},
+ {"Xi", 926},
+ {"Yacute", 221},
+ {"Yuml", 376},
+ {"Zeta", 918},
+ {"aacute", 225},
+ {"acirc", 226},
+ {"acute", 180},
+ {"aelig", 230},
+ {"agrave", 224},
+ {"alefsym", 8501},
+ {"alpha", 945},
+ {"amp", 38},
+ {"and", 8743},
+ {"ang", 8736},
+ {"aring", 229},
+ {"asymp", 8776},
+ {"atilde", 227},
+ {"auml", 228},
+ {"bdquo", 8222},
+ {"beta", 946},
+ {"brvbar", 166},
+ {"bull", 8226},
+ {"cap", 8745},
+ {"ccedil", 231},
+ {"cedil", 184},
+ {"cent", 162},
+ {"chi", 967},
+ {"circ", 710},
+ {"clubs", 9827},
+ {"cong", 8773},
+ {"copy", 169},
+ {"crarr", 8629},
+ {"cup", 8746},
+ {"curren", 164},
+ {"dArr", 8659},
+ {"dagger", 8224},
+ {"darr", 8595},
+ {"deg", 176},
+ {"delta", 948},
+ {"diams", 9830},
+ {"divide", 247},
+ {"eacute", 233},
+ {"ecirc", 234},
+ {"egrave", 232},
+ {"empty", 8709},
+ {"emsp", 8195},
+ {"ensp", 8194},
+ {"epsilon", 949},
+ {"equiv", 8801},
+ {"eta", 951},
+ {"eth", 240},
+ {"euml", 235},
+ {"euro", 8364},
+ {"exist", 8707},
+ {"fnof", 402},
+ {"forall", 8704},
+ {"frac12", 189},
+ {"frac14", 188},
+ {"frac34", 190},
+ {"frasl", 8260},
+ {"gamma", 947},
+ {"ge", 8805},
+ {"gt", 62},
+ {"hArr", 8660},
+ {"harr", 8596},
+ {"hearts", 9829},
+ {"hellip", 8230},
+ {"iacute", 237},
+ {"icirc", 238},
+ {"iexcl", 161},
+ {"igrave", 236},
+ {"image", 8465},
+ {"infin", 8734},
+ {"int", 8747},
+ {"iota", 953},
+ {"iquest", 191},
+ {"isin", 8712},
+ {"iuml", 239},
+ {"kappa", 954},
+ {"lArr", 8656},
+ {"lambda", 955},
+ {"lang", 9001},
+ {"laquo", 171},
+ {"larr", 8592},
+ {"lceil", 8968},
+ {"ldquo", 8220},
+ {"le", 8804},
+ {"lfloor", 8970},
+ {"lowast", 8727},
+ {"loz", 9674},
+ {"lrm", 8206},
+ {"lsaquo", 8249},
+ {"lsquo", 8216},
+ {"lt", 60},
+ {"macr", 175},
+ {"mdash", 8212},
+ {"micro", 181},
+ {"middot", 183},
+ {"minus", 8722},
+ {"mu", 956},
+ {"nabla", 8711},
+ {"nbsp", 160},
+ {"ndash", 8211},
+ {"ne", 8800},
+ {"ni", 8715},
+ {"not", 172},
+ {"notin", 8713},
+ {"nsub", 8836},
+ {"ntilde", 241},
+ {"nu", 957},
+ {"oacute", 243},
+ {"ocirc", 244},
+ {"oelig", 339},
+ {"ograve", 242},
+ {"oline", 8254},
+ {"omega", 969},
+ {"omicron", 959},
+ {"oplus", 8853},
+ {"or", 8744},
+ {"ordf", 170},
+ {"ordm", 186},
+ {"oslash", 248},
+ {"otilde", 245},
+ {"otimes", 8855},
+ {"ouml", 246},
+ {"para", 182},
+ {"part", 8706},
+ {"permil", 8240},
+ {"perp", 8869},
+ {"phi", 966},
+ {"pi", 960},
+ {"piv", 982},
+ {"plusmn", 177},
+ {"pound", 163},
+ {"prime", 8242},
+ {"prod", 8719},
+ {"prop", 8733},
+ {"psi", 968},
+ {"quot", 34},
+ {"rArr", 8658},
+ {"radic", 8730},
+ {"rang", 9002},
+ {"raquo", 187},
+ {"rarr", 8594},
+ {"rceil", 8969},
+ {"rdquo", 8221},
+ {"real", 8476},
+ {"reg", 174},
+ {"rfloor", 8971},
+ {"rho", 961},
+ {"rlm", 8207},
+ {"rsaquo", 8250},
+ {"rsquo", 8217},
+ {"sbquo", 8218},
+ {"scaron", 353},
+ {"sdot", 8901},
+ {"sect", 167},
+ {"shy", 173},
+ {"sigma", 963},
+ {"sigmaf", 962},
+ {"sim", 8764},
+ {"spades", 9824},
+ {"sub", 8834},
+ {"sube", 8838},
+ {"sum", 8721},
+ {"sup", 8835},
+ {"sup1", 185},
+ {"sup2", 178},
+ {"sup3", 179},
+ {"supe", 8839},
+ {"szlig", 223},
+ {"tau", 964},
+ {"there4", 8756},
+ {"theta", 952},
+ {"thetasym", 977},
+ {"thinsp", 8201},
+ {"thorn", 254},
+ {"tilde", 732},
+ {"times", 215},
+ {"trade", 8482},
+ {"uArr", 8657},
+ {"uacute", 250},
+ {"uarr", 8593},
+ {"ucirc", 251},
+ {"ugrave", 249},
+ {"uml", 168},
+ {"upsih", 978},
+ {"upsilon", 965},
+ {"uuml", 252},
+ {"weierp", 8472},
+ {"xi", 958},
+ {"yacute", 253},
+ {"yen", 165},
+ {"yuml", 255},
+ {"zeta", 950},
+ {"zwj", 8205},
+ {"zwnj", 8204},
+ };
#define ENTITY_NAME_LENGTH_MAX 8
#define NR_OF_ENTITIES 252
diff --git a/lib/MacOSX/libgd/include/gd.h b/lib/MacOSX/libgd/include/gd.h
@@ -6,75 +6,62 @@ extern "C" {
#define GD_H 1
#define GD_MAJOR_VERSION 2
-#define GD_MINOR_VERSION 0
-#define GD_RELEASE_VERSION 36
-#define GD_EXTRA_VERSION ""
-#define GD_VERSION_STRING "2.0.36"
-
+#define GD_MINOR_VERSION 1
+#define GD_RELEASE_VERSION 0
+#define GD_EXTRA_VERSION "alpha"
+#define GD_VERSION_STRING "2.1.0-alpha"
/* Do the DLL dance: dllexport when building the DLL,
- dllimport when importing from it, nothing when
- not on Silly Silly Windows (tm Aardman Productions). */
+ 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.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. */
-
-#ifndef WIN32
-#define NONDLL 1
-#endif /* WIN32 */
-
-#ifdef NONDLL
-#define BGD_DECLARE(rt) extern rt
-#else
-#ifdef BGDWIN32
-#define BGD_DECLARE(rt) __declspec(dllexport) rt __stdcall
-#else
-#define BGD_DECLARE(rt) __declspec(dllimport) rt _stdcall
-#endif /* BGDWIN32 */
-#endif /* NONDLL */
-
-/* 2.0.20: for actual storage of exported data, functions don't need this,
- currently needed only for font pointers */
-#ifdef NONDLL
-/* 2.0.25: bring back extern */
-#define BGD_EXPORT_DATA_PROT extern
-#define BGD_EXPORT_DATA_IMPL
+ 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)
+# ifdef BGDWIN32
+# ifdef NONDLL
+# define BGD_EXPORT_DATA_PROT
+# else
+# ifdef __GNUC__
+# define BGD_EXPORT_DATA_PROT __attribute__ ((dllexport))
+# else
+# define BGD_EXPORT_DATA_PROT __declspec(dllexport)
+# endif
+# endif
+# else
+# ifdef __GNUC__
+# define BGD_EXPORT_DATA_PROT __attribute__ ((dllimport))
+# else
+# define BGD_EXPORT_DATA_PROT __declspec(dllimport)
+# endif
+# endif
+# define BGD_STDCALL __stdcall
+# define BGD_EXPORT_DATA_IMPL
#else
-#ifdef BGDWIN32
-#define BGD_EXPORT_DATA_PROT __declspec(dllexport) extern
-#define BGD_EXPORT_DATA_IMPL __declspec(dllexport)
-#else
-#define BGD_EXPORT_DATA_PROT __declspec(dllimport) extern
-#define BGD_EXPORT_DATA_IMPL __declspec(dllimport)
-#endif /* BGDWIN32 */
-#endif /* NONDLL */
-
-#ifdef __cplusplus
-extern "C"
-{
+# ifdef HAVE_VISIBILITY
+# define BGD_EXPORT_DATA_PROT __attribute__ ((visibility ("default")))
+# define BGD_EXPORT_DATA_IMPL __attribute__ ((visibility ("hidden")))
+# else
+# define BGD_EXPORT_DATA_PROT
+# define BGD_EXPORT_DATA_IMPL
+# endif
+# define BGD_STDCALL
#endif
-/* some might want to set DEFAULT_FONTPATH from configure in config.h */
-#ifdef NETWARE
-/* default fontpath for netware systems, could probably be handled in configure for 2.1 */
-#define DEFAULT_FONTPATH "sys:/java/nwgfx/lib/x11/fonts/ttf;."
-#define PATHSEPARATOR ";"
-#endif
+#define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt BGD_STDCALL
-/* 2.0.23: more Type 1 fonts */
-#ifndef DEFAULT_FONTPATH
-/* default fontpath for unix systems - whatever happened to standards ! */
-#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:/usr/lib/X11/fonts/Type1:/usr/openwin/lib/X11/fonts/Type1"
-#endif
-#ifndef PATHSEPARATOR
-#define PATHSEPARATOR ":"
+#ifdef __cplusplus
+ extern "C"
+ {
#endif
/* gd.h: declarations file for the graphic-draw module.
@@ -83,41 +70,42 @@ extern "C"
* 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
+ * 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
* documentation. */
/* stdio is needed for file I/O. */
#include <stdio.h>
+#include <stdarg.h>
#include "gd_io.h"
/* 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. */
+ In the wonderful new world of gd 2.0, you can of course have
+ many more colors when using truecolor mode. */
#define gdMaxColors 256
/* 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
- read-only purposes. */
-
-/* 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:
-
- ARGB
-
- 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,
- just as in gd 1.x. */
+ the elements directly. Use the provided macros to
+ access sx, sy, the color table, and colorsTotal for
+ read-only purposes. */
+
+/* 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:
+
+ ARGB
+
+ 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,
+ just as in gd 1.x. */
#define gdAlphaMax 127
#define gdAlphaOpaque 0
@@ -129,119 +117,244 @@ extern "C"
#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
-/* 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. */
+#define GD_TRUE 1
+#define GD_FALSE 0
+
+#define GD_EPSILON 1e-6
+#ifndef M_PI
+# define M_PI 3.14159265358979323846
+#endif
+
+/* 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);
- typedef struct gdImageStruct
- {
- /* Palette-based image pixels */
- unsigned char **pixels;
- int sx;
- int sy;
- /* These are valid in palette images only. See also
- 'alpha', which appears later in the structure to
- preserve binary backwards compatibility */
- int colorsTotal;
- int red[gdMaxColors];
- int green[gdMaxColors];
- int blue[gdMaxColors];
- int open[gdMaxColors];
- /* 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. */
- int transparent;
- int *polyInts;
- int polyAllocated;
- struct gdImageStruct *brush;
- struct gdImageStruct *tile;
- int brushColorMap[gdMaxColors];
- int tileColorMap[gdMaxColors];
- int styleLength;
- int stylePos;
- int *style;
- int interlace;
- /* New in 2.0: thickness of line. Initialized to 1. */
- int thick;
- /* 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
- in between. TBB */
- int alpha[gdMaxColors];
- /* Truecolor flag and pixels. New 2.0 fields appear here at the
- end to minimize breakage of existing object code. */
- int trueColor;
- int **tpixels;
- /* 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. */
- int alphaBlendingFlag;
- /* 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. */
- int saveAlphaFlag;
-
- /* 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. */
- int AA;
- int AA_color;
- int AA_dont_blend;
-
- /* 2.0.12: simple clipping rectangle. These values
- must be checked for safety when set; please use
- gdImageSetClip */
- int cx1;
- int cy1;
- int cx2;
- int cy2;
- }
- gdImage;
-
- typedef gdImage *gdImagePtr;
-
- typedef struct
- {
- /* # of characters in font */
- int nchars;
- /* First character is numbered... (usually 32 = space) */
- int offset;
- /* Character width and height */
- int w;
- int h;
- /* Font data; array of characters, one row after another.
- Easily included in code, also easily loaded from
- data files. */
- char *data;
- }
- gdFont;
+enum gdPaletteQuantizationMethod {
+ GD_QUANT_DEFAULT = 0,
+ GD_QUANT_JQUANT = 1, /* libjpeg's old median cut. Fast, but only uses 16-bit color. */
+ GD_QUANT_NEUQUANT = 2, /* neuquant - approximation using kohonen neural network. */
+ GD_QUANT_LIQ = 3 /* combination of algorithms used in libimagequant/pngquant2 aiming for highest quality at cost of speed */
+};
+
+/**
+ * Group: Transform
+ *
+ * Constants: gdInterpolationMethod
+
+ * GD_BELL - Bell
+ * GD_BESSEL - Bessel
+ * GD_BILINEAR_FIXED - fixed point bilinear
+ * GD_BICUBIC - Bicubic
+ * GD_BICUBIC_FIXED - fixed point bicubic integer
+ * GD_BLACKMAN - Blackman
+ * GD_BOX - Box
+ * GD_BSPLINE - BSpline
+ * GD_CATMULLROM - Catmullrom
+ * GD_GAUSSIAN - Gaussian
+ * GD_GENERALIZED_CUBIC - Generalized cubic
+ * GD_HERMITE - Hermite
+ * GD_HAMMING - Hamming
+ * GD_HANNING - Hannig
+ * GD_MITCHELL - Mitchell
+ * GD_NEAREST_NEIGHBOUR - Nearest neighbour interpolation
+ * GD_POWER - Power
+ * GD_QUADRATIC - Quadratic
+ * GD_SINC - Sinc
+ * GD_TRIANGLE - Triangle
+ * GD_WEIGHTED4 - 4 pixels weighted bilinear interpolation
+ *
+ * See also:
+ * <gdSetInterpolationMethod>
+ **/
+typedef enum {
+ GD_DEFAULT = 0,
+ GD_BELL,
+ GD_BESSEL,
+ GD_BILINEAR_FIXED,
+ GD_BICUBIC,
+ GD_BICUBIC_FIXED,
+ GD_BLACKMAN,
+ GD_BOX,
+ GD_BSPLINE,
+ GD_CATMULLROM,
+ GD_GAUSSIAN,
+ GD_GENERALIZED_CUBIC,
+ GD_HERMITE,
+ GD_HAMMING,
+ GD_HANNING,
+ GD_MITCHELL,
+ GD_NEAREST_NEIGHBOUR,
+ GD_POWER,
+ GD_QUADRATIC,
+ GD_SINC,
+ GD_TRIANGLE,
+ GD_WEIGHTED4,
+ GD_METHOD_COUNT = 21
+} gdInterpolationMethod;
+
+/* define struct with name and func ptr and add it to gdImageStruct gdInterpolationMethod interpolation; */
+
+/* Interpolation function ptr */
+typedef double (* interpolation_method )(double);
+
+typedef struct gdImageStruct {
+ /* Palette-based image pixels */
+ unsigned char **pixels;
+ int sx;
+ int sy;
+ /* These are valid in palette images only. See also
+ 'alpha', which appears later in the structure to
+ preserve binary backwards compatibility */
+ int colorsTotal;
+ int red[gdMaxColors];
+ int green[gdMaxColors];
+ int blue[gdMaxColors];
+ int open[gdMaxColors];
+ /* 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. */
+ int transparent;
+ int *polyInts;
+ int polyAllocated;
+ struct gdImageStruct *brush;
+ struct gdImageStruct *tile;
+ int brushColorMap[gdMaxColors];
+ int tileColorMap[gdMaxColors];
+ int styleLength;
+ int stylePos;
+ int *style;
+ int interlace;
+ /* New in 2.0: thickness of line. Initialized to 1. */
+ int thick;
+ /* 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
+ in between. TBB */
+ int alpha[gdMaxColors];
+ /* Truecolor flag and pixels. New 2.0 fields appear here at the
+ end to minimize breakage of existing object code. */
+ int trueColor;
+ int **tpixels;
+ /* 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. */
+ int alphaBlendingFlag;
+ /* 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. */
+ int saveAlphaFlag;
+
+ /* 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. */
+ int AA;
+ int AA_color;
+ int AA_dont_blend;
+
+ /* 2.0.12: simple clipping rectangle. These values
+ must be checked for safety when set; please use
+ gdImageSetClip */
+ int cx1;
+ int cy1;
+ int cx2;
+ int cy2;
+
+ /* 2.1.0: allows to specify resolution in dpi */
+ unsigned int res_x;
+ unsigned int res_y;
+
+ /* 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;
+}
+gdImage;
+
+typedef gdImage *gdImagePtr;
+
+
+/* Point type for use in polygon drawing. */
+
+/**
+ * Group: Types
+ *
+ * typedef: gdPointF
+ * Defines a point in a 2D coordinate system using floating point
+ * values.
+ * x - Floating point position (increase from left to right)
+ * y - Floating point Row position (increase from top to bottom)
+ *
+ * typedef: gdPointFPtr
+ * Pointer to a <gdPointF>
+ *
+ * See also:
+ * <gdImageCreate>, <gdImageCreateTrueColor>,
+ **/
+typedef struct
+{
+ double x, y;
+}
+gdPointF, *gdPointFPtr;
+
+typedef struct {
+ /* # of characters in font */
+ int nchars;
+ /* First character is numbered... (usually 32 = space) */
+ int offset;
+ /* Character width and height */
+ int w;
+ int h;
+ /* Font data; array of characters, one row after another.
+ Easily included in code, also easily loaded from
+ data files. */
+ char *data;
+}
+gdFont;
/* Text functions take these. */
- typedef gdFont *gdFontPtr;
+typedef gdFont *gdFontPtr;
+
+typedef void(*gdErrorMethod)(int, const char *, va_list);
+
+BGD_DECLARE(void) gdSetErrorMethod(gdErrorMethod);
+BGD_DECLARE(void) gdClearErrorMethod(void);
/* For backwards compatibility only. Use gdImageSetStyle()
- for MUCH more flexible line drawing. Also see
- gdImageSetBrush(). */
+ for MUCH more flexible line drawing. Also see
+ gdImageSetBrush(). */
#define gdDashSize 4
/* Special colors. */
@@ -252,7 +365,7 @@ BGD_DECLARE(int) gdAlphaBlend (int dest, int src);
#define gdTiled (-5)
/* NOT the same as the transparent color index.
- This is used in line styles only. */
+ This is used in line styles only. */
#define gdTransparent (-6)
#define gdAntiAliased (-7)
@@ -269,10 +382,10 @@ BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy);
BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy);
/* Creates an image from various file types. These functions
- return a palette or truecolor image based on the
- nature of the file being loaded. Truecolor PNG
- stays truecolor; palette PNG stays palette-based;
- JPEG is always truecolor. */
+ return a palette or truecolor image based on the
+ nature of the file being loaded. Truecolor PNG
+ stays truecolor; palette PNG stays palette-based;
+ JPEG is always truecolor. */
BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * fd);
BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtxPtr in);
BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data);
@@ -285,22 +398,39 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMP (FILE * inFile);
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx (gdIOCtx * infile);
BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPPtr (int size, void *data);
BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg (FILE * infile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx (FILE * infile, int ignore_warning);
BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx (gdIOCtx * infile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtxEx (gdIOCtx * infile, int ignore_warning);
BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr (int size, void *data);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtrEx (int size, void *data, int ignore_warning);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile);
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiff(FILE *inFile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffPtr(int size, void *data);
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTga( FILE * fp );
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaCtx(gdIOCtx* ctx);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaPtr(int size, void *data);
+
+BGD_DECLARE(gdImagePtr) gdImageCreateFromBmp (FILE * inFile);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromBmpPtr (int size, void *data);
+BGD_DECLARE(gdImagePtr) gdImageCreateFromBmpCtx (gdIOCtxPtr infile);
/* A custom data source. */
/* The source function must return -1 on error, otherwise the number
- of bytes fetched. 0 is EOF, not an error! */
+ of bytes fetched. 0 is EOF, not an error! */
/* context will be passed to your source function. */
- typedef struct
- {
- int (*source) (void *context, char *buffer, int len);
- void *context;
- }
- gdSource, *gdSourcePtr;
+typedef struct {
+ int (*source) (void *context, char *buffer, int len);
+ void *context;
+}
+gdSource, *gdSourcePtr;
- /* Deprecated in favor of gdImageCreateFromPngCtx */
+/* Deprecated in favor of gdImageCreateFromPngCtx */
BGD_DECLARE(gdImagePtr) gdImageCreateFromPngSource (gdSourcePtr in);
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * in);
@@ -312,25 +442,26 @@ BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in);
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data);
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * in, int srcx, int srcy, int w,
- int h);
+ int h);
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy,
- int w, int h);
+ int w, int h);
BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy,
- int w, int h);
- /* 2.0.10: prototype was missing */
+ int w, int h);
+/* 2.0.10: prototype was missing */
BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm (FILE * in);
+BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out);
- /* NOTE: filename, not FILE */
+/* NOTE: filename, not FILE */
BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename);
BGD_DECLARE(void) gdImageDestroy (gdImagePtr im);
/* Replaces or blends with the background depending on the
- most recent call to gdImageAlphaBlending and the
- alpha channel value of 'color'; default is to overwrite.
- Tiling and line styling are also implemented
- here. All other gd drawing functions pass through this call,
- allowing for many useful effects. */
+ most recent call to gdImageAlphaBlending and the
+ alpha channel value of 'color'; default is to overwrite.
+ Tiling and line styling are also implemented
+ here. All other gd drawing functions pass through this call,
+ allowing for many useful effects. */
BGD_DECLARE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color);
/* FreeType 2 text output with hook to extra flags */
@@ -343,92 +474,91 @@ BGD_DECLARE(void) gdImageAABlend (gdImagePtr im);
BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color);
/* For backwards compatibility only. Use gdImageSetStyle()
- for much more flexible line drawing. */
+ for much more flexible line drawing. */
BGD_DECLARE(void) gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2,
- int color);
+ int color);
/* Corners specified (not width and height). Upper left first, lower right
- second. */
+ second. */
BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
- int color);
+ int color);
/* Solid bar. Upper left corner first, lower right corner second. */
BGD_DECLARE(void) gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
- int color);
+ int color);
BGD_DECLARE(void) gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2);
BGD_DECLARE(void) gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P);
+BGD_DECLARE(void) gdImageSetResolution(gdImagePtr im, const unsigned int res_x, const unsigned int res_y);
BGD_DECLARE(int) gdImageBoundsSafe (gdImagePtr im, int x, int y);
BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c,
- int color);
+ int color);
BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c,
- int color);
+ int color);
BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
- unsigned char *s, int color);
+ unsigned char *s, int color);
BGD_DECLARE(void) gdImageStringUp (gdImagePtr im, gdFontPtr f, int x, int y,
- unsigned char *s, int color);
+ unsigned char *s, int color);
BGD_DECLARE(void) gdImageString16 (gdImagePtr im, gdFontPtr f, int x, int y,
- unsigned short *s, int color);
+ unsigned short *s, int color);
BGD_DECLARE(void) gdImageStringUp16 (gdImagePtr im, gdFontPtr f, int x, int y,
- unsigned short *s, int color);
+ unsigned short *s, int color);
/* 2.0.16: for thread-safe use of gdImageStringFT and friends,
- call this before allowing any thread to call gdImageStringFT.
- Otherwise it is invoked by the first thread to invoke
- gdImageStringFT, with a very small but real risk of a race condition.
- Return 0 on success, nonzero on failure to initialize freetype. */
+ call this before allowing any thread to call gdImageStringFT.
+ Otherwise it is invoked by the first thread to invoke
+ gdImageStringFT, with a very small but real risk of a race condition.
+ Return 0 on success, nonzero on failure to initialize freetype. */
BGD_DECLARE(int) gdFontCacheSetup (void);
-/* Optional: clean up after application is done using fonts in
-BGD_DECLARE( )
- gdImageStringFT(). */
+/* Optional: clean up after application is done using fonts in
+ gdImageStringFT(). */
BGD_DECLARE(void) gdFontCacheShutdown (void);
/* 2.0.20: for backwards compatibility. A few applications did start calling
- this function when it first appeared although it was never documented.
- Simply invokes gdFontCacheShutdown. */
+ this function when it first appeared although it was never documented.
+ Simply invokes gdFontCacheShutdown. */
BGD_DECLARE(void) gdFreeFontCache (void);
/* Calls gdImageStringFT. Provided for backwards compatibility only. */
BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y,
- char *string);
+ double ptsize, double angle, int x, int y,
+ char *string);
/* FreeType 2 text output */
BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y,
- char *string);
+ double ptsize, double angle, int x, int y,
+ char *string);
/* 2.0.5: provides an extensible way to pass additional parameters.
- Thanks to Wez Furlong, sorry for the delay. */
+ Thanks to Wez Furlong, sorry for the delay. */
- typedef struct
- {
- int flags; /* Logical OR of gdFTEX_ values */
- double linespacing; /* fine tune line spacing for '\n' */
- int charmap; /* TBB: 2.0.12: may be gdFTEX_Unicode,
+typedef struct {
+ int flags; /* Logical OR of gdFTEX_ values */
+ double linespacing; /* fine tune line spacing for '\n' */
+ int charmap; /* TBB: 2.0.12: may be gdFTEX_Unicode,
gdFTEX_Shift_JIS, gdFTEX_Big5,
or gdFTEX_Adobe_Custom;
when not specified, maps are searched
for in the above order. */
- int hdpi; /* if (flags & gdFTEX_RESOLUTION) */
- int vdpi; /* if (flags & gdFTEX_RESOLUTION) */
- char *xshow; /* if (flags & gdFTEX_XSHOW)
- then, on return, xshow is a malloc'ed
- string contining xshow position data for
- the last string.
-
- NB. The caller is responsible for gdFree'ing
- the xshow string.
- */
- char *fontpath; /* if (flags & gdFTEX_RETURNFONTPATHNAME)
- then, on return, fontpath is a malloc'ed
- string containing the actual font file path name
- used, which can be interesting when fontconfig
- is in use.
-
- The caller is responsible for gdFree'ing the
- fontpath string.
- */
-
- }
- gdFTStringExtra, *gdFTStringExtraPtr;
+ int hdpi; /* if (flags & gdFTEX_RESOLUTION) */
+ int vdpi; /* if (flags & gdFTEX_RESOLUTION) */
+ char *xshow; /* if (flags & gdFTEX_XSHOW)
+ then, on return, xshow is a malloc'ed
+ string containing xshow position data for
+ the last string.
+
+ NB. The caller is responsible for gdFree'ing
+ the xshow string.
+ */
+ char *fontpath; /* if (flags & gdFTEX_RETURNFONTPATHNAME)
+ then, on return, fontpath is a malloc'ed
+ string containing the actual font file path name
+ used, which can be interesting when fontconfig
+ is in use.
+
+ The caller is responsible for gdFree'ing the
+ fontpath string.
+ */
+
+}
+gdFTStringExtra, *gdFTStringExtraPtr;
#define gdFTEX_LINESPACE 1
#define gdFTEX_CHARMAP 2
@@ -436,58 +566,64 @@ BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, char *fon
#define gdFTEX_DISABLE_KERNING 8
#define gdFTEX_XSHOW 16
/* The default unless gdFTUseFontConfig(1); has been called:
- fontlist is a full or partial font file pathname or list thereof
- (i.e. just like before 2.0.29) */
+ fontlist is a full or partial font file pathname or list thereof
+ (i.e. just like before 2.0.29) */
#define gdFTEX_FONTPATHNAME 32
/* Necessary to use fontconfig patterns instead of font pathnames
- as the fontlist argument, unless gdFTUseFontConfig(1); has
- been called. New in 2.0.29 */
+ as the fontlist argument, unless gdFTUseFontConfig(1); has
+ been called. New in 2.0.29 */
#define gdFTEX_FONTCONFIG 64
/* Sometimes interesting when fontconfig is used: the fontpath
- element of the structure above will contain a gdMalloc'd string
- copy of the actual font file pathname used, if this flag is set
+ element of the structure above will contain a gdMalloc'd string
+ copy of the actual font file pathname used, if this flag is set
when the call is made */
#define gdFTEX_RETURNFONTPATHNAME 128
-/* If flag is nonzero, the fontlist parameter to gdImageStringFT
- and gdImageStringFTEx shall be assumed to be a fontconfig font pattern
- if fontconfig was compiled into gd. This function returns zero
- if fontconfig is not available, nonzero otherwise. */
+/* If flag is nonzero, the fontlist parameter to gdImageStringFT
+ and gdImageStringFTEx shall be assumed to be a fontconfig font pattern
+ if fontconfig was compiled into gd. This function returns zero
+ if fontconfig is not available, nonzero otherwise. */
BGD_DECLARE(int) gdFTUseFontConfig(int flag);
/* These are NOT flags; set one in 'charmap' if you set the
- gdFTEX_CHARMAP bit in 'flags'. */
+ gdFTEX_CHARMAP bit in 'flags'. */
#define gdFTEX_Unicode 0
#define gdFTEX_Shift_JIS 1
#define gdFTEX_Big5 2
#define gdFTEX_Adobe_Custom 3
BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist,
- double ptsize, double angle, int x, int y,
- char *string, gdFTStringExtraPtr strex);
+ double ptsize, double angle, int x, int y,
+ char *string, gdFTStringExtraPtr strex);
/* Point type for use in polygon drawing. */
- typedef struct
- {
- int x, y;
- }
- gdPoint, *gdPointPtr;
+typedef struct {
+ int x, y;
+}
+gdPoint, *gdPointPtr;
+
+typedef struct {
+ int x, y;
+ int width, height;
+}
+gdRect, *gdRectPtr;
+
BGD_DECLARE(void) gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c);
BGD_DECLARE(void) gdImageOpenPolygon (gdImagePtr im, gdPointPtr p, int n, int c);
BGD_DECLARE(void) gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c);
-/* These functions still work with truecolor images,
- for which they never return error. */
+/* These functions still work with truecolor images,
+ for which they never return error. */
BGD_DECLARE(int) gdImageColorAllocate (gdImagePtr im, int r, int g, int b);
/* gd 2.0: palette entries with non-opaque transparency are permitted. */
BGD_DECLARE(int) gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a);
/* Assumes opaque is the preferred alpha channel value */
BGD_DECLARE(int) gdImageColorClosest (gdImagePtr im, int r, int g, int b);
/* Closest match taking all four parameters into account.
- A slightly different color with the same transparency
- beats the exact same color with radically different
- transparency */
+ A slightly different color with the same transparency
+ beats the exact same color with radically different
+ transparency */
BGD_DECLARE(int) gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, int a);
/* An alternate method */
BGD_DECLARE(int) gdImageColorClosestHWB (gdImagePtr im, int r, int g, int b);
@@ -501,93 +637,143 @@ BGD_DECLARE(int) gdImageColorResolve (gdImagePtr im, int r, int g, int b);
BGD_DECLARE(int) gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a);
/* A simpler way to obtain an opaque truecolor value for drawing on a
- truecolor image. Not for use with palette images! */
+ truecolor image. Not for use with palette images! */
#define gdTrueColor(r, g, b) (((r) << 16) + \
- ((g) << 8) + \
- (b))
+ ((g) << 8) + \
+ (b))
/* Returns a truecolor value with an alpha channel component.
- gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely
- opaque. */
+ gdAlphaMax (127, **NOT 255**) is transparent, 0 is completely
+ opaque. */
#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \
- ((r) << 16) + \
- ((g) << 8) + \
- (b))
+ ((r) << 16) + \
+ ((g) << 8) + \
+ (b))
BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color);
/* Converts a truecolor image to a palette-based image,
- using a high-quality two-pass quantization routine
- which attempts to preserve alpha channel information
- as well as R/G/B color information when creating
- a palette. If ditherFlag is set, the image will be
- dithered to approximate colors better, at the expense
- of some obvious "speckling." colorsWanted can be
- anything up to 256. If the original source image
- includes photographic information or anything that
- came out of a JPEG, 256 is strongly recommended.
-
- Better yet, don't use these function -- write real
- truecolor PNGs and JPEGs. The disk space gain of
- conversion to palette is not great (for small images
- it can be negative) and the quality loss is ugly.
-
- DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and
- returns a new image. gdImageTrueColorToPalette modifies
- an existing image, and the truecolor pixels are discarded. */
+ using a high-quality two-pass quantization routine
+ which attempts to preserve alpha channel information
+ as well as R/G/B color information when creating
+ a palette. If ditherFlag is set, the image will be
+ dithered to approximate colors better, at the expense
+ of some obvious "speckling." colorsWanted can be
+ anything up to 256. If the original source image
+ includes photographic information or anything that
+ came out of a JPEG, 256 is strongly recommended.
+
+ Better yet, don't use these function -- write real
+ truecolor PNGs and JPEGs. The disk space gain of
+ conversion to palette is not great (for small images
+ it can be negative) and the quality loss is ugly.
+
+ DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and
+ returns a new image. gdImageTrueColorToPalette modifies
+ an existing image, and the truecolor pixels are discarded.
+
+ gdImageTrueColorToPalette() returns TRUE on success, FALSE on failure.
+*/
BGD_DECLARE(gdImagePtr) gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag,
- int colorsWanted);
+ int colorsWanted);
+
+BGD_DECLARE(int) gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag,
+ int colorsWanted);
+
+BGD_DECLARE(int) gdImagePaletteToTrueColor(gdImagePtr src);
+
+/* An attempt at getting the results of gdImageTrueColorToPalette to
+ * look a bit more like the original (im1 is the original and im2 is
+ * the palette version */
-BGD_DECLARE(void) gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag,
- int colorsWanted);
+BGD_DECLARE(int) gdImageColorMatch(gdImagePtr im1, gdImagePtr im2);
+
+/* Selects quantization method used for subsequent gdImageTrueColorToPalette calls.
+ See gdPaletteQuantizationMethod enum (e.g. GD_QUANT_NEUQUANT, GD_QUANT_LIQ).
+ Speed is from 1 (highest quality) to 10 (fastest).
+ Speed 0 selects method-specific default (recommended).
+
+ Returns FALSE if the given method is invalid or not available.
+*/
+BGD_DECLARE(int) gdImageTrueColorToPaletteSetMethod (gdImagePtr im, int method, int speed);
+
+/*
+ Chooses quality range that subsequent call to gdImageTrueColorToPalette will aim for.
+ Min and max quality is in range 1-100 (1 = ugly, 100 = perfect). Max must be higher than min.
+ If palette cannot represent image with at least min_quality, then image will remain true-color.
+ If palette can represent image with quality better than max_quality, then lower number of colors will be used.
+ This function has effect only when GD_QUANT_LIQ method has been selected and the source image is true-color.
+*/
+BGD_DECLARE(void) gdImageTrueColorToPaletteSetQuality (gdImagePtr im, int min_quality, int max_quality);
/* Specifies a color index (if a palette image) or an
- RGB color (if a truecolor image) which should be
- considered 100% transparent. FOR TRUECOLOR IMAGES,
- THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING
- SAVED. Use gdImageSaveAlpha(im, 0); to
- turn off the saving of a full alpha channel in
- a truecolor image. Note that gdImageColorTransparent
- is usually compatible with older browsers that
- do not understand full alpha channels well. TBB */
+ RGB color (if a truecolor image) which should be
+ considered 100% transparent. FOR TRUECOLOR IMAGES,
+ THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING
+ SAVED. Use gdImageSaveAlpha(im, 0); to
+ turn off the saving of a full alpha channel in
+ a truecolor image. Note that gdImageColorTransparent
+ is usually compatible with older browsers that
+ do not understand full alpha channels well. TBB */
BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color);
BGD_DECLARE(void) gdImagePaletteCopy (gdImagePtr dst, gdImagePtr src);
+
+typedef int (*gdCallbackImageColor)(gdImagePtr im, int src);
+
+BGD_DECLARE(int) gdImageColorReplace(gdImagePtr im, int src, int dst);
+BGD_DECLARE(int) gdImageColorReplaceThreshold(gdImagePtr im, int src, int dst, float threshold);
+BGD_DECLARE(int) gdImageColorReplaceArray(gdImagePtr im, int len, int *src, int *dst);
+BGD_DECLARE(int) gdImageColorReplaceCallback(gdImagePtr im, gdCallbackImageColor callback);
+
BGD_DECLARE(void) gdImageGif (gdImagePtr im, FILE * out);
BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * out);
BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * out);
BGD_DECLARE(void) gdImageGifCtx (gdImagePtr im, gdIOCtx * out);
+BGD_DECLARE(void) gdImageTiff(gdImagePtr im, FILE *outFile);
+BGD_DECLARE(void *) gdImageTiffPtr(gdImagePtr im, int *size);
+BGD_DECLARE(void) gdImageTiffCtx(gdImagePtr image, gdIOCtx *out);
+
+BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression);
+BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression);
+BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression);
/* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
- 1 is FASTEST but produces larger files, 9 provides the best
- compression (smallest files) but takes a long time to compress, and
- -1 selects the default compiled into the zlib library. */
+ 1 is FASTEST but produces larger files, 9 provides the best
+ compression (smallest files) but takes a long time to compress, and
+ -1 selects the default compiled into the zlib library. */
BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * out, int level);
BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * out, int level);
BGD_DECLARE(void) gdImageWBMP (gdImagePtr image, int fg, FILE * out);
BGD_DECLARE(void) gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out);
-/* Guaranteed to correctly free memory returned
- by the gdImage*Ptr functions */
+/* Guaranteed to correctly free memory returned by the gdImage*Ptr
+ functions */
BGD_DECLARE(void) gdFree (void *m);
/* Best to free this memory with gdFree(), not free() */
BGD_DECLARE(void *) gdImageWBMPPtr (gdImagePtr im, int *size, int fg);
/* 100 is highest quality (there is always a little loss with JPEG).
- 0 is lowest. 10 is about the lowest useful setting. */
+ 0 is lowest. 10 is about the lowest useful setting. */
BGD_DECLARE(void) gdImageJpeg (gdImagePtr im, FILE * out, int quality);
BGD_DECLARE(void) gdImageJpegCtx (gdImagePtr im, gdIOCtx * out, int quality);
/* Best to free this memory with gdFree(), not free() */
BGD_DECLARE(void *) gdImageJpegPtr (gdImagePtr im, int *size, int quality);
+BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization);
+BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile);
+BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size);
+BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization);
+BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization);
+
/* Legal values for Disposal. gdDisposalNone is always used by
- the built-in optimizer if previm is passed. */
+ the built-in optimizer if previm is passed. */
enum {
gdDisposalUnknown,
@@ -606,17 +792,16 @@ BGD_DECLARE(void *) gdImageGifAnimBeginPtr(gdImagePtr im, int *size, int GlobalC
BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);
BGD_DECLARE(void *) gdImageGifAnimEndPtr(int *size);
-/* A custom data sink. For backwards compatibility. Use
- gdIOCtx instead. */
-/* The sink function must return -1 on error, otherwise the number
- of bytes written, which must be equal to len. */
-/* context will be passed to your sink function. */
- typedef struct
- {
- int (*sink) (void *context, const char *buffer, int len);
- void *context;
- }
- gdSink, *gdSinkPtr;
+/* A custom data sink. For backwards compatibility. Use gdIOCtx
+ instead. The sink function must return -1 on error, otherwise the
+ number of bytes written, which must be equal to len. Context will
+ be passed to your sink function.
+*/
+typedef struct {
+ int (*sink) (void *context, const char *buffer, int len);
+ void *context;
+}
+gdSink, *gdSinkPtr;
BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr out);
@@ -636,20 +821,17 @@ BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size);
/* Best to free this memory with gdFree(), not free() */
BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size);
-BGD_DECLARE(void) gdImageEllipse (gdImagePtr im, int cx, int cy, int w, int h,
- int color);
-
/* Style is a bitwise OR ( | operator ) of these.
- gdArc and gdChord are mutually exclusive;
- gdChord just connects the starting and ending
- angles with a straight line, while gdArc produces
- a rounded edge. gdPie is a synonym for gdArc.
- gdNoFill indicates that the arc or chord should be
- outlined, not filled. gdEdged, used together with
- gdNoFill, indicates that the beginning and ending
- angles should be connected to the center; this is
- a good way to outline (rather than fill) a
- 'pie slice'. */
+ gdArc and gdChord are mutually exclusive;
+ gdChord just connects the starting and ending
+ angles with a straight line, while gdArc produces
+ a rounded edge. gdPie is a synonym for gdArc.
+ gdNoFill indicates that the arc or chord should be
+ outlined, not filled. gdEdged, used together with
+ gdNoFill, indicates that the beginning and ending
+ angles should be connected to the center; this is
+ a good way to outline (rather than fill) a
+ 'pie slice'. */
#define gdArc 0
#define gdPie gdArc
#define gdChord 1
@@ -657,116 +839,153 @@ BGD_DECLARE(void) gdImageEllipse (gdImagePtr im, int cx, int cy, int w, int h,
#define gdEdged 4
BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s,
- int e, int color, int style);
+ int e, int color, int style);
BGD_DECLARE(void) gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,
- int color);
+ int color);
BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h,
- int color);
+ int color);
BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
- int color);
+ int color);
BGD_DECLARE(void) gdImageFill (gdImagePtr im, int x, int y, int color);
BGD_DECLARE(void) gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
- int srcX, int srcY, int w, int h);
+ int srcX, int srcY, int w, int h);
BGD_DECLARE(void) gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
- int srcX, int srcY, int w, int h, int pct);
+ int srcX, int srcY, int w, int h, int pct);
BGD_DECLARE(void) gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX,
- int dstY, int srcX, int srcY, int w, int h,
- int pct);
+ int dstY, int srcX, int srcY, int w, int h,
+ int pct);
/* Stretches or shrinks to fit, as needed. Does NOT attempt
- to average the entire set of source pixels that scale down onto the
- destination pixel. */
+ to average the entire set of source pixels that scale down onto the
+ destination pixel. */
BGD_DECLARE(void) gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
- int srcX, int srcY, int dstW, int dstH, int srcW,
- int srcH);
+ int srcX, int srcY, int dstW, int dstH, int srcW,
+ int srcH);
/* gd 2.0: stretches or shrinks to fit, as needed. When called with a
- truecolor destination image, this function averages the
- entire set of source pixels that scale down onto the
- destination pixel, taking into account what portion of the
- destination pixel each source pixel represents. This is a
- floating point operation, but this is not a performance issue
- on modern hardware, except for some embedded devices. If the
- destination is a palette image, gdImageCopyResized is
- substituted automatically. */
+ truecolor destination image, this function averages the
+ entire set of source pixels that scale down onto the
+ destination pixel, taking into account what portion of the
+ destination pixel each source pixel represents. This is a
+ floating point operation, but this is not a performance issue
+ on modern hardware, except for some embedded devices. If the
+ destination is a palette image, gdImageCopyResized is
+ substituted automatically. */
BGD_DECLARE(void) gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX,
- int dstY, int srcX, int srcY, int dstW, int dstH,
- int srcW, int srcH);
+ int dstY, int srcX, int srcY, int dstW, int dstH,
+ int srcW, int srcH);
/* gd 2.0.8: gdImageCopyRotated is added. Source
- is a rectangle, with its upper left corner at
- srcX and srcY. Destination is the *center* of
- the rotated copy. Angle is in degrees, same as
- gdImageArc. Floating point destination center
- coordinates allow accurate rotation of
- objects of odd-numbered width or height. */
+ is a rectangle, with its upper left corner at
+ srcX and srcY. Destination is the *center* of
+ the rotated copy. Angle is in degrees, same as
+ gdImageArc. Floating point destination center
+ coordinates allow accurate rotation of
+ objects of odd-numbered width or height. */
BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst,
- gdImagePtr src,
- double dstX, double dstY,
- int srcX, int srcY,
- int srcWidth, int srcHeight, int angle);
+ gdImagePtr src,
+ double dstX, double dstY,
+ int srcX, int srcY,
+ int srcWidth, int srcHeight, int angle);
+
+BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src);
BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush);
BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile);
BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c);
BGD_DECLARE(void) gdImageSetAntiAliasedDontBlend (gdImagePtr im, int c, int dont_blend);
BGD_DECLARE(void) gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels);
-/* Line thickness (defaults to 1). Affects lines, ellipses,
- rectangles, polygons and so forth. */
+/* Line thickness (defaults to 1). Affects lines, ellipses,
+ rectangles, polygons and so forth. */
BGD_DECLARE(void) gdImageSetThickness (gdImagePtr im, int thickness);
/* On or off (1 or 0) for all three of these. */
BGD_DECLARE(void) gdImageInterlace (gdImagePtr im, int interlaceArg);
BGD_DECLARE(void) gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg);
BGD_DECLARE(void) gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg);
+BGD_DECLARE(gdImagePtr) gdImageNeuQuant(gdImagePtr im, const int max_color, int sample_factor);
+
+enum gdPixelateMode {
+ GD_PIXELATE_UPPERLEFT,
+ GD_PIXELATE_AVERAGE
+};
+
+BGD_DECLARE(int) gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode);
+
+typedef struct {
+ int sub;
+ int plus;
+ unsigned int num_colors;
+ int *colors;
+ unsigned int seed;
+} gdScatter, *gdScatterPtr;
+
+BGD_DECLARE(int) gdImageScatter(gdImagePtr im, int sub, int plus);
+BGD_DECLARE(int) gdImageScatterColor(gdImagePtr im, int sub, int plus, int colors[], unsigned int num_colors);
+BGD_DECLARE(int) gdImageScatterEx(gdImagePtr im, gdScatterPtr s);
+BGD_DECLARE(int) gdImageSmooth(gdImagePtr im, float weight);
+BGD_DECLARE(int) gdImageMeanRemoval(gdImagePtr im);
+BGD_DECLARE(int) gdImageEmboss(gdImagePtr im);
+BGD_DECLARE(int) gdImageGaussianBlur(gdImagePtr im);
+BGD_DECLARE(int) gdImageEdgeDetectQuick(gdImagePtr src);
+BGD_DECLARE(int) gdImageSelectiveBlur( gdImagePtr src);
+BGD_DECLARE(int) gdImageConvolution(gdImagePtr src, float filter[3][3], float filter_div, float offset);
+BGD_DECLARE(int) gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha);
+BGD_DECLARE(int) gdImageContrast(gdImagePtr src, double contrast);
+BGD_DECLARE(int) gdImageBrightness(gdImagePtr src, int brightness);
+BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src);
+BGD_DECLARE(int) gdImageNegate(gdImagePtr src);
+
/* Macros to access information about images. */
/* Returns nonzero if the image is a truecolor image,
- zero for a palette image. */
-
+ zero for a palette image. */
#define gdImageTrueColor(im) ((im)->trueColor)
#define gdImageSX(im) ((im)->sx)
#define gdImageSY(im) ((im)->sy)
#define gdImageColorsTotal(im) ((im)->colorsTotal)
#define gdImageRed(im, c) ((im)->trueColor ? gdTrueColorGetRed(c) : \
- (im)->red[(c)])
+ (im)->red[(c)])
#define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \
- (im)->green[(c)])
+ (im)->green[(c)])
#define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \
- (im)->blue[(c)])
+ (im)->blue[(c)])
#define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \
- (im)->alpha[(c)])
+ (im)->alpha[(c)])
#define gdImageGetTransparent(im) ((im)->transparent)
#define gdImageGetInterlaced(im) ((im)->interlace)
/* These macros provide direct access to pixels in
- palette-based and truecolor images, respectively.
- If you use these macros, you must perform your own
- bounds checking. Use of the macro for the correct type
- of image is also your responsibility. */
+ palette-based and truecolor images, respectively.
+ If you use these macros, you must perform your own
+ bounds checking. Use of the macro for the correct type
+ of image is also your responsibility. */
#define gdImagePalettePixel(im, x, y) (im)->pixels[(y)][(x)]
#define gdImageTrueColorPixel(im, x, y) (im)->tpixels[(y)][(x)]
+#define gdImageResolutionX(im) (im)->res_x
+#define gdImageResolutionY(im) (im)->res_y
+
/* I/O Support routines. */
BGD_DECLARE(gdIOCtx *) gdNewFileCtx (FILE *);
- /* If data is null, size is ignored and an initial data buffer is
- allocated automatically. NOTE: this function assumes gd has the right
- to free or reallocate "data" at will! Also note that gd will free
- "data" when the IO context is freed. If data is not null, it must point
- to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr.
- If not, see gdNewDynamicCtxEx for an alternative. */
+/* If data is null, size is ignored and an initial data buffer is
+ allocated automatically. NOTE: this function assumes gd has the right
+ to free or reallocate "data" at will! Also note that gd will free
+ "data" when the IO context is freed. If data is not null, it must point
+ to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr.
+ If not, see gdNewDynamicCtxEx for an alternative. */
BGD_DECLARE(gdIOCtx *) gdNewDynamicCtx (int size, void *data);
- /* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as
- needed as described above. If freeFlag is zero, gd will never free
- or reallocate "data," which means that the context should only be used
- for *reading* an image from a memory buffer, or writing an image to a
- memory buffer which is already large enough. If the memory buffer is
- not large enough and an image write is attempted, the write operation
- will fail. Those wishing to write an image to a buffer in memory have
- a much simpler alternative in the gdImage[something]Ptr functions. */
+/* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as
+ needed as described above. If freeFlag is zero, gd will never free
+ or reallocate "data", which means that the context should only be used
+ for *reading* an image from a memory buffer, or writing an image to a
+ memory buffer which is already large enough. If the memory buffer is
+ not large enough and an image write is attempted, the write operation
+ will fail. Those wishing to write an image to a buffer in memory have
+ a much simpler alternative in the gdImage[something]Ptr functions. */
BGD_DECLARE(gdIOCtx *) gdNewDynamicCtxEx (int size, void *data, int freeFlag);
BGD_DECLARE(gdIOCtx *) gdNewSSCtx (gdSourcePtr in, gdSinkPtr out);
BGD_DECLARE(void *) gdDPExtractData (struct gdIOCtx *ctx, int *size);
@@ -784,6 +1003,89 @@ BGD_DECLARE(void *) gdDPExtractData (struct gdIOCtx *ctx, int *size);
/* Image comparison definitions */
BGD_DECLARE(int) gdImageCompare (gdImagePtr im1, gdImagePtr im2);
+BGD_DECLARE(void) gdImageFlipHorizontal(gdImagePtr im);
+BGD_DECLARE(void) gdImageFlipVertical(gdImagePtr im);
+BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im);
+
+#define GD_FLIP_HORINZONTAL 1
+#define GD_FLIP_VERTICAL 2
+#define GD_FLIP_BOTH 3
+
+/**
+ * Group: Crop
+ *
+ * Constants: gdCropMode
+ * GD_CROP_DEFAULT - Default crop mode (4 corners or background)
+ * GD_CROP_TRANSPARENT - Crop using the transparent color
+ * GD_CROP_BLACK - Crop black borders
+ * GD_CROP_WHITE - Crop white borders
+ * GD_CROP_SIDES - Crop using colors of the 4 corners
+ *
+ * See also:
+ * <gdImageAutoCrop>
+ **/
+enum gdCropMode {
+ GD_CROP_DEFAULT = 0,
+ GD_CROP_TRANSPARENT,
+ GD_CROP_BLACK,
+ GD_CROP_WHITE,
+ GD_CROP_SIDES,
+ GD_CROP_THRESHOLD
+};
+
+BGD_DECLARE(gdImagePtr) gdImageCrop(gdImagePtr src, const gdRect *crop);
+BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode);
+BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int color, const float threshold);
+
+BGD_DECLARE(int) gdImageSetInterpolationMethod(gdImagePtr im, gdInterpolationMethod id);
+
+gdImagePtr gdImageScaleBilinear(gdImagePtr im, const unsigned int new_width, const unsigned int new_height);
+gdImagePtr gdImageScaleBicubic(gdImagePtr src_img, const unsigned int new_width, const unsigned int new_height);
+gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, const unsigned int height);
+gdImagePtr gdImageScaleNearestNeighbour(gdImagePtr im, const unsigned int width, const unsigned int height);
+gdImagePtr gdImageScaleTwoPass(const gdImagePtr pOrigImage, const unsigned int uOrigWidth, const unsigned int uOrigHeight, const unsigned int uNewWidth, const unsigned int uNewHeight);
+BGD_DECLARE(gdImagePtr) gdImageScale(const gdImagePtr src, const unsigned int new_width, const unsigned int new_height);
+
+gdImagePtr gdImageRotate90(gdImagePtr src, int ignoretransparent);
+gdImagePtr gdImageRotate180(gdImagePtr src, int ignoretransparent);
+gdImagePtr gdImageRotate270(gdImagePtr src, int ignoretransparent);
+gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, const int bgColor);
+gdImagePtr gdImageRotateBilinear(gdImagePtr src, const float degrees, const int bgColor);
+gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const int bgColor);
+gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor);
+BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor);
+
+typedef enum {
+ GD_AFFINE_TRANSLATE = 0,
+ GD_AFFINE_SCALE,
+ GD_AFFINE_ROTATE,
+ GD_AFFINE_SHEAR_HORIZONTAL,
+ GD_AFFINE_SHEAR_VERTICAL
+} gdAffineStandardMatrix;
+
+BGD_DECLARE(int) gdAffineApplyToPointF (gdPointFPtr dst, const gdPointFPtr src, const double affine[6]);
+BGD_DECLARE(int) gdAffineInvert (double dst[6], const double src[6]);
+BGD_DECLARE(int) gdAffineFlip (double dst_affine[6], const double src_affine[6], const int flip_h, const int flip_v);
+BGD_DECLARE(int) gdAffineConcat (double dst[6], const double m1[6], const double m2[6]);
+
+BGD_DECLARE(int) gdAffineIdentity (double dst[6]);
+BGD_DECLARE(int) gdAffineScale (double dst[6], const double scale_x, const double scale_y);
+BGD_DECLARE(int) gdAffineRotate (double dst[6], const double angle);
+BGD_DECLARE(int) gdAffineShearHorizontal (double dst[6], const double angle);
+BGD_DECLARE(int) gdAffineShearVertical(double dst[6], const double angle);
+BGD_DECLARE(int) gdAffineTranslate (double dst[6], const double offset_x, const double offset_y);
+BGD_DECLARE(double) gdAffineExpansion (const double src[6]);
+BGD_DECLARE(int) gdAffineRectilinear (const double src[6]);
+BGD_DECLARE(int) gdAffineEqual (const double matrix1[6], const double matrix2[6]);
+BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst, const gdImagePtr src, gdRectPtr src_area, const double affine[6]);
+BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst, int dst_x, int dst_y, const gdImagePtr src, gdRectPtr src_region, const double affine[6]);
+/*
+gdTransformAffineCopy(gdImagePtr dst, int x0, int y0, int x1, int y1,
+ const gdImagePtr src, int src_width, int src_height,
+ const double affine[6]);
+*/
+BGD_DECLARE(int) gdTransformAffineBoundingBox(gdRectPtr src, const double affine[6], gdRectPtr bbox);
+
#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 */
@@ -795,7 +1097,7 @@ BGD_DECLARE(int) gdImageCompare (gdImagePtr im1, gdImagePtr im2);
#define GD_CMP_TRUECOLOR 256 /* Truecolor vs palette differs */
/* resolution affects ttf font rendering, particularly hinting */
-#define GD_RESOLUTION 96 /* pixels per inch */
+#define GD_RESOLUTION 96 /* pixels per inch */
#ifdef __cplusplus
}
diff --git a/lib/MacOSX/libgd/include/gd_color_map.h b/lib/MacOSX/libgd/include/gd_color_map.h
@@ -0,0 +1,30 @@
+#ifndef GD_COLOR_MAP_H
+#define GD_COLOR_MAP_H 1
+
+#include "gd.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct {
+ char *color_name;
+ int red;
+ int green;
+ int blue;
+} gdColorMapEntry;
+
+typedef struct {
+ int num_entries;
+ gdColorMapEntry *entries;
+} gdColorMap;
+
+extern BGD_EXPORT_DATA_PROT gdColorMap GD_COLOR_MAP_X11;
+
+BGD_DECLARE(int) gdColorMapLookup(const gdColorMap color_map, const char *color_name, int *r, int *g, int *b);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/MacOSX/libgd/include/gd_errors.h b/lib/MacOSX/libgd/include/gd_errors.h
@@ -0,0 +1,46 @@
+#ifndef GD_ERRORS_H
+#define GD_ERRORS_H
+
+#ifndef _WIN32
+# include <syslog.h>
+#else
+/*
+ * priorities/facilities are encoded into a single 32-bit quantity, where the
+ * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
+ * (0-big number). Both the priorities and the facilities map roughly
+ * one-to-one to strings in the syslogd(8) source code. This mapping is
+ * included in this file.
+ *
+ * priorities (these are ordered)
+ */
+# define LOG_EMERG 0 /* system is unusable */
+# define LOG_ALERT 1 /* action must be taken immediately */
+# define LOG_CRIT 2 /* critical conditions */
+# define LOG_ERR 3 /* error conditions */
+# define LOG_WARNING 4 /* warning conditions */
+# define LOG_NOTICE 5 /* normal but significant condition */
+# define LOG_INFO 6 /* informational */
+# define LOG_DEBUG 7 /* debug-level messages */
+#endif
+
+/*
+LOG_EMERG system is unusable
+LOG_ALERT action must be taken immediately
+LOG_CRIT critical conditions
+LOG_ERR error conditions
+LOG_WARNING warning conditions
+LOG_NOTICE normal, but significant, condition
+LOG_INFO informational message
+LOG_DEBUG debug-level message
+*/
+
+#define GD_ERROR LOG_ERR
+#define GD_WARNING LOG_WARNING
+#define GD_NOTICE LOG_NOTICE
+#define GD_INFO LOG_INFO
+#define GD_DEBUG LOG_DEBUG
+
+void gd_error(const char *format, ...);
+void gd_error_ex(int priority, const char *format, ...);
+
+#endif
diff --git a/lib/MacOSX/libgd/include/gd_io.h b/lib/MacOSX/libgd/include/gd_io.h
@@ -8,45 +8,42 @@ extern "C" {
#include <stdio.h>
#ifdef VMS
-#define Putchar gdPutchar
+# define Putchar gdPutchar
#endif
-typedef struct gdIOCtx
-{
- int (*getC) (struct gdIOCtx *);
- int (*getBuf) (struct gdIOCtx *, void *, int);
-
- void (*putC) (struct gdIOCtx *, int);
- int (*putBuf) (struct gdIOCtx *, const void *, int);
-
- /* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
- int (*seek) (struct gdIOCtx *, const int);
-
- long (*tell) (struct gdIOCtx *);
-
- void (*gd_free) (struct gdIOCtx *);
-
-}
-gdIOCtx;
-
-typedef struct gdIOCtx *gdIOCtxPtr;
-
-void Putword (int w, gdIOCtx * ctx);
-void Putchar (int c, gdIOCtx * ctx);
-
- void gdPutC (const unsigned char c, gdIOCtx * ctx);
- int gdPutBuf (const void *, int, gdIOCtx *);
- void gdPutWord (int w, gdIOCtx * ctx);
- void gdPutInt (int w, gdIOCtx * ctx);
-
- int gdGetC (gdIOCtx * ctx);
- int gdGetBuf (void *, int, gdIOCtx *);
- int gdGetByte (int *result, gdIOCtx * ctx);
- int gdGetWord (int *result, gdIOCtx * ctx);
- int gdGetInt (int *result, gdIOCtx * ctx);
-
- int gdSeek (gdIOCtx * ctx, const int offset);
- long gdTell (gdIOCtx * ctx);
+ typedef struct gdIOCtx {
+ int (*getC)(struct gdIOCtx *);
+ int (*getBuf)(struct gdIOCtx *, void *, int);
+ void (*putC)(struct gdIOCtx *, int);
+ int (*putBuf)(struct gdIOCtx *, const void *, int);
+ /* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
+ int (*seek)(struct gdIOCtx *, const int);
+ long (*tell)(struct gdIOCtx *);
+ void (*gd_free)(struct gdIOCtx *);
+ void *data;
+ }
+ gdIOCtx;
+
+ typedef struct gdIOCtx *gdIOCtxPtr;
+
+ void Putword(int w, gdIOCtx *ctx);
+ void Putchar(int c, gdIOCtx *ctx);
+
+ void gdPutC(const unsigned char c, gdIOCtx *ctx);
+ int gdPutBuf(const void *, int, gdIOCtx *);
+ void gdPutWord(int w, gdIOCtx *ctx);
+ void gdPutInt(int w, gdIOCtx *ctx);
+
+ int gdGetC(gdIOCtx *ctx);
+ int gdGetBuf(void *, int, gdIOCtx *);
+ int gdGetByte(int *result, gdIOCtx *ctx);
+ int gdGetWord(int *result, gdIOCtx *ctx);
+ int gdGetWordLSB(signed short int *result, gdIOCtx *ctx);
+ int gdGetInt(int *result, gdIOCtx *ctx);
+ int gdGetIntLSB(signed int *result, gdIOCtx *ctx);
+
+ int gdSeek(gdIOCtx *ctx, const int offset);
+ long gdTell(gdIOCtx *ctx);
#endif
diff --git a/lib/MacOSX/libgd/include/gdcache.h b/lib/MacOSX/libgd/include/gdcache.h
@@ -2,91 +2,86 @@
extern "C" {
#endif
-/*
- * gdcache.h
- *
- * Caches of pointers to user structs in which the least-recently-used
- * element is replaced in the event of a cache miss after the cache has
- * reached a given size.
- *
- * John Ellson (ellson@graphviz.org) Oct 31, 1997
- *
- * Test this with:
- * gcc -o gdcache -g -Wall -DTEST gdcache.c
- *
- * The cache is implemented by a singly-linked list of elements
- * each containing a pointer to a user struct that is being managed by
- * the cache.
- *
- * The head structure has a pointer to the most-recently-used
- * element, and elements are moved to this position in the list each
- * time they are used. The head also contains pointers to three
- * user defined functions:
- * - a function to test if a cached userdata matches some keydata
- * - a function to provide a new userdata struct to the cache
- * if there has been a cache miss.
- * - a function to release a userdata struct when it is
- * no longer being managed by the cache
- *
- * In the event of a cache miss the cache is allowed to grow up to
- * a specified maximum size. After the maximum size is reached then
- * the least-recently-used element is discarded to make room for the
- * new. The most-recently-returned value is always left at the
- * beginning of the list after retrieval.
- *
- * In the current implementation the cache is traversed by a linear
- * search from most-recent to least-recent. This linear search
- * probably limits the usefulness of this implementation to cache
- * sizes of a few tens of elements.
- */
+ /*
+ * gdcache.h
+ *
+ * Caches of pointers to user structs in which the least-recently-used
+ * element is replaced in the event of a cache miss after the cache has
+ * reached a given size.
+ *
+ * John Ellson (ellson@graphviz.org) Oct 31, 1997
+ *
+ * Test this with:
+ * gcc -o gdcache -g -Wall -DTEST gdcache.c
+ *
+ * The cache is implemented by a singly-linked list of elements
+ * each containing a pointer to a user struct that is being managed by
+ * the cache.
+ *
+ * The head structure has a pointer to the most-recently-used
+ * element, and elements are moved to this position in the list each
+ * time they are used. The head also contains pointers to three
+ * user defined functions:
+ * - a function to test if a cached userdata matches some keydata
+ * - a function to provide a new userdata struct to the cache
+ * if there has been a cache miss.
+ * - a function to release a userdata struct when it is
+ * no longer being managed by the cache
+ *
+ * In the event of a cache miss the cache is allowed to grow up to
+ * a specified maximum size. After the maximum size is reached then
+ * the least-recently-used element is discarded to make room for the
+ * new. The most-recently-returned value is always left at the
+ * beginning of the list after retrieval.
+ *
+ * In the current implementation the cache is traversed by a linear
+ * search from most-recent to least-recent. This linear search
+ * probably limits the usefulness of this implementation to cache
+ * sizes of a few tens of elements.
+ */
-/*********************************************************/
-/* header */
-/*********************************************************/
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+ /*********************************************************/
+ /* header */
+ /*********************************************************/
#include <stdlib.h>
#ifndef NULL
-#define NULL (void *)0
+# define NULL (void *)0
#endif
-/* user defined function templates */
-typedef int (*gdCacheTestFn_t) (void *userdata, void *keydata);
-typedef void *(*gdCacheFetchFn_t) (char **error, void *keydata);
-typedef void (*gdCacheReleaseFn_t) (void *userdata);
+ /* user defined function templates */
+ typedef int (*gdCacheTestFn_t)(void *userdata, void *keydata);
+ typedef void *(*gdCacheFetchFn_t)(char **error, void *keydata);
+ typedef void (*gdCacheReleaseFn_t)(void *userdata);
-/* element structure */
-typedef struct gdCache_element_s gdCache_element_t;
-struct gdCache_element_s
-{
- gdCache_element_t *next;
- void *userdata;
-};
+ /* element structure */
+ typedef struct gdCache_element_s gdCache_element_t;
+ struct gdCache_element_s {
+ gdCache_element_t *next;
+ void *userdata;
+ };
-/* head structure */
-typedef struct gdCache_head_s gdCache_head_t;
-struct gdCache_head_s
-{
- gdCache_element_t *mru;
- int size;
- char *error;
- gdCacheTestFn_t gdCacheTest;
- gdCacheFetchFn_t gdCacheFetch;
- gdCacheReleaseFn_t gdCacheRelease;
-};
+ /* head structure */
+ typedef struct gdCache_head_s gdCache_head_t;
+ struct gdCache_head_s {
+ gdCache_element_t *mru;
+ int size;
+ char *error;
+ gdCacheTestFn_t gdCacheTest;
+ gdCacheFetchFn_t gdCacheFetch;
+ gdCacheReleaseFn_t gdCacheRelease;
+ };
-/* function templates */
-gdCache_head_t *gdCacheCreate (int size,
- gdCacheTestFn_t gdCacheTest,
- gdCacheFetchFn_t gdCacheFetch,
- gdCacheReleaseFn_t gdCacheRelease);
+ /* function templates */
+ gdCache_head_t *gdCacheCreate(int size,
+ gdCacheTestFn_t gdCacheTest,
+ gdCacheFetchFn_t gdCacheFetch,
+ gdCacheReleaseFn_t gdCacheRelease
+ );
-void gdCacheDelete (gdCache_head_t * head);
+ void gdCacheDelete(gdCache_head_t *head);
-void *gdCacheGet (gdCache_head_t * head, void *keydata);
+ void *gdCacheGet(gdCache_head_t *head, void *keydata);
#ifdef __cplusplus
}
diff --git a/lib/MacOSX/libgd/include/gdfontg.h b/lib/MacOSX/libgd/include/gdfontg.h
@@ -1,8 +1,3 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
#ifndef _GDFONTG_H_
#define _GDFONTG_H_ 1
@@ -21,18 +16,13 @@ extern "C"
"Libor Skarvada, libor@informatics.muni.cz"
*/
-
#include "gd.h"
- BGD_EXPORT_DATA_PROT gdFontPtr gdFontGiant;
- BGD_DECLARE(gdFontPtr) gdFontGetGiant(void);
+extern BGD_EXPORT_DATA_PROT gdFontPtr gdFontGiant;
+BGD_DECLARE(gdFontPtr) gdFontGetGiant(void);
#ifdef __cplusplus
}
#endif
#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/lib/MacOSX/libgd/include/gdfontl.h b/lib/MacOSX/libgd/include/gdfontl.h
@@ -1,8 +1,3 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
#ifndef _GDFONTL_H_
#define _GDFONTL_H_ 1
@@ -22,18 +17,13 @@ extern "C"
"Libor Skarvada, libor@informatics.muni.cz"
*/
-
#include "gd.h"
- BGD_EXPORT_DATA_PROT gdFontPtr gdFontLarge;
- BGD_DECLARE(gdFontPtr) gdFontGetLarge(void);
+extern BGD_EXPORT_DATA_PROT gdFontPtr gdFontLarge;
+BGD_DECLARE(gdFontPtr) gdFontGetLarge(void);
#ifdef __cplusplus
}
#endif
#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/lib/MacOSX/libgd/include/gdfontmb.h b/lib/MacOSX/libgd/include/gdfontmb.h
@@ -1,8 +1,3 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
#ifndef _GDFONTMB_H_
#define _GDFONTMB_H_ 1
@@ -20,18 +15,13 @@ extern "C"
No copyright info was found in the original bdf.
*/
-
#include "gd.h"
- BGD_EXPORT_DATA_PROT gdFontPtr gdFontMediumBold;
- BGD_DECLARE(gdFontPtr) gdFontGetMediumBold(void);
+extern BGD_EXPORT_DATA_PROT gdFontPtr gdFontMediumBold;
+BGD_DECLARE(gdFontPtr) gdFontGetMediumBold(void);
#ifdef __cplusplus
}
#endif
#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/lib/MacOSX/libgd/include/gdfonts.h b/lib/MacOSX/libgd/include/gdfonts.h
@@ -1,8 +1,3 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
#ifndef _GDFONTS_H_
#define _GDFONTS_H_ 1
@@ -20,18 +15,13 @@ extern "C"
No copyright info was found in the original bdf.
*/
-
#include "gd.h"
- BGD_EXPORT_DATA_PROT gdFontPtr gdFontSmall;
- BGD_DECLARE(gdFontPtr) gdFontGetSmall(void);
+extern BGD_EXPORT_DATA_PROT gdFontPtr gdFontSmall;
+BGD_DECLARE(gdFontPtr) gdFontGetSmall(void);
#ifdef __cplusplus
}
#endif
#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/lib/MacOSX/libgd/include/gdfontt.h b/lib/MacOSX/libgd/include/gdfontt.h
@@ -1,8 +1,3 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
#ifndef _GDFONTT_H_
#define _GDFONTT_H_ 1
@@ -21,18 +16,13 @@ extern "C"
"Libor Skarvada, libor@informatics.muni.cz"
*/
-
#include "gd.h"
- BGD_EXPORT_DATA_PROT gdFontPtr gdFontTiny;
- BGD_DECLARE(gdFontPtr) gdFontGetTiny(void);
+extern BGD_EXPORT_DATA_PROT gdFontPtr gdFontTiny;
+BGD_DECLARE(gdFontPtr) gdFontGetTiny(void);
#ifdef __cplusplus
}
#endif
#endif
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/lib/MacOSX/libgd/include/gdfx.h b/lib/MacOSX/libgd/include/gdfx.h
@@ -5,15 +5,13 @@ extern "C" {
#ifndef GDFX_H
#define GDFX_H 1
-#include "gd.h"
-
-/* im MUST be square, but can have any size. Returns a new image
+/* im MUST be square, but can have any size. Returns a new image
of width and height radius * 2, in which the X axis of
the original has been remapped to theta (angle) and the Y axis
of the original has been remapped to rho (distance from center).
This is known as a "polar coordinate transform." */
- BGD_DECLARE(gdImagePtr) gdImageSquareToCircle(gdImagePtr im, int radius);
+BGD_DECLARE(gdImagePtr) gdImageSquareToCircle(gdImagePtr im, int radius);
/* Draws the text 'top' and 'bottom' on 'im', curved along the
edge of a circle of radius 'radius', with its
@@ -32,38 +30,38 @@ extern "C" {
the size of the text is determined by radius, textRadius,
and fillPortion, you should pass a point size that
'hints' appropriately -- if you know the text will be
- large, pass a large point size such as 24.0 to get the
+ large, pass a large point size such as 24.0 to get the
best results. 'fgcolor' can be any color, and may have
- an alpha component, do blending, etc.
+ an alpha component, do blending, etc.
- Returns 0 on success, or an error string. */
+ Returns 0 on success, or an error string. */
BGD_DECLARE(char *) gdImageStringFTCircle(
- gdImagePtr im,
- int cx,
- int cy,
- double radius,
- double textRadius,
- double fillPortion,
- char *font,
- double points,
- char *top,
- char *bottom,
- int fgcolor);
+ gdImagePtr im,
+ int cx,
+ int cy,
+ double radius,
+ double textRadius,
+ double fillPortion,
+ char *font,
+ double points,
+ char *top,
+ char *bottom,
+ int fgcolor);
- /* 2.0.16:
- * Sharpen function added on 2003-11-19
- * by Paul Troughton (paul<dot>troughton<at>ieee<dot>org)
- * Simple 3x3 convolution kernel
- * Makes use of seperability
- * Faster, but less flexible, than full-blown unsharp masking
- * pct is sharpening percentage, and can be greater than 100
- * Silently does nothing to non-truecolor images
- * Silently does nothing for pct<0, as not a useful blurring function
- * Leaves transparency/alpha-channel untouched
- */
+/* 2.0.16:
+ * Sharpen function added on 2003-11-19
+ * by Paul Troughton (paul<dot>troughton<at>ieee<dot>org)
+ * Simple 3x3 convolution kernel
+ * Makes use of seperability
+ * Faster, but less flexible, than full-blown unsharp masking
+ * pct is sharpening percentage, and can be greater than 100
+ * Silently does nothing to non-truecolor images
+ * Silently does nothing for pct<0, as not a useful blurring function
+ * Leaves transparency/alpha-channel untouched
+ */
- BGD_DECLARE(void) gdImageSharpen (gdImagePtr im, int pct);
+BGD_DECLARE(void) gdImageSharpen (gdImagePtr im, int pct);
#endif /* GDFX_H */
diff --git a/lib/MacOSX/libgd/include/gdpp.h b/lib/MacOSX/libgd/include/gdpp.h
@@ -0,0 +1,1497 @@
+/* *****************************************************************************
+** $Id$
+** Initial file written and documented by:
+** Kevin Shepherd <kshepherd@php.net> December 2007
+** of Scarlet Line http://www.scarletline.com/
+** with contributions from Torben Nielsen.
+*******************************************************************************/
+/** \file gdpp.h
+ \brief Object Oriented C++ wrappers around libgd functionality.
+
+ Example usage, convert png to gif:
+ #include <fstream>
+ #include <gdpp.h>
+
+ std::ifstream in("image.png", std::ios_base::in | std::ios_base::binary );
+ GD::Image im(in, GD::Png_tag());
+ if (im.good())
+ {
+ std::ofstream out("image.gif", std::ios_base::out | std::ios_base::binary );
+ im.Gif(out);
+ }
+*/
+#ifdef __cplusplus
+#ifndef _gdpp_h
+#define _gdpp_h
+
+#include "gd_io_stream.h"
+#include <string>
+
+/// namespace GD:: contains the C++ wrapper classes for libgd
+/** This namespace is primarily to avoid name clashes, and to
+ contain all of the gd classes within one namespace.
+ It is not recommended to use the "using namespace" directive with this namespace.
+ Example usage:
+ GD::Image im(64, 32, true); // Create a truecolor image 64 pixels wide by 32 pixels high
+ GD::Point pt(10, 8); // The point at x=10, y=8.
+ GD::Size sz(16, 8); // The size width=16, height=8.
+ GD::TrueColor col(0xFF, 0, 0); // The colour red; R=255, G=0, B=0.
+ im.Rectangle(pt, sz, col.Int()); // Draw a red rectangle with top left corner at pt, of size sz.
+*/
+namespace GD
+{
+/** This class GD::Point stores a point in two dimensions, somewhere
+ on the plane of an image.
+*/
+class Point
+{
+public:
+ // Constructors
+ Point(int x, int y)
+ :_x(x), _y(y) {}
+ Point(const Point & p)
+ :_x(p._x), _y(p._y) {}
+ Point()
+ :_x(0), _y(0) {}
+ Point & operator=(const Point & p) {
+ _x = p._x;
+ _y = p._y;
+ return (* this);
+ }
+ // Accessors
+ int X() const {
+ return _x;
+ }
+ int Y() const {
+ return _y;
+ }
+ // Updaters
+ void X(int x) {
+ _x = x;
+ }
+ void Y(int y) {
+ _y = y;
+ }
+ void set(int x, int y) {
+ _x = x;
+ _y = y;
+ }
+ int & lhsX() {
+ return _x;
+ }
+ int & lhsY() {
+ return _y;
+ }
+
+ gdPointPtr as_gdPointPtr() {
+ return (gdPointPtr) this;
+ }
+protected:
+ int _x, _y;
+};
+typedef Point * PointPtr;
+/** This class GD::Size stores length in two dimensions.
+ Giving the size of an area as width and height.
+*/
+class Size
+{
+public:
+ // Constructors
+ Size(int w, int h)
+ :_w(w), _h(h) {}
+ Size(const Size & p)
+ :_w(p._w), _h(p._h) {}
+ Size()
+ :_w(0), _h(0) {}
+ Size & operator=(const Size & p) {
+ _w = p._w;
+ _h = p._h;
+ return (* this);
+ }
+ // Accessors
+ int W() const {
+ return _w;
+ }
+ int H() const {
+ return _h;
+ }
+ // Updaters
+ void W(int w) {
+ _w = w;
+ }
+ void H(int h) {
+ _h = h;
+ }
+ void set(int w, int h) {
+ _w = w;
+ _h = h;
+ }
+ int & lhsW() {
+ return _w;
+ }
+ int & lhsH() {
+ return _h;
+ }
+protected:
+ int _w, _h;
+};
+typedef Size * SizePtr;
+
+/** This class GD::TrueColor stores a colour as an RGBA quadruplet.
+ It can also be read as an integer, and in other colour formats.
+*/
+class TrueColor
+{
+public:
+ union as_types {
+ int as_int;
+ struct uchars {
+ unsigned char blue, green, red, alpha;
+ } as_uchar;
+ };
+ TrueColor() {
+ internal.as_int = 0;
+ }
+ TrueColor(int c) {
+ internal.as_int = c;
+ }
+ TrueColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0) {
+ internal.as_uchar.alpha = a;
+ internal.as_uchar.red = r;
+ internal.as_uchar.green = g;
+ internal.as_uchar.blue = b;
+ }
+ // Accessors
+ int Int() const {
+ return internal.as_int;
+ }
+ unsigned char Red() const {
+ return internal.as_uchar.red;
+ }
+ unsigned char Green() const {
+ return internal.as_uchar.green;
+ }
+ unsigned char Blue() const {
+ return internal.as_uchar.blue;
+ }
+ unsigned char Alpha() const {
+ return internal.as_uchar.alpha;
+ }
+ // Updaters
+ void set(int c) {
+ internal.as_int = c;
+ }
+ void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 0) {
+ internal.as_uchar.alpha = a;
+ internal.as_uchar.red = r;
+ internal.as_uchar.green = g;
+ internal.as_uchar.blue = b;
+ }
+ void Red(unsigned char c) {
+ internal.as_uchar.red = c;
+ }
+ void Green(unsigned char c) {
+ internal.as_uchar.green = c;
+ }
+ void Blue(unsigned char c) {
+ internal.as_uchar.blue = c;
+ }
+ void Alpha(unsigned char c) {
+ internal.as_uchar.alpha = c;
+ }
+protected:
+ as_types internal;
+};
+/* The following tags are simply empty structures which are used
+ to tell the compiler which constructor we want when we know
+ the image file format.
+*/
+struct Png_tag {};
+struct Gif_tag {};
+struct WBMP_tag {};
+struct Jpeg_tag {};
+struct Gd_tag {};
+struct Gd2_tag {};
+struct Xbm_tag {};
+
+/** This class GD::Image wraps all of the 'C' libgd functionality
+ for the convenience of C++ users. An instance of this class
+ corresponds to a single image.
+*/
+class BGD_EXPORT_DATA_IMPL Image
+{
+public:
+ /** Construct a null image
+ */
+ Image()
+ :im(0)
+ {}
+ /** Construct a blank image, of the given size and colour format type.
+ \param[in] sx Width of the image
+ \param[in] sy Height of the image
+ \param[in] istruecolor Create a true colour image, defaults to false, i.e. create an indexed palette image.
+ */
+ Image(int sx, int sy, bool istruecolor = false)
+ :im(0) {
+ if (istruecolor)
+ CreateTrueColor(sx, sy);
+ else
+ Create(sx, sy);
+ }
+ /** Construct a blank image, of the given size and colour format type.
+ \param[in] s Width and height of the image
+ \param[in] istruecolor Create a true colour image, defaults to false, i.e. create an indexed palette image.
+ */
+ Image(const Size & s, bool istruecolor = false)
+ :im(0) {
+ if (istruecolor)
+ CreateTrueColor(s);
+ else
+ Create(s);
+ }
+ /** Construct an instance of the GD::Image class, given the internal gdImage poimter.
+ Note that gdImageDestroy will be called on the image pointer in the destructor.
+ \param[in] i Pointer to the internal gdImage
+ */
+ Image(gdImagePtr i)
+ :im(i) {}
+ /** Copy constructor. Construct an instance of the GD::Image class,
+ by making a copy of the GD::Image provided.
+ \param[in] i Reference to the image to be copied
+ */
+ Image(const GD::Image & i)
+ :im(0) {
+ Copy(i);
+ }
+ /** Construct an image by reading from \p in. This constructor
+ will first attempt to determine the file format.
+ \param[in] in The stream containing the image data
+ */
+ Image(std::istream & in)
+ :im(0) {
+ CreateFrom(in);
+ }
+ /** Construct an image by reading from \p in. This constructor
+ will first attempt to determine the file format.
+ \param[in] in An opened FILE * handle to a file containing the image data
+ */
+ Image(FILE * in)
+ :im(0) {
+ CreateFrom(in);
+ }
+ /** Construct an image by reading from memory block \p data. This constructor
+ will first attempt to determine the image formatting.
+ \param[in] size The byte count of the memory block
+ \param[in] data Pointer to the memory block
+ */
+ Image(int size, void * data)
+ :im(0) {
+ CreateFrom(size, data);
+ }
+#if HAVE_PNG
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
+ \param[in] in The stream containing the image data
+ */
+ Image(std::istream & in, Png_tag)
+ :im(0) {
+ CreateFromPng(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
+ \param[in] in An opened FILE * handle to a file containing the image data
+ */
+ Image(FILE * in, Png_tag)
+ :im(0) {
+ CreateFromPng(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
+ \param[in] in The io context from which to read the image data
+ */
+ Image(gdIOCtx * in, Png_tag)
+ :im(0) {
+ CreateFromPng(in);
+ }
+ /** Construct an image by reading from memory block \p data.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(sz, dat, GD::Png_tag()); // read a png file from dat
+ \param[in] size The byte count of the memory block
+ \param[in] data Pointer to the memory block
+ */
+ Image(int size, void * data, Png_tag)
+ :im(0) {
+ CreateFromPng(size, data);
+ }
+#endif
+
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input
+ \param[in] in The stream containing the image data
+ */
+ Image(std::istream & in, Gif_tag)
+ :im(0) {
+ CreateFromGif(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input
+ \param[in] in An opened FILE * handle to a file containing the image data
+ */
+ Image(FILE * in, Gif_tag)
+ :im(0) {
+ CreateFromGif(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Gif_tag()); // read a gif file from input
+ \param[in] in The io context from which to read the image data
+ */
+ Image(gdIOCtx * in, Gif_tag)
+ :im(0) {
+ CreateFromGif(in);
+ }
+ /** Construct an image by reading from memory block \p data.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(sz, dat, GD::Gif_tag()); // read a gif file from dat
+ \param[in] size The byte count of the memory block
+ \param[in] data Pointer to the memory block
+ */
+ Image(int size, void * data, Gif_tag)
+ :im(0) {
+ CreateFromGif(size, data);
+ }
+
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input
+ \param[in] in The stream containing the image data
+ */
+ Image(std::istream & in, WBMP_tag)
+ :im(0) {
+ CreateFromWBMP(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input
+ \param[in] in An opened FILE * handle to a file containing the image data
+ */
+ Image(FILE * in, WBMP_tag)
+ :im(0) {
+ CreateFromWBMP(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::WBMP_tag()); // read a monchrome WBMP file from input
+ \param[in] in The io context from which to read the image data
+ */
+ Image(gdIOCtx * in, WBMP_tag)
+ :im(0) {
+ CreateFromWBMP(in);
+ }
+ /** Construct an image by reading from memory block \p data.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(sz, dat, GD::WBMP_tag()); // read a monchrome WBMP file from dat
+ \param[in] size The byte count of the memory block
+ \param[in] data Pointer to the memory block
+ */
+ Image(int size, void * data, WBMP_tag)
+ :im(0) {
+ CreateFromWBMP(size, data);
+ }
+
+#if HAVE_JPEG
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
+ \param[in] in The stream containing the image data
+ */
+ Image(std::istream & in, Jpeg_tag)
+ :im(0) {
+ CreateFromJpeg(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
+ \param[in] in An opened FILE * handle to a file containing the image data
+ */
+ Image(FILE * in, Jpeg_tag)
+ :im(0) {
+ CreateFromJpeg(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Jpeg_tag()); // read a jpeg file from input
+ \param[in] in The io context from which to read the image data
+ */
+ Image(gdIOCtx * in, Jpeg_tag)
+ :im(0) {
+ CreateFromJpeg(in);
+ }
+ /** Construct an image by reading from memory block \p data.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(sz, dat, GD::Jpeg_tag()); // read a jpeg file from dat
+ \param[in] size The byte count of the memory block
+ \param[in] data Pointer to the memory block
+ */
+ Image(int size, void * data, Jpeg_tag)
+ :im(0) {
+ CreateFromJpeg(size, data);
+ }
+#endif
+
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input
+ \param[in] in The stream containing the image data
+ */
+ Image(std::istream & in, Gd_tag)
+ :im(0) {
+ CreateFromGd(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input
+ \param[in] in An opened FILE * handle to a file containing the image data
+ */
+ Image(FILE * in, Gd_tag)
+ :im(0) {
+ CreateFromGd(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Gd_tag()); // read a gd file from input
+ \param[in] in The io context from which to read the image data
+ */
+ Image(gdIOCtx * in, Gd_tag)
+ :im(0) {
+ CreateFromGd(in);
+ }
+ /** Construct an image by reading from memory block \p data.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(sz, dat, GD::Gd_tag()); // read a gd file from dat
+ \param[in] size The byte count of the memory block
+ \param[in] data Pointer to the memory block
+ */
+ Image(int size, void * data, Gd_tag)
+ :im(0) {
+ CreateFromGd(size, data);
+ }
+
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Gd2_tag()); // read a gd2 file from input
+ \param[in] in The stream containing the image data
+ */
+ Image(std::istream & in, Gd2_tag)
+ :im(0) {
+ CreateFromGd2(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Png_tag()); // read a png file from input
+ \param[in] in An opened FILE * handle to a file containing the image data
+ */
+ Image(FILE * in, Gd2_tag)
+ :im(0) {
+ CreateFromGd2(in);
+ }
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Gd2_tag()); // read a gd2 file from input
+ \param[in] in The io context from which to read the image data
+ */
+ Image(gdIOCtx * in, Gd2_tag)
+ :im(0) {
+ CreateFromGd2(in);
+ }
+ /** Construct an image by reading from memory block \p data.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(sz, dat, GD::Gd2_tag()); // read a gd2 file from dat
+ \param[in] size The byte count of the memory block
+ \param[in] data Pointer to the memory block
+ */
+ Image(int size, void * data, Gd2_tag)
+ :im(0) {
+ CreateFromGd2(size, data);
+ }
+
+ /** Construct an image by reading from \p in.
+ The tag is an empty struct which simply tells the compiler which image read function to use.
+ e.g. GD::Image img(input, GD::Xbm_tag()); // read an xbm file from input
+ \param[in] in An opened FILE * handle to a file containing the image data
+ */
+ Image(FILE * in, Xbm_tag)
+ :im(0) {
+ CreateFromXbm(in);
+ }
+
+ ~Image() {
+ clear();
+ }
+
+ /** Assignment Operator. Make this a copy of the GD::Image provided.
+ \param[in] src Reference to the image to be copied
+ */
+ GD::Image & operator=(const GD::Image & src) {
+ Copy(src);
+ return (* this);
+ }
+ /** Make this an exact copy of the GD::Image provided. Any existing iamge data is discarded.
+ \param[in] src Reference to the image to be copied
+ */
+ void Copy(const GD::Image & src) {
+ int w = src.Width(), h = src.Height();
+ if (src.IsTrueColor())
+ CreateTrueColor(w, h);
+ else {
+ Create(w, h);
+ PaletteCopy(src);
+ }
+ Copy(src, 0, 0, 0, 0, w, h);
+ }
+ /** Check to see if this appears to be a valid image
+ */
+ bool good() const {
+ return (im != 0);
+ }
+ // Creation:
+ /**
+ Create a palette-based image, with no more than 256 colors.
+ \param sx Width of the desired image
+ \param sy Height of the desired image
+ \return true if it worked, else false
+ */
+ bool Create(int sx, int sy) {
+ clear();
+ return ((im = gdImageCreate(sx, sy)) != 0);
+ }
+ /**
+ Create a truecolor image.
+ \param sx Width of the desired image
+ \param sy Height of the desired image
+ \return true if it worked, else false
+ */
+ bool CreateTrueColor(int sx, int sy) {
+ clear();
+ return ((im = gdImageCreateTrueColor(sx, sy)) != 0);
+ }
+ /**
+ Create a palette-based image, with no more than 256 colors.
+ \param s Width and height of the desired image
+ \return true if it worked, else false
+ */
+ bool Create(const Size & s) {
+ return Create(s.W(), s.H());
+ }
+ /**
+ Create a truecolor image.
+ \param s Width and height of the desired image
+ \return true if it worked, else false
+ */
+ bool CreateTrueColor(const Size & s) {
+ return CreateTrueColor(s.W(), s.H());
+ }
+ // Create, determining the image format from the data
+ /// Read an image from an open FILE * handle, after determining the image format
+ bool CreateFrom(FILE * in);
+ /// Read an image from an open standard library input stream, after determining the image format
+ bool CreateFrom(std::istream & in);
+ /// Read an image from a memory block, after determining the image format
+ bool CreateFrom(int size, void * data);
+
+#if HAVE_PNG
+ // Png
+ bool CreateFromPng(FILE * in) {
+ clear();
+ return ((im = gdImageCreateFromPng(in)) != 0);
+ }
+ bool CreateFromPng(gdIOCtx * in) {
+ clear();
+ return ((im = gdImageCreateFromPngCtx(in)) != 0);
+ }
+ bool CreateFromPng(int size, void * data) {
+ clear();
+ return ((im = gdImageCreateFromPngPtr(size, data)) != 0);
+ }
+ bool CreateFromPng(std::istream & in) {
+ clear();
+ istreamIOCtx _in_ctx(in);
+ return ((im = gdImageCreateFromPngCtx( & _in_ctx)) != 0);
+ }
+#endif
+
+ // Gif
+ bool CreateFromGif(FILE * in) {
+ clear();
+ return ((im = gdImageCreateFromGif(in)) != 0);
+ }
+ bool CreateFromGif(gdIOCtx * in) {
+ clear();
+ return ((im = gdImageCreateFromGifCtx(in)) != 0);
+ }
+ bool CreateFromGif(int size, void * data) {
+ clear();
+ return ((im = gdImageCreateFromGifPtr(size, data)) != 0);
+ }
+ bool CreateFromGif(std::istream & in) {
+ clear();
+ istreamIOCtx _in_ctx(in);
+ return ((im = gdImageCreateFromGifCtx( & _in_ctx)) != 0);
+ }
+ // WBMP
+ bool CreateFromWBMP(FILE * in) {
+ clear();
+ return ((im = gdImageCreateFromWBMP(in)) != 0);
+ }
+ bool CreateFromWBMP(gdIOCtx * in) {
+ clear();
+ return ((im = gdImageCreateFromWBMPCtx(in)) != 0);
+ }
+ bool CreateFromWBMP(int size, void * data) {
+ clear();
+ return ((im = gdImageCreateFromWBMPPtr(size, data)) != 0);
+ }
+ bool CreateFromWBMP(std::istream & in) {
+ clear();
+ istreamIOCtx _in_ctx(in);
+ return ((im = gdImageCreateFromWBMPCtx( & _in_ctx)) != 0);
+ }
+
+#if HAVE_JPEG
+ // Jpeg
+ /**
+ Load a truecolor image from a JPEG format file.
+ Invoke CreateFromJpeg with an already opened
+ pointer to a file containing the desired image.
+ CreateFromJpeg does not close the file.
+ \return true for success, or false if unable to load the image (most often because
+ the file is corrupt or does not contain a JPEG image).
+ You can call Width() and Height() member functions of the image to determine its
+ size. The returned image is always a truecolor image.
+ */
+ bool CreateFromJpeg(FILE * in) {
+ clear();
+ return ((im = gdImageCreateFromJpeg(in)) != 0);
+ }
+ /**
+ Load a truecolor image from a JPEG format file.
+ Invoke CreateFromJpeg with an already opened
+ pointer to a file containing the desired image.
+ CreateFromJpeg does not close the file.
+ \return true for success, or false if unable to load the image (most often because the file is corrupt or does not contain a JPEG image).
+ You can call Width() and Height() member functions of the image to determine its
+ size. The returned image is always a truecolor image.
+ */
+ bool CreateFromJpeg(gdIOCtx * in) {
+ clear();
+ return ((im = gdImageCreateFromJpegCtx(in)) != 0);
+ }
+ /**
+ Load a truecolor image from a JPEG format file.
+ Invoke CreateFromJpeg with an already opened
+ pointer to a file containing the desired image.
+ CreateFromJpeg does not close the file.
+ \return true for success, or false if unable to load the image (most often because the file is corrupt or does not contain a JPEG image).
+ You can call Width() and Height() member functions of the image to determine its
+ size. The returned image is always a truecolor image.
+ */
+ bool CreateFromJpeg(int size, void * data) {
+ clear();
+ return ((im = gdImageCreateFromJpegPtr(size, data)) != 0);
+ }
+ /**
+ Load a truecolor image from a JPEG format file.
+ Invoke CreateFromJpeg with an image file in memory.
+ \return true for success, or false if unable to load the image (most often because the format is corrupt or does not contain a JPEG image).
+ You can call Width() and Height() member functions of the image to determine its
+ size. The returned image is always a truecolor image.
+ */
+ bool CreateFromJpeg(std::istream & in) {
+ clear();
+ istreamIOCtx _in_ctx(in);
+ return ((im = gdImageCreateFromJpegCtx( & _in_ctx)) != 0);
+ }
+#endif
+
+ // Gd
+ bool CreateFromGd(FILE * in) {
+ clear();
+ return ((im = gdImageCreateFromGd(in)) != 0);
+ }
+ bool CreateFromGd(gdIOCtx * in) {
+ clear();
+ return ((im = gdImageCreateFromGdCtx(in)) != 0);
+ }
+ bool CreateFromGd(int size, void * data) {
+ clear();
+ return ((im = gdImageCreateFromGdPtr(size, data)) != 0);
+ }
+ bool CreateFromGd(std::istream & in) {
+ clear();
+ istreamIOCtx _in_ctx(in);
+ return ((im = gdImageCreateFromGdCtx( & _in_ctx)) != 0);
+ }
+ // Gd2
+ bool CreateFromGd2(FILE * in) {
+ clear();
+ return ((im = gdImageCreateFromGd2(in)) != 0);
+ }
+ bool CreateFromGd2(gdIOCtx * in) {
+ clear();
+ return ((im = gdImageCreateFromGd2Ctx(in)) != 0);
+ }
+ bool CreateFromGd2(int size, void * data) {
+ clear();
+ return ((im = gdImageCreateFromGd2Ptr(size, data)) != 0);
+ }
+ bool CreateFromGd2(std::istream & in) {
+ clear();
+ istreamIOCtx _in_ctx(in);
+ return ((im = gdImageCreateFromGd2Ctx( & _in_ctx)) != 0);
+ }
+ // Gd2 Part
+ bool CreateFromGd2Part(FILE * in, int srcx, int srcy, int w, int h) {
+ clear();
+ return ((im = gdImageCreateFromGd2Part(in, srcx, srcy, w, h)) != 0);
+ }
+ bool CreateFromGd2Part(gdIOCtx * in, int srcx, int srcy, int w, int h) {
+ clear();
+ return ((im = gdImageCreateFromGd2PartCtx(in, srcx, srcy, w, h)) != 0);
+ }
+ bool CreateFromGd2Part(int size, void * data, int srcx, int srcy, int w, int h) {
+ clear();
+ return ((im = gdImageCreateFromGd2PartPtr(size, data, srcx, srcy, w, h)) != 0);
+ }
+ bool CreateFromGd2Part(std::istream & in, int srcx, int srcy, int w, int h) {
+ clear();
+ istreamIOCtx _in_ctx(in);
+ return ((im = gdImageCreateFromGd2PartCtx( & _in_ctx, srcx, srcy, w, h)) != 0);
+ }
+ bool CreateFromGd2Part(FILE * in, const Point & src, const Size & s) {
+ return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H());
+ }
+ bool CreateFromGd2Part(gdIOCtx * in, const Point & src, const Size & s) {
+ return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H());
+ }
+ bool CreateFromGd2Part(int size, void * data, const Point & src, const Size & s) {
+ return CreateFromGd2Part(size, data, src.X(), src.Y(), s.W(), s.H());
+ }
+ bool CreateFromGd2Part(std::istream & in, const Point & src, const Size & s) {
+ return CreateFromGd2Part(in, src.X(), src.Y(), s.W(), s.H());
+ }
+ // Xbm
+ bool CreateFromXbm(FILE * in) {
+ clear();
+ return ((im = gdImageCreateFromXbm(in)) != 0);
+ }
+ // Xpm
+ bool CreateFromXpm(char * filename) {
+ clear();
+ return ((im = gdImageCreateFromXpm(filename)) != 0);
+ }
+ bool CreateFromXpm(std::string & filename) {
+ return CreateFromXpm((char *)(filename.c_str()));
+ }
+
+ // Accessors, Updaters & Methods:
+ void SetPixel(int x, int y, int color) {
+ gdImageSetPixel(im, x, y, color);
+ }
+ void SetPixel(const Point & p, int color) {
+ SetPixel(p.X(), p.Y(), color);
+ }
+ int GetPixel(int x, int y) const {
+ return gdImageGetPixel(im, x, y);
+ }
+ int GetPixel(const Point & p) const {
+ return GetPixel(p.X(), p.Y());
+ }
+ int GetTrueColorPixel(int x, int y) const {
+ return gdImageGetTrueColorPixel(im, x, y);
+ }
+ int GetTrueColorPixel(const Point & p) const {
+ return GetTrueColorPixel(p.X(), p.Y());
+ }
+
+ void SetPixel(int x, int y, TrueColor c) {
+ SetPixel(x, y, c.Int());
+ }
+ void SetPixel(const Point & p, TrueColor c) {
+ SetPixel(p.X(), p.Y(), c.Int());
+ }
+ void GetTrueColorPixel(TrueColor & c, int x, int y) const {
+ c.set(GetTrueColorPixel(x, y));
+ }
+ void GetTrueColorPixel(TrueColor & c, const Point & p) const {
+ c.set(GetTrueColorPixel(p.X(), p.Y()));
+ }
+
+ void AABlend() {
+ gdImageAABlend(im);
+ }
+
+ void Line(int x1, int y1, int x2, int y2, int color) {
+ gdImageLine(im, x1, y1, x2, y2, color);
+ }
+ void Line(const Point & p1, const Point & p2, int color) {
+ Line(p1.X(), p1.Y(), p2.X(), p2.Y(), color);
+ }
+ void Rectangle(int x1, int y1, int x2, int y2, int color) {
+ gdImageRectangle(im, x1, y1, x2, y2, color);
+ }
+ void Rectangle(const Point & p1, const Point & p2, int color) {
+ Rectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color);
+ }
+ void Rectangle(const Point & p, const Size & s, int color) {
+ Rectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color);
+ }
+ void FilledRectangle(int x1, int y1, int x2, int y2, int color) {
+ gdImageFilledRectangle(im, x1, y1, x2, y2, color);
+ }
+ void FilledRectangle(const Point & p1, const Point & p2, int color) {
+ FilledRectangle(p1.X(), p1.Y(), p2.X(), p2.Y(), color);
+ }
+ void FilledRectangle(const Point & p, const Size & s, int color) {
+ FilledRectangle(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H(), color);
+ }
+
+ void SetClip(int x1, int y1, int x2, int y2) {
+ gdImageSetClip(im, x1, y1, x2, y2);
+ }
+ void SetClip(const Point & p1, const Point & p2) {
+ SetClip(p1.X(), p1.Y(), p2.X(), p2.Y());
+ }
+ void SetClip(const Point & p, const Size & s) {
+ SetClip(p.X(), p.Y(), p.X() + s.W(), p.Y() + s.H());
+ }
+ void GetClip(int & x1, int & y1, int & x2, int & y2) const {
+ gdImageGetClip(im, & x1, & y1, & x2, & y2);
+ }
+ void GetClip(Point & p1, Point & p2) const {
+ GetClip(p1.lhsX(), p1.lhsY(), p2.lhsX(), p2.lhsY());
+ }
+ void GetClip(Point & p, Size & s) const {
+ Point p2;
+ GetClip(p.lhsX(), p.lhsY(), p2.lhsX(), p2.lhsY());
+ s.set(p2.X() - p.X(), p2.Y() - p.Y());
+ }
+
+ bool BoundsSafe(int x, int y) const {
+ return (gdImageBoundsSafe(im, x, y)?true:false);
+ }
+ bool BoundsSafe(const Point & p) const {
+ return BoundsSafe(p.X(), p.Y());
+ }
+
+ void Char(gdFontPtr f, int x, int y, int c, int color) {
+ gdImageChar(im, f, x, y, c, color);
+ }
+ void CharUp(gdFontPtr f, int x, int y, int c, int color) {
+ gdImageCharUp(im, f, x, y, c, color);
+ }
+
+ void Char(gdFontPtr f, const Point & p, int c, int color) {
+ Char(f, p.X(), p.Y(), c, color);
+ }
+ void CharUp(gdFontPtr f, const Point & p, int c, int color) {
+ CharUp(f, p.X(), p.Y(), c, color);
+ }
+
+ void String(gdFontPtr f, int x, int y, unsigned char * s, int color) {
+ gdImageString(im, f, x, y, (unsigned char *)s, color);
+ }
+ void StringUp(gdFontPtr f, int x, int y, unsigned char * s, int color) {
+ gdImageStringUp(im, f, x, y, (unsigned char *)s, color);
+ }
+ void String(gdFontPtr f, int x, int y, unsigned short * s, int color) {
+ gdImageString16(im, f, x, y, (unsigned short *)s, color);
+ }
+ void StringUp(gdFontPtr f, int x, int y, unsigned short * s, int color) {
+ gdImageStringUp16(im, f, x, y, (unsigned short *)s, color);
+ }
+ void String(gdFontPtr f, int x, int y, char * s, int color) {
+ gdImageString(im, f, x, y, (unsigned char *)s, color);
+ }
+ void StringUp(gdFontPtr f, int x, int y, char * s, int color) {
+ gdImageStringUp(im, f, x, y, (unsigned char *)s, color);
+ }
+ void String(gdFontPtr f, int x, int y, const std::string & s, int color) {
+ String(f, x, y, (char *)s.c_str(), color);
+ }
+ void StringUp(gdFontPtr f, int x, int y, const std::string & s, int color) {
+ StringUp(f, x, y, (char *)s.c_str(), color);
+ }
+
+ void String(gdFontPtr f, const Point & p, unsigned char * s, int color) {
+ String(f, p.X(), p.Y(), (unsigned char *)s, color);
+ }
+ void StringUp(gdFontPtr f, const Point & p, unsigned char * s, int color) {
+ StringUp(f, p.X(), p.Y(), (unsigned char *)s, color);
+ }
+ void String(gdFontPtr f, const Point & p, unsigned short * s, int color) {
+ String(f, p.X(), p.Y(), (unsigned short *)s, color);
+ }
+ void StringUp(gdFontPtr f, const Point & p, unsigned short * s, int color) {
+ StringUp(f, p.X(), p.Y(), (unsigned short *)s, color);
+ }
+ void String(gdFontPtr f, const Point & p, char * s, int color) {
+ String(f, p.X(), p.Y(), (unsigned char *)s, color);
+ }
+ void StringUp(gdFontPtr f, const Point & p, char * s, int color) {
+ StringUp(f, p.X(), p.Y(), (unsigned char *)s, color);
+ }
+ void String(gdFontPtr f, const Point & p, const std::string & s, int color) {
+ String(f, p, (char *)s.c_str(), color);
+ }
+ void StringUp(gdFontPtr f, const Point & p, const std::string & s, int color) {
+ StringUp(f, p, (char *)s.c_str(), color);
+ }
+
+ char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
+ int x, int y, char * string) {
+ return gdImageStringFT(im, brect, fg, fontlist, ptsize, angle, x, y, string);
+ }
+ char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
+ int x, int y, char * string, gdFTStringExtraPtr strex) {
+ return gdImageStringFTEx(im, brect, fg, fontlist, ptsize, angle, x, y, string, strex);
+ }
+ char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
+ int x, int y, const std::string & string) {
+ return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str());
+ }
+ char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
+ int x, int y, const std::string & string, gdFTStringExtraPtr strex) {
+ return StringFT(brect, fg, fontlist, ptsize, angle, x, y, (char *)string.c_str(), strex);
+ }
+
+ char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
+ const Point & p, char * string) {
+ return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string);
+ }
+ char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
+ const Point & p, char * string, gdFTStringExtraPtr strex) {
+ return StringFT(brect, fg, fontlist, ptsize, angle, p.X(), p.Y(), string, strex);
+ }
+ char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
+ const Point & p, const std::string & string) {
+ return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str());
+ }
+ char * StringFT(int * brect, int fg, char * fontlist, double ptsize, double angle,
+ const Point & p, const std::string & string, gdFTStringExtraPtr strex) {
+ return StringFT(brect, fg, fontlist, ptsize, angle, p, (char *)string.c_str(), strex);
+ }
+
+ void Polygon(gdPointPtr p, int n, int c) {
+ gdImagePolygon(im, p, n, c);
+ }
+ void OpenPolygon(gdPointPtr p, int n, int c) {
+ gdImageOpenPolygon(im, p, n, c);
+ }
+ void FilledPolygon(gdPointPtr p, int n, int c) {
+ gdImageFilledPolygon(im, p, n, c);
+ }
+
+ void Polygon(PointPtr p, int n, int c) {
+ Polygon(p->as_gdPointPtr(), n, c);
+ }
+ void OpenPolygon(PointPtr p, int n, int c) {
+ OpenPolygon(p->as_gdPointPtr(), n, c);
+ }
+ void FilledPolygon(PointPtr p, int n, int c) {
+ FilledPolygon(p->as_gdPointPtr(), n, c);
+ }
+
+ int ColorAllocate(int r, int g, int b) {
+ return gdImageColorAllocate(im, r, g, b);
+ }
+ int ColorAllocate(int r, int g, int b, int a) {
+ return gdImageColorAllocateAlpha(im, r, g, b, a);
+ }
+
+ int ColorClosest(int r, int g, int b) const {
+ return gdImageColorClosest(im, r, g, b);
+ }
+ int ColorClosest(int r, int g, int b, int a) const {
+ return gdImageColorClosestAlpha(im, r, g, b, a);
+ }
+ int ColorClosestHWB(int r, int g, int b) const {
+ return gdImageColorClosestHWB(im, r, g, b);
+ }
+ int ColorExact(int r, int g, int b) const {
+ return gdImageColorExact(im, r, g, b);
+ }
+ int ColorExact(int r, int g, int b, int a) const {
+ return gdImageColorExactAlpha(im, r, g, b, a);
+ }
+ int ColorResolve(int r, int g, int b) {
+ return gdImageColorResolve(im, r, g, b);
+ }
+ int ColorResolve(int r, int g, int b, int a) {
+ return gdImageColorResolveAlpha(im, r, g, b, a);
+ }
+
+ void ColorDeallocate(int color) {
+ gdImageColorDeallocate(im, color);
+ }
+
+ void TrueColorToPalette(int ditherFlag, int colorsWanted) {
+ gdImageTrueColorToPalette(im, ditherFlag, colorsWanted);
+ }
+
+ void ColorTransparent(int color) {
+ gdImageColorTransparent(im, color);
+ }
+
+ void PaletteCopy(gdImagePtr src) {
+ gdImagePaletteCopy(im, src);
+ }
+ void PaletteCopy(const GD::Image & src) {
+ PaletteCopy(src.im);
+ }
+
+ /**
+ Write out this image in GIF file format to \p out.
+ \param out A FILE * handle
+ */
+ void Gif(FILE * out) const {
+ gdImageGif(im, out);
+ }
+ /**
+ Write out this image in GIF file format to \p out.
+ \param out A gdIOCtx * handle
+ */
+ void Gif(gdIOCtx * out) const {
+ gdImageGifCtx(im, out);
+ }
+ /**
+ Allocate sufficient memory, and write this image, in GIF file format, to that memory.
+ \param size A pointer for the allocated memory
+ \return A pointer to the allocated memory, containing the image GIF file formatted. Caller is responsible for freeing with gdFree().
+ */
+ void * Gif(int * size) const {
+ return gdImageGifPtr(im, size);
+ }
+ /**
+ Write out this image in GIF file format to \p out.
+ \param out An output stream, already opened.
+ */
+ void Gif(std::ostream & out) const {
+ ostreamIOCtx _out_ctx(out);
+ gdImageGifCtx(im, & _out_ctx);
+ }
+
+#if HAVE_PNG
+ /**
+ Write out this image in PNG file format to \p out.
+ \param out A FILE * handle
+ */
+ void Png(FILE * out) const {
+ gdImagePng(im, out);
+ }
+ /**
+ Write out this image in PNG file format to \p out.
+ \param out A gdIOCtx * handle
+ */
+ void Png(gdIOCtx * out) const {
+ gdImagePngCtx(im, out);
+ }
+ /**
+ Allocate sufficient memory, and write this image, in PNG file format, to that memory.
+ \param size A pointer for the allocated memory
+ \return A pointer to the allocated memory, containing the image PNG file formatted. Caller is responsible for freeing with gdFree().
+ */
+ void * Png(int * size) const {
+ return gdImagePngPtr(im, size);
+ }
+ /**
+ Write out this image in PNG file format to \p out.
+ \param out An output stream, already opened.
+ */
+ void Png(std::ostream & out) const {
+ ostreamIOCtx _out_ctx(out);
+ gdImagePngCtx(im, & _out_ctx);
+ }
+ /**
+ Write out this image in PNG file format to \p out.
+ \param out A FILE * handle
+ \param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level
+ */
+ void Png(FILE * out, int level) const {
+ gdImagePngEx(im, out, level);
+ }
+ /**
+ Write out this image in PNG file format to \p out.
+ \param out A gdIOCtx * handle
+ \param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level
+ */
+ void Png(gdIOCtx * out, int level) const {
+ gdImagePngCtxEx(im, out, level);
+ }
+ /**
+ Allocate sufficient memory, and write this image, in PNG file format, to that memory.
+ \param size A pointer for the allocated memory
+ \param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level
+ \return A pointer to the allocated memory, containing the image PNG file formatted. Caller is responsible for freeing with gdFree().
+ */
+ void * Png(int * size, int level) const {
+ return gdImagePngPtrEx(im, size, level);
+ }
+ /**
+ Write out this image in PNG file format to \p out.
+ \param out An output stream, already opened.
+ \param level The level of compression: 0 == "no compression", 1 == "compressed as quickly as possible" --> 9 == "compressed as much as possible", -1 == zlib default compression level
+ */
+ void Png(std::ostream & out, int level) const {
+ ostreamIOCtx _out_ctx(out);
+ gdImagePngCtxEx(im, & _out_ctx, level);
+ }
+#endif
+
+ /**
+ Write out this image in WBMP file format ( black and white only ) to \p out.
+ \param fg The color index of the foreground. All other pixels considered background.
+ \param out A FILE * handle
+ */
+ void WBMP(int fg, FILE * out) const {
+ gdImageWBMP(im, fg, out);
+ }
+ /**
+ Write out this image in WBMP file format ( black and white only ) to \p out.
+ \param fg The color index of the foreground. All other pixels considered background.
+ \param out A gdIOCtx * handle
+ */
+ void WBMP(int fg, gdIOCtx * out) const {
+ gdImageWBMPCtx(im, fg, out);
+ }
+ /**
+ Allocate sufficient memory, and write this image, in WBMP file format ( black and white only ), to that memory.
+ \param size A pointer for the allocated memory
+ \param fg The color index of the foreground. All other pixels considered background.
+ \return A pointer to the allocated memory, containing the image WBMP file formatted. Caller is responsible for freeing with gdFree().
+ */
+ void * WBMP(int * size, int fg) const {
+ return gdImageWBMPPtr(im, size, fg);
+ }
+ /**
+ Write out this image in WBMP file format ( black and white only ) to \p out.
+ \param fg The color index of the foreground. All other pixels considered background.
+ \param out An output stream, already opened.
+ */
+ void WBMP(int fg, std::ostream & out) const {
+ ostreamIOCtx _out_ctx(out);
+ gdImageWBMPCtx(im, fg, & _out_ctx);
+ }
+
+#if HAVE_JPEG
+ /**
+ Write out this image in JPEG file format to \p out.
+ \param out A FILE * handle
+ \param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value".
+ */
+ void Jpeg(FILE * out, int quality = -1) const {
+ gdImageJpeg(im, out, quality);
+ }
+ /**
+ Write out this image in JPEG file format to \p out.
+ \param out A gdIOCtx * handle
+ \param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value".
+ */
+ void Jpeg(gdIOCtx * out, int quality = -1) const {
+ gdImageJpegCtx(im, out, quality);
+ }
+ /**
+ Allocate sufficient memory, and write this image, in JPEG file format, to that memory.
+ \param size A pointer for the allocated memory
+ \param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value".
+ \return A pointer to the allocated memory, containing the image JPEG file formatted. Caller is responsible for freeing with gdFree().
+ */
+ void * Jpeg(int * size, int quality = -1) const {
+ return gdImageJpegPtr(im, size, quality);
+ }
+ /**
+ Write out this image in JPEG file format to \p out.
+ \param out An output stream, already opened.
+ \param quality Should be a value in the range 0-95, higher numbers imply both higher quality and larger image size. Default value is -1, indicating "use a sensible default value".
+ */
+ void Jpeg(std::ostream & out, int quality = -1) const {
+ ostreamIOCtx _out_ctx(out);
+ gdImageJpegCtx(im, & _out_ctx, quality);
+ }
+#endif
+
+ void GifAnimBegin(FILE * out, int GlobalCM, int Loops) const {
+ gdImageGifAnimBegin(im, out, GlobalCM, Loops);
+ }
+ void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const {
+ gdImageGifAnimAdd(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
+ }
+ void GifAnimAdd(FILE * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const {
+ GifAnimAdd(out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im);
+ }
+ inline static void GifAnimEnd(FILE * out) {
+ gdImageGifAnimEnd(out);
+ }
+ void GifAnimBegin(gdIOCtx * out, int GlobalCM, int Loops) const {
+ gdImageGifAnimBeginCtx(im, out, GlobalCM, Loops);
+ }
+ void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const {
+ gdImageGifAnimAddCtx(im, out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
+ }
+ void GifAnimAdd(gdIOCtx * out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const {
+ GifAnimAdd(out, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im);
+ }
+ inline static void GifAnimEnd(gdIOCtx * out) {
+ gdImageGifAnimEndCtx(out);
+ }
+ void * GifAnimBegin(int * size, int GlobalCM, int Loops) const {
+ return gdImageGifAnimBeginPtr(im, size, GlobalCM, Loops);
+ }
+ void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm) const {
+ return gdImageGifAnimAddPtr(im, size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm);
+ }
+ void * GifAnimAdd(int * size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, const GD::Image & previm) const {
+ return GifAnimAdd(size, LocalCM, LeftOfs, TopOfs, Delay, Disposal, previm.im);
+ }
+ inline static void * GifAnimEnd(int * size) {
+ return gdImageGifAnimEndPtr(size);
+ }
+
+ void Gd(FILE * out) const {
+ gdImageGd(im, out);
+ }
+ void Gd(int * size) const {
+ gdImageGdPtr(im, size);
+ }
+ void Gd2(FILE * out, int cs, int fmt) const {
+ gdImageGd2(im, out, cs, fmt);
+ }
+ void Gd2(int cs, int fmt, int * size) const {
+ gdImageGd2Ptr(im, cs, fmt, size);
+ }
+
+ void Ellipse(int cx, int cy, int w, int h, int color) {
+ gdImageEllipse(im, cx, cy, w, h, color);
+ }
+ /**
+ Draw a partial ellipse centered at the given point, with the specified width and height in pixels.
+ */
+ void FilledArc(int cx, int cy, int w, int h, int s, int e, int color, int style) {
+ gdImageFilledArc(im, cx, cy, w, h, s, e, color, style);
+ }
+ void Arc(int cx, int cy, int w, int h, int s, int e, int color) {
+ gdImageArc(im, cx, cy, w, h, s, e, color);
+ }
+ void FilledEllipse(int cx, int cy, int w, int h, int color) {
+ gdImageFilledEllipse(im, cx, cy, w, h, color);
+ }
+ void FillToBorder(int x, int y, int border, int color) {
+ gdImageFillToBorder(im, x, y, border, color);
+ }
+ void Fill(int x, int y, int color) {
+ gdImageFill(im, x, y, color);
+ }
+
+ void Ellipse(const Point & c, const Size & s, int color) {
+ Ellipse(c.X(), c.Y(), s.W(), s.H(), color);
+ }
+ void FilledArc(const Point & c, const Size & si, int s, int e, int color, int style) {
+ FilledArc(c.X(), c.Y(), si.W(), si.H(), s, e, color, style);
+ }
+ void Arc(const Point & c, const Size & si, int s, int e, int color) {
+ Arc(c.X(), c.Y(), si.W(), si.H(), s, e, color);
+ }
+ void FilledEllipse(const Point & c, const Size & s, int color) {
+ FilledEllipse(c.X(), c.Y(), s.W(), s.H(), color);
+ }
+ void FillToBorder(const Point & p, int border, int color) {
+ FillToBorder(p.X(), p.Y(), border, color);
+ }
+ void Fill(const Point & p, int color) {
+ Fill(p.X(), p.Y(), color);
+ }
+
+ void Copy(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h) {
+ gdImageCopy(im, src, dstX, dstY, srcX, srcY, w, h);
+ }
+ void CopyMerge(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) {
+ gdImageCopyMerge(im, src, dstX, dstY, srcX, srcY, w, h, pct);
+ }
+ void CopyMergeGray(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) {
+ gdImageCopyMergeGray(im, src, dstX, dstY, srcX, srcY, w, h, pct);
+ }
+
+ void CopyResized(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) {
+ gdImageCopyResized(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
+ }
+ void CopyResampled(const gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) {
+ gdImageCopyResampled(im, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
+ }
+ void CopyRotated(const gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) {
+ gdImageCopyRotated(im, src, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle);
+ }
+
+ void Copy(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s) {
+ Copy(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H());
+ }
+ void CopyMerge(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct) {
+ CopyMerge(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct);
+ }
+ void CopyMergeGray(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & s, int pct) {
+ CopyMergeGray(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct);
+ }
+
+ void CopyResized(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) {
+ CopyResized(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H());
+ }
+ void CopyResampled(const gdImagePtr src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) {
+ CopyResampled(src, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H());
+ }
+ void CopyRotated(const gdImagePtr src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) {
+ CopyRotated(src, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle);
+ }
+
+ void Copy(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h) {
+ Copy(src.im, dstX, dstY, srcX, srcY, w, h);
+ }
+ void CopyMerge(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) {
+ CopyMerge(src.im, dstX, dstY, srcX, srcY, w, h, pct);
+ }
+ void CopyMergeGray(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct) {
+ CopyMergeGray(src.im, dstX, dstY, srcX, srcY, w, h, pct);
+ }
+
+ void CopyResized(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) {
+ CopyResized(src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
+ }
+ void CopyResampled(const GD::Image & src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH) {
+ CopyResampled(src.im, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
+ }
+ void CopyRotated(const GD::Image & src, double dstX, double dstY, int srcX, int srcY, int srcWidth, int srcHeight, int angle) {
+ CopyRotated(src.im, dstX, dstY, srcX, srcY, srcWidth, srcHeight, angle);
+ }
+
+ void Copy(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s) {
+ Copy(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H());
+ }
+ void CopyMerge(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s, int pct) {
+ CopyMerge(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct);
+ }
+ void CopyMergeGray(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & s, int pct) {
+ CopyMergeGray(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), s.W(), s.H(), pct);
+ }
+
+ void CopyResized(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) {
+ CopyResized(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H());
+ }
+ void CopyResampled(const GD::Image & src, const Point & dstP, const Point & srcP, const Size & dstS, const Size & srcS) {
+ CopyResampled(src.im, dstP.X(), dstP.Y(), srcP.X(), srcP.Y(), dstS.W(), dstS.H(), srcS.W(), srcS.H());
+ }
+ void CopyRotated(const GD::Image & src, double dstX, double dstY, const Point & srcP, const Size & srcS, int angle) {
+ CopyRotated(src.im, dstX, dstY, srcP.X(), srcP.Y(), srcS.W(), srcS.H(), angle);
+ }
+
+ void SetBrush(gdImagePtr brush) {
+ gdImageSetBrush(im, brush);
+ }
+ void SetBrush(const GD::Image & brush) {
+ SetBrush(brush.im);
+ }
+ void SetTile(gdImagePtr tile) {
+ gdImageSetTile(im, tile);
+ }
+ void SetTile(const GD::Image & tile) {
+ SetTile(tile.im);
+ }
+ void SetAntiAliased(int c) {
+ gdImageSetAntiAliased(im, c);
+ }
+ void SetAntiAliasedDontBlend(int c, int dont_blend) {
+ gdImageSetAntiAliasedDontBlend(im, c, dont_blend);
+ }
+ void SetStyle(int * style, int noOfPixels) {
+ gdImageSetStyle(im, style, noOfPixels);
+ }
+ void SetThickness(int thickness) {
+ gdImageSetThickness(im, thickness);
+ }
+
+ void Interlace(bool interlaceArg) {
+ gdImageInterlace(im, interlaceArg?1:0);
+ }
+ void AlphaBlending(bool alphaBlendingArg) {
+ gdImageAlphaBlending(im, alphaBlendingArg?1:0);
+ }
+ void SaveAlpha(bool saveAlphaArg) {
+ gdImageSaveAlpha(im, saveAlphaArg?1:0);
+ }
+
+ bool IsTrueColor() const {
+ return (gdImageTrueColor(im)?true:false);
+ }
+ int SX() const {
+ return gdImageSX(im);
+ }
+ int SY() const {
+ return gdImageSY(im);
+ }
+ int Width() const {
+ return SX();
+ }
+ int Height() const {
+ return SY();
+ }
+ void GetSize(Size & s) const {
+ s.set(SX(), SY());
+ }
+ int ColorsTotal() const {
+ return gdImageColorsTotal(im);
+ }
+ int Red(int color) const {
+ return gdImageRed(im, color);
+ }
+ int Green(int color) const {
+ return gdImageGreen(im, color);
+ }
+ int Blue(int color) const {
+ return gdImageBlue(im, color);
+ }
+ int Alpha(int color) const {
+ return gdImageAlpha(im, color);
+ }
+ int GetTransparent() const {
+ return gdImageGetTransparent(im);
+ }
+ int GetInterlaced() const {
+ return gdImageGetInterlaced(im);
+ }
+ int PalettePixel(int x, int y) const {
+ return gdImagePalettePixel(im, x, y);
+ }
+ int TrueColorPixel(int x, int y) const {
+ return gdImageTrueColorPixel(im, x, y);
+ }
+
+ const gdImagePtr GetPtr() const {
+ return im;
+ }
+
+protected:
+ /// Free the internal image pointer
+ void clear() {
+ if (im)
+ gdImageDestroy(im);
+ im = 0;
+ }
+ gdImagePtr im;
+};
+} // namespace GD
+/// Read in an image from a standard library input stream
+std::istream & operator>> (std::istream & in, GD::Image & img);
+
+#endif /* _gdpp_h */
+#endif /* __cplusplus */
diff --git a/lib/MacOSX/libgd/libgd.2.0.0.dylib b/lib/MacOSX/libgd/libgd.2.0.0.dylib
Binary files differ.
diff --git a/lib/MacOSX/libgd/libgd.3.dylib b/lib/MacOSX/libgd/libgd.3.dylib
Binary files differ.