"Fossies" - the Fresh Open Source Software Archive

Member "libgd-2.3.2/src/gd.h" (6 Mar 2021, 59643 Bytes) of package /linux/www/libgd-2.3.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gd.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.3.1_vs_2.3.2.

    1 #ifndef GD_H
    2 #define GD_H 1
    3 
    4 #include <stdlib.h>
    5 
    6 #ifdef __cplusplus
    7 extern "C" {
    8 #endif
    9 
   10 /* Version information.  This gets parsed by build scripts as well as
   11  * gcc so each #define line in this group must also be splittable on
   12  * whitespace, take the form GD_*_VERSION and contain the magical
   13  * trailing comment. */
   14 #define GD_MAJOR_VERSION    2           /*version605b5d1778*/
   15 #define GD_MINOR_VERSION    3           /*version605b5d1778*/
   16 #define GD_RELEASE_VERSION  2           /*version605b5d1778*/
   17 #define GD_EXTRA_VERSION    ""      /*version605b5d1778*/
   18 /* End parsable section. */
   19 
   20 /* The version string.  This is constructed from the version number
   21  * parts above via macro abuse^Wtrickery. */
   22 #define GDXXX_VERSION_STR(mjr, mnr, rev, ext) mjr "." mnr "." rev ext
   23 #define GDXXX_STR(s) GDXXX_SSTR(s)  /* Two levels needed to expand args. */
   24 #define GDXXX_SSTR(s) #s
   25 
   26 #define GD_VERSION_STRING                                               \
   27     GDXXX_VERSION_STR(GDXXX_STR(GD_MAJOR_VERSION),                      \
   28                       GDXXX_STR(GD_MINOR_VERSION),                      \
   29                       GDXXX_STR(GD_RELEASE_VERSION),                    \
   30                       GD_EXTRA_VERSION)
   31 
   32 
   33 /* Do the DLL dance: dllexport when building the DLL,
   34    dllimport when importing from it, nothing when
   35    not on Silly Silly Windows (tm Aardman Productions). */
   36 
   37 /* 2.0.20: for headers */
   38 
   39 /* 2.0.24: __stdcall also needed for Visual BASIC
   40    and other languages. This breaks ABI compatibility
   41    with previous DLL revs, but it's necessary. */
   42 
   43 /* 2.0.29: WIN32 programmers can declare the NONDLL macro if they
   44    wish to build gd as a static library or by directly including
   45    the gd sources in a project. */
   46 
   47 /* http://gcc.gnu.org/wiki/Visibility */
   48 #if defined(_WIN32) || defined(CYGWIN) || defined(_WIN32_WCE)
   49 # ifdef BGDWIN32
   50 #  ifdef NONDLL
   51 #   define BGD_EXPORT_DATA_PROT
   52 #  else
   53 #   ifdef __GNUC__
   54 #    define BGD_EXPORT_DATA_PROT __attribute__ ((__dllexport__))
   55 #   else
   56 #    define BGD_EXPORT_DATA_PROT __declspec(dllexport)
   57 #   endif
   58 #  endif
   59 # else
   60 #  ifdef __GNUC__
   61 #   define BGD_EXPORT_DATA_PROT __attribute__ ((__dllimport__))
   62 #  else
   63 #   define BGD_EXPORT_DATA_PROT __declspec(dllimport)
   64 #  endif
   65 # endif
   66 # define BGD_STDCALL __stdcall
   67 # define BGD_EXPORT_DATA_IMPL
   68 #else
   69 # if defined(__GNUC__) || defined(__clang__)
   70 #  define BGD_EXPORT_DATA_PROT __attribute__ ((__visibility__ ("default")))
   71 #  define BGD_EXPORT_DATA_IMPL __attribute__ ((__visibility__ ("hidden")))
   72 # else
   73 #  define BGD_EXPORT_DATA_PROT
   74 #  define BGD_EXPORT_DATA_IMPL
   75 # endif
   76 # define BGD_STDCALL
   77 #endif
   78 
   79 #define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt BGD_STDCALL
   80 
   81 /* VS2012+ disable keyword macroizing unless _ALLOW_KEYWORD_MACROS is set
   82    We define inline, and strcasecmp if they're missing
   83 */
   84 #ifdef _MSC_VER
   85 #  define _ALLOW_KEYWORD_MACROS
   86 #  ifndef inline
   87 #    define inline __inline
   88 #  endif
   89 #  ifndef strcasecmp
   90 #    define strcasecmp _stricmp
   91 #  endif
   92 #endif
   93 
   94 /* gd.h: declarations file for the graphic-draw module.
   95  * Permission to use, copy, modify, and distribute this software and its
   96  * documentation for any purpose and without fee is hereby granted, provided
   97  * that the above copyright notice appear in all copies and that both that
   98  * copyright notice and this permission notice appear in supporting
   99  * documentation.  This software is provided "AS IS." Thomas Boutell and
  100  * Boutell.Com, Inc. disclaim all warranties, either express or implied,
  101  * including but not limited to implied warranties of merchantability and
  102  * fitness for a particular purpose, with respect to this code and accompanying
  103  * documentation. */
  104 
  105 /* stdio is needed for file I/O. */
  106 #include <stdio.h>
  107 #include <stdarg.h>
  108 #include "gd_io.h"
  109 
  110 /* The maximum number of palette entries in palette-based images.
  111    In the wonderful new world of gd 2.0, you can of course have
  112    many more colors when using truecolor mode. */
  113 
  114 #define gdMaxColors 256
  115 
  116 /* Image type. See functions below; you will not need to change
  117    the elements directly. Use the provided macros to
  118    access sx, sy, the color table, and colorsTotal for
  119    read-only purposes. */
  120 
  121 /* If 'truecolor' is set true, the image is truecolor;
  122    pixels are represented by integers, which
  123    must be 32 bits wide or more.
  124 
  125    True colors are repsented as follows:
  126 
  127    ARGB
  128 
  129    Where 'A' (alpha channel) occupies only the
  130    LOWER 7 BITS of the MSB. This very small
  131    loss of alpha channel resolution allows gd 2.x
  132    to keep backwards compatibility by allowing
  133    signed integers to be used to represent colors,
  134    and negative numbers to represent special cases,
  135    just as in gd 1.x. */
  136 
  137 #define gdAlphaMax 127
  138 #define gdAlphaOpaque 0
  139 #define gdAlphaTransparent 127
  140 #define gdRedMax 255
  141 #define gdGreenMax 255
  142 #define gdBlueMax 255
  143 
  144 /**
  145  * Group: Color Decomposition
  146  */
  147 
  148 /**
  149  * Macro: gdTrueColorGetAlpha
  150  *
  151  * Gets the alpha channel value
  152  *
  153  * Parameters:
  154  *   c - The color
  155  *
  156  * See also:
  157  *   - <gdTrueColorAlpha>
  158  */
  159 #define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24)
  160 
  161 /**
  162  * Macro: gdTrueColorGetRed
  163  *
  164  * Gets the red channel value
  165  *
  166  * Parameters:
  167  *   c - The color
  168  *
  169  * See also:
  170  *   - <gdTrueColorAlpha>
  171  */
  172 #define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16)
  173 
  174 /**
  175  * Macro: gdTrueColorGetGreen
  176  *
  177  * Gets the green channel value
  178  *
  179  * Parameters:
  180  *   c - The color
  181  *
  182  * See also:
  183  *   - <gdTrueColorAlpha>
  184  */
  185 #define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8)
  186 
  187 /**
  188  * Macro: gdTrueColorGetBlue
  189  *
  190  * Gets the blue channel value
  191  *
  192  * Parameters:
  193  *   c - The color
  194  *
  195  * See also:
  196  *   - <gdTrueColorAlpha>
  197  */
  198 #define gdTrueColorGetBlue(c) ((c) & 0x0000FF)
  199 
  200 /**
  201  * Group: Effects
  202  *
  203  * The layering effect
  204  *
  205  * When pixels are drawn the new colors are "mixed" with the background
  206  * depending on the effect.
  207  *
  208  * Note that the effect does not apply to palette images, where pixels
  209  * are always replaced.
  210  *
  211  * Modes:
  212  *   gdEffectReplace    - replace pixels
  213  *   gdEffectAlphaBlend - blend pixels, see <gdAlphaBlend>
  214  *   gdEffectNormal     - default mode; same as gdEffectAlphaBlend
  215  *   gdEffectOverlay    - overlay pixels, see <gdLayerOverlay>
  216  *   gdEffectMultiply   - overlay pixels with multiply effect, see
  217  *                        <gdLayerMultiply>
  218  *
  219  * See also:
  220  *   - <gdImageAlphaBlending>
  221  */
  222 #define gdEffectReplace 0
  223 #define gdEffectAlphaBlend 1
  224 #define gdEffectNormal 2
  225 #define gdEffectOverlay 3
  226 #define gdEffectMultiply 4
  227 
  228 #define GD_TRUE 1
  229 #define GD_FALSE 0
  230 
  231 #define GD_EPSILON 1e-6
  232 #ifndef M_PI
  233 # define M_PI 3.14159265358979323846
  234 #endif
  235 
  236 /* This function accepts truecolor pixel values only. The
  237    source color is composited with the destination color
  238    based on the alpha channel value of the source color.
  239    The resulting color is opaque. */
  240 
  241 BGD_DECLARE(int) gdAlphaBlend (int dest, int src);
  242 BGD_DECLARE(int) gdLayerOverlay (int dest, int src);
  243 BGD_DECLARE(int) gdLayerMultiply (int dest, int src);
  244 
  245 
  246 /**
  247  * Group: Color Quantization
  248  *
  249  * Enum: gdPaletteQuantizationMethod
  250  *
  251  * Constants:
  252  *   GD_QUANT_DEFAULT  - GD_QUANT_LIQ if libimagequant is available,
  253  *                       GD_QUANT_JQUANT otherwise.
  254  *   GD_QUANT_JQUANT   - libjpeg's old median cut. Fast, but only uses 16-bit
  255  *                       color.
  256  *   GD_QUANT_NEUQUANT - NeuQuant - approximation using Kohonen neural network.
  257  *   GD_QUANT_LIQ      - A combination of algorithms used in libimagequant
  258  *                       aiming for the highest quality at cost of speed.
  259  *
  260  * Note that GD_QUANT_JQUANT does not retain the alpha channel, and
  261  * GD_QUANT_NEUQUANT does not support dithering.
  262  *
  263  * See also:
  264  *   - <gdImageTrueColorToPaletteSetMethod>
  265  */
  266 enum gdPaletteQuantizationMethod {
  267     GD_QUANT_DEFAULT = 0,
  268     GD_QUANT_JQUANT = 1,
  269     GD_QUANT_NEUQUANT = 2,
  270     GD_QUANT_LIQ = 3
  271 };
  272 
  273 
  274 /**
  275  * Group: Transform
  276  *
  277  * Constants: gdInterpolationMethod
  278  *
  279  *  GD_BELL              - Bell
  280  *  GD_BESSEL            - Bessel
  281  *  GD_BILINEAR_FIXED    - fixed point bilinear
  282  *  GD_BICUBIC           - Bicubic
  283  *  GD_BICUBIC_FIXED     - fixed point bicubic integer
  284  *  GD_BLACKMAN          - Blackman
  285  *  GD_BOX               - Box
  286  *  GD_BSPLINE           - BSpline
  287  *  GD_CATMULLROM        - Catmullrom
  288  *  GD_GAUSSIAN          - Gaussian
  289  *  GD_GENERALIZED_CUBIC - Generalized cubic
  290  *  GD_HERMITE           - Hermite
  291  *  GD_HAMMING           - Hamming
  292  *  GD_HANNING           - Hannig
  293  *  GD_MITCHELL          - Mitchell
  294  *  GD_NEAREST_NEIGHBOUR - Nearest neighbour interpolation
  295  *  GD_POWER             - Power
  296  *  GD_QUADRATIC         - Quadratic
  297  *  GD_SINC              - Sinc
  298  *  GD_TRIANGLE          - Triangle
  299  *  GD_WEIGHTED4         - 4 pixels weighted bilinear interpolation
  300  *  GD_LINEAR            - bilinear interpolation
  301  *
  302  * See also:
  303  *  - <gdImageSetInterpolationMethod>
  304  *  - <gdImageGetInterpolationMethod>
  305  */
  306 typedef enum {
  307     GD_DEFAULT          = 0,
  308     GD_BELL,
  309     GD_BESSEL,
  310     GD_BILINEAR_FIXED,
  311     GD_BICUBIC,
  312     GD_BICUBIC_FIXED,
  313     GD_BLACKMAN,
  314     GD_BOX,
  315     GD_BSPLINE,
  316     GD_CATMULLROM,
  317     GD_GAUSSIAN,
  318     GD_GENERALIZED_CUBIC,
  319     GD_HERMITE,
  320     GD_HAMMING,
  321     GD_HANNING,
  322     GD_MITCHELL,
  323     GD_NEAREST_NEIGHBOUR,
  324     GD_POWER,
  325     GD_QUADRATIC,
  326     GD_SINC,
  327     GD_TRIANGLE,
  328     GD_WEIGHTED4,
  329     GD_LINEAR,
  330     GD_METHOD_COUNT = 23
  331 } gdInterpolationMethod;
  332 
  333 /**
  334  * Group: HEIF Coding Format
  335  *
  336  * Values that select the HEIF coding format.
  337  *
  338  * Constants: gdHeifCodec
  339  *
  340  *  GD_HEIF_CODEC_UNKNOWN
  341  *  GD_HEIF_CODEC_HEVC
  342  *  GD_HEIF_CODEC_AV1
  343  *
  344  * See also:
  345  *  - <gdImageHeif>
  346  */
  347 typedef enum {
  348     GD_HEIF_CODEC_UNKNOWN = 0,
  349     GD_HEIF_CODEC_HEVC,
  350     GD_HEIF_CODEC_AV1 = 4,
  351 } gdHeifCodec;
  352 
  353 /**
  354  * Group: HEIF Chroma Subsampling
  355  *
  356  * Values that select the HEIF chroma subsampling.
  357  *
  358  * Constants: gdHeifCompression
  359  *
  360  *  GD_HEIF_CHROMA_420
  361  *  GD_HEIF_CHROMA_422
  362  *  GD_HEIF_CHROMA_444
  363  *
  364  * See also:
  365  *  - <gdImageHeif>
  366  */
  367 typedef const char *gdHeifChroma;
  368 
  369 #define GD_HEIF_CHROMA_420 "420"
  370 #define GD_HEIF_CHROMA_422 "422"
  371 #define GD_HEIF_CHROMA_444 "444"
  372 
  373 /* define struct with name and func ptr and add it to gdImageStruct gdInterpolationMethod interpolation; */
  374 
  375 /* Interpolation function ptr */
  376 typedef double (* interpolation_method )(double);
  377 
  378 
  379 /*
  380    Group: Types
  381 
  382    typedef: gdImage
  383 
  384    typedef: gdImagePtr
  385 
  386    The data structure in which gd stores images. <gdImageCreate>,
  387    <gdImageCreateTrueColor> and the various image file-loading functions
  388    return a pointer to this type, and the other functions expect to
  389    receive a pointer to this type as their first argument.
  390 
  391    *gdImagePtr* is a pointer to *gdImage*.
  392 
  393    See also:
  394      <Accessor Macros>
  395 
  396    (Previous versions of this library encouraged directly manipulating
  397    the contents ofthe struct but we are attempting to move away from
  398    this practice so the fields are no longer documented here.  If you
  399    need to poke at the internals of this struct, feel free to look at
  400    *gd.h*.)
  401 */
  402 typedef struct gdImageStruct {
  403     /* Palette-based image pixels */
  404     unsigned char **pixels;
  405     int sx;
  406     int sy;
  407     /* These are valid in palette images only. See also
  408        'alpha', which appears later in the structure to
  409        preserve binary backwards compatibility */
  410     int colorsTotal;
  411     int red[gdMaxColors];
  412     int green[gdMaxColors];
  413     int blue[gdMaxColors];
  414     int open[gdMaxColors];
  415     /* For backwards compatibility, this is set to the
  416        first palette entry with 100% transparency,
  417        and is also set and reset by the
  418        gdImageColorTransparent function. Newer
  419        applications can allocate palette entries
  420        with any desired level of transparency; however,
  421        bear in mind that many viewers, notably
  422        many web browsers, fail to implement
  423        full alpha channel for PNG and provide
  424        support for full opacity or transparency only. */
  425     int transparent;
  426     int *polyInts;
  427     int polyAllocated;
  428     struct gdImageStruct *brush;
  429     struct gdImageStruct *tile;
  430     int brushColorMap[gdMaxColors];
  431     int tileColorMap[gdMaxColors];
  432     int styleLength;
  433     int stylePos;
  434     int *style;
  435     int interlace;
  436     /* New in 2.0: thickness of line. Initialized to 1. */
  437     int thick;
  438     /* New in 2.0: alpha channel for palettes. Note that only
  439        Macintosh Internet Explorer and (possibly) Netscape 6
  440        really support multiple levels of transparency in
  441        palettes, to my knowledge, as of 2/15/01. Most
  442        common browsers will display 100% opaque and
  443        100% transparent correctly, and do something
  444        unpredictable and/or undesirable for levels
  445        in between. TBB */
  446     int alpha[gdMaxColors];
  447     /* Truecolor flag and pixels. New 2.0 fields appear here at the
  448        end to minimize breakage of existing object code. */
  449     int trueColor;
  450     int **tpixels;
  451     /* Should alpha channel be copied, or applied, each time a
  452        pixel is drawn? This applies to truecolor images only.
  453        No attempt is made to alpha-blend in palette images,
  454        even if semitransparent palette entries exist.
  455        To do that, build your image as a truecolor image,
  456        then quantize down to 8 bits. */
  457     int alphaBlendingFlag;
  458     /* Should the alpha channel of the image be saved? This affects
  459        PNG at the moment; other future formats may also
  460        have that capability. JPEG doesn't. */
  461     int saveAlphaFlag;
  462 
  463     /* There should NEVER BE ACCESSOR MACROS FOR ITEMS BELOW HERE, so this
  464        part of the structure can be safely changed in new releases. */
  465 
  466     /* 2.0.12: anti-aliased globals. 2.0.26: just a few vestiges after
  467       switching to the fast, memory-cheap implementation from PHP-gd. */
  468     int AA;
  469     int AA_color;
  470     int AA_dont_blend;
  471 
  472     /* 2.0.12: simple clipping rectangle. These values
  473       must be checked for safety when set; please use
  474       gdImageSetClip */
  475     int cx1;
  476     int cy1;
  477     int cx2;
  478     int cy2;
  479 
  480     /* 2.1.0: allows to specify resolution in dpi */
  481     unsigned int res_x;
  482     unsigned int res_y;
  483 
  484     /* Selects quantization method, see gdImageTrueColorToPaletteSetMethod() and gdPaletteQuantizationMethod enum. */
  485     int paletteQuantizationMethod;
  486     /* speed/quality trade-off. 1 = best quality, 10 = best speed. 0 = method-specific default.
  487        Applicable to GD_QUANT_LIQ and GD_QUANT_NEUQUANT. */
  488     int paletteQuantizationSpeed;
  489     /* Image will remain true-color if conversion to palette cannot achieve given quality.
  490        Value from 1 to 100, 1 = ugly, 100 = perfect. Applicable to GD_QUANT_LIQ.*/
  491     int paletteQuantizationMinQuality;
  492     /* Image will use minimum number of palette colors needed to achieve given quality. Must be higher than paletteQuantizationMinQuality
  493        Value from 1 to 100, 1 = ugly, 100 = perfect. Applicable to GD_QUANT_LIQ.*/
  494     int paletteQuantizationMaxQuality;
  495     gdInterpolationMethod interpolation_id;
  496     interpolation_method interpolation;
  497 }
  498 gdImage;
  499 
  500 typedef gdImage *gdImagePtr;
  501 
  502 
  503 /* Point type for use in polygon drawing. */
  504 
  505 /**
  506  * Group: Types
  507  *
  508  * typedef: gdPointF
  509  *  Defines a point in a 2D coordinate system using floating point
  510  *  values.
  511  * x - Floating point position (increase from left to right)
  512  * y - Floating point Row position (increase from top to bottom)
  513  *
  514  * typedef: gdPointFPtr
  515  *  Pointer to a <gdPointF>
  516  *
  517  * See also:
  518  *  <gdImageCreate>, <gdImageCreateTrueColor>,
  519  **/
  520 typedef struct
  521 {
  522     double x, y;
  523 }
  524 gdPointF, *gdPointFPtr;
  525 
  526 
  527 /*
  528   Group: Types
  529 
  530   typedef: gdFont
  531 
  532   typedef: gdFontPtr
  533 
  534   A font structure, containing the bitmaps of all characters in a
  535   font.  Used to declare the characteristics of a font. Text-output
  536   functions expect these as their second argument, following the
  537   <gdImagePtr> argument.  <gdFontGetSmall> and <gdFontGetLarge> both
  538   return one.
  539 
  540   You can provide your own font data by providing such a structure and
  541   the associated pixel array. You can determine the width and height
  542   of a single character in a font by examining the w and h members of
  543   the structure. If you will not be creating your own fonts, you will
  544   not need to concern yourself with the rest of the components of this
  545   structure.
  546 
  547   Please see the files gdfontl.c and gdfontl.h for an example of
  548   the proper declaration of this structure.
  549 
  550   > typedef struct {
  551   >   // # of characters in font
  552   >   int nchars;
  553   >   // First character is numbered... (usually 32 = space)
  554   >   int offset;
  555   >   // Character width and height
  556   >   int w;
  557   >   int h;
  558   >   // Font data; array of characters, one row after another.
  559   >   // Easily included in code, also easily loaded from
  560   >   // data files.
  561   >   char *data;
  562   > } gdFont;
  563 
  564   gdFontPtr is a pointer to gdFont.
  565 
  566 */
  567 typedef struct {
  568     /* # of characters in font */
  569     int nchars;
  570     /* First character is numbered... (usually 32 = space) */
  571     int offset;
  572     /* Character width and height */
  573     int w;
  574     int h;
  575     /* Font data; array of characters, one row after another.
  576        Easily included in code, also easily loaded from
  577        data files. */
  578     char *data;
  579 }
  580 gdFont;
  581 
  582 /* Text functions take these. */
  583 typedef gdFont *gdFontPtr;
  584 
  585 typedef void(*gdErrorMethod)(int, const char *, va_list);
  586 
  587 BGD_DECLARE(void) gdSetErrorMethod(gdErrorMethod);
  588 BGD_DECLARE(void) gdClearErrorMethod(void);
  589 
  590 /* For backwards compatibility only. Use gdImageSetStyle()
  591    for MUCH more flexible line drawing. Also see
  592    gdImageSetBrush(). */
  593 #define gdDashSize 4
  594 
  595 /**
  596  * Group: Colors
  597  *
  598  * Colors are always of type int which is supposed to be at least 32 bit large.
  599  *
  600  * Kinds of colors:
  601  *   true colors     - ARGB values where the alpha channel is stored as most
  602  *                     significant, and the blue channel as least significant
  603  *                     byte. Note that the alpha channel only uses the 7 least
  604  *                     significant bits.
  605  *                     Don't rely on the internal representation, though, and
  606  *                     use <gdTrueColorAlpha> to compose a truecolor value, and
  607  *                     <gdTrueColorGetAlpha>, <gdTrueColorGetRed>,
  608  *                     <gdTrueColorGetGreen> and <gdTrueColorGetBlue> to access
  609  *                     the respective channels.
  610  *   palette indexes - The index of a color palette entry (0-255).
  611  *   special colors  - As listed in the following section.
  612  *
  613  * Constants: Special Colors
  614  *   gdStyled        - use the current style, see <gdImageSetStyle>
  615  *   gdBrushed       - use the current brush, see <gdImageSetBrush>
  616  *   gdStyledBrushed - use the current style and brush
  617  *   gdTiled         - use the current tile, see <gdImageSetTile>
  618  *   gdTransparent   - indicate transparency, what is not the same as the
  619  *                     transparent color index; used for lines only
  620  *   gdAntiAliased   - draw anti aliased
  621  */
  622 
  623 #define gdStyled (-2)
  624 #define gdBrushed (-3)
  625 #define gdStyledBrushed (-4)
  626 #define gdTiled (-5)
  627 #define gdTransparent (-6)
  628 #define gdAntiAliased (-7)
  629 
  630 /* Functions to manipulate images. */
  631 
  632 /* Creates a palette-based image (up to 256 colors). */
  633 BGD_DECLARE(gdImagePtr) gdImageCreate (int sx, int sy);
  634 
  635 /* An alternate name for the above (2.0). */
  636 #define gdImageCreatePalette gdImageCreate
  637 
  638 /* Creates a truecolor image (millions of colors). */
  639 BGD_DECLARE(gdImagePtr) gdImageCreateTrueColor (int sx, int sy);
  640 
  641 /* Creates an image from various file types. These functions
  642    return a palette or truecolor image based on the
  643    nature of the file being loaded. Truecolor PNG
  644    stays truecolor; palette PNG stays palette-based;
  645    JPEG is always truecolor. */
  646 BGD_DECLARE(gdImagePtr) gdImageCreateFromPng (FILE * fd);
  647 BGD_DECLARE(gdImagePtr) gdImageCreateFromPngCtx (gdIOCtxPtr in);
  648 BGD_DECLARE(gdImagePtr) gdImageCreateFromPngPtr (int size, void *data);
  649 
  650 /* These read the first frame only */
  651 BGD_DECLARE(gdImagePtr) gdImageCreateFromGif (FILE * fd);
  652 BGD_DECLARE(gdImagePtr) gdImageCreateFromGifCtx (gdIOCtxPtr in);
  653 BGD_DECLARE(gdImagePtr) gdImageCreateFromGifPtr (int size, void *data);
  654 BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMP (FILE * inFile);
  655 BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPCtx (gdIOCtx * infile);
  656 BGD_DECLARE(gdImagePtr) gdImageCreateFromWBMPPtr (int size, void *data);
  657 BGD_DECLARE(gdImagePtr) gdImageCreateFromJpeg (FILE * infile);
  658 BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegEx (FILE * infile, int ignore_warning);
  659 BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtx (gdIOCtx * infile);
  660 BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegCtxEx (gdIOCtx * infile, int ignore_warning);
  661 BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtr (int size, void *data);
  662 BGD_DECLARE(gdImagePtr) gdImageCreateFromJpegPtrEx (int size, void *data, int ignore_warning);
  663 BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile);
  664 BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data);
  665 BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile);
  666 
  667 BGD_DECLARE(gdImagePtr) gdImageCreateFromHeif(FILE *inFile);
  668 BGD_DECLARE(gdImagePtr) gdImageCreateFromHeifPtr(int size, void *data);
  669 BGD_DECLARE(gdImagePtr) gdImageCreateFromHeifCtx(gdIOCtx *infile);
  670 
  671 BGD_DECLARE(gdImagePtr) gdImageCreateFromAvif(FILE *inFile);
  672 BGD_DECLARE(gdImagePtr) gdImageCreateFromAvifPtr(int size, void *data);
  673 BGD_DECLARE(gdImagePtr) gdImageCreateFromAvifCtx(gdIOCtx *infile);
  674 
  675 BGD_DECLARE(gdImagePtr) gdImageCreateFromTiff(FILE *inFile);
  676 BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffCtx(gdIOCtx *infile);
  677 BGD_DECLARE(gdImagePtr) gdImageCreateFromTiffPtr(int size, void *data);
  678 
  679 BGD_DECLARE(gdImagePtr) gdImageCreateFromTga( FILE * fp );
  680 BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaCtx(gdIOCtx* ctx);
  681 BGD_DECLARE(gdImagePtr) gdImageCreateFromTgaPtr(int size, void *data);
  682 
  683 BGD_DECLARE(gdImagePtr) gdImageCreateFromBmp (FILE * inFile);
  684 BGD_DECLARE(gdImagePtr) gdImageCreateFromBmpPtr (int size, void *data);
  685 BGD_DECLARE(gdImagePtr) gdImageCreateFromBmpCtx (gdIOCtxPtr infile);
  686 BGD_DECLARE(gdImagePtr) gdImageCreateFromFile(const char *filename);
  687 
  688 
  689 /*
  690   Group: Types
  691 
  692   typedef: gdSource
  693 
  694   typedef: gdSourcePtr
  695 
  696     *Note:* This interface is *obsolete* and kept only for
  697     *compatibility.  Use <gdIOCtx> instead.
  698 
  699     Represents a source from which a PNG can be read. Programmers who
  700     do not wish to read PNGs from a file can provide their own
  701     alternate input mechanism, using the <gdImageCreateFromPngSource>
  702     function. See the documentation of that function for an example of
  703     the proper use of this type.
  704 
  705     > typedef struct {
  706     >         int (*source) (void *context, char *buffer, int len);
  707     >         void *context;
  708     > } gdSource, *gdSourcePtr;
  709 
  710     The source function must return -1 on error, otherwise the number
  711     of bytes fetched. 0 is EOF, not an error!
  712 
  713    'context' will be passed to your source function.
  714 
  715 */
  716 typedef struct {
  717     int (*source) (void *context, char *buffer, int len);
  718     void *context;
  719 }
  720 gdSource, *gdSourcePtr;
  721 
  722 /* Deprecated in favor of gdImageCreateFromPngCtx */
  723 BGD_DECLARE(gdImagePtr) gdImageCreateFromPngSource (gdSourcePtr in);
  724 
  725 BGD_DECLARE(gdImagePtr) gdImageCreateFromGd (FILE * in);
  726 BGD_DECLARE(gdImagePtr) gdImageCreateFromGdCtx (gdIOCtxPtr in);
  727 BGD_DECLARE(gdImagePtr) gdImageCreateFromGdPtr (int size, void *data);
  728 
  729 BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2 (FILE * in);
  730 BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ctx (gdIOCtxPtr in);
  731 BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Ptr (int size, void *data);
  732 
  733 BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2Part (FILE * in, int srcx, int srcy, int w,
  734                           int h);
  735 BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartCtx (gdIOCtxPtr in, int srcx, int srcy,
  736                              int w, int h);
  737 BGD_DECLARE(gdImagePtr) gdImageCreateFromGd2PartPtr (int size, void *data, int srcx, int srcy,
  738                              int w, int h);
  739 /* 2.0.10: prototype was missing */
  740 BGD_DECLARE(gdImagePtr) gdImageCreateFromXbm (FILE * in);
  741 BGD_DECLARE(void) gdImageXbmCtx(gdImagePtr image, char* file_name, int fg, gdIOCtx * out);
  742 
  743 /* NOTE: filename, not FILE */
  744 BGD_DECLARE(gdImagePtr) gdImageCreateFromXpm (char *filename);
  745 
  746 BGD_DECLARE(void) gdImageDestroy (gdImagePtr im);
  747 
  748 /* Replaces or blends with the background depending on the
  749    most recent call to gdImageAlphaBlending and the
  750    alpha channel value of 'color'; default is to overwrite.
  751    Tiling and line styling are also implemented
  752    here. All other gd drawing functions pass through this call,
  753    allowing for many useful effects.
  754    Overlay and multiply effects are used when gdImageAlphaBlending
  755    is passed gdEffectOverlay and gdEffectMultiply */
  756 
  757 BGD_DECLARE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color);
  758 /* FreeType 2 text output with hook to extra flags */
  759 
  760 BGD_DECLARE(int) gdImageGetPixel (gdImagePtr im, int x, int y);
  761 BGD_DECLARE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y);
  762 
  763 BGD_DECLARE(void) gdImageAABlend (gdImagePtr im);
  764 
  765 BGD_DECLARE(void) gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color);
  766 
  767 /* For backwards compatibility only. Use gdImageSetStyle()
  768    for much more flexible line drawing. */
  769 BGD_DECLARE(void) gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2,
  770                                      int color);
  771 /* Corners specified (not width and height). Upper left first, lower right
  772    second. */
  773 BGD_DECLARE(void) gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
  774                                     int color);
  775 /* Solid bar. Upper left corner first, lower right corner second. */
  776 BGD_DECLARE(void) gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2,
  777                       int color);
  778 BGD_DECLARE(void) gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2);
  779 BGD_DECLARE(void) gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P);
  780 BGD_DECLARE(void) gdImageSetResolution(gdImagePtr im, const unsigned int res_x, const unsigned int res_y);
  781 BGD_DECLARE(int) gdImageBoundsSafe (gdImagePtr im, int x, int y);
  782 BGD_DECLARE(void) gdImageChar (gdImagePtr im, gdFontPtr f, int x, int y, int c,
  783                                int color);
  784 BGD_DECLARE(void) gdImageCharUp (gdImagePtr im, gdFontPtr f, int x, int y, int c,
  785                                  int color);
  786 BGD_DECLARE(void) gdImageString (gdImagePtr im, gdFontPtr f, int x, int y,
  787                                  unsigned char *s, int color);
  788 BGD_DECLARE(void) gdImageStringUp (gdImagePtr im, gdFontPtr f, int x, int y,
  789                                    unsigned char *s, int color);
  790 BGD_DECLARE(void) gdImageString16 (gdImagePtr im, gdFontPtr f, int x, int y,
  791                                    unsigned short *s, int color);
  792 BGD_DECLARE(void) gdImageStringUp16 (gdImagePtr im, gdFontPtr f, int x, int y,
  793                                      unsigned short *s, int color);
  794 
  795 /* 2.0.16: for thread-safe use of gdImageStringFT and friends,
  796    call this before allowing any thread to call gdImageStringFT.
  797    Otherwise it is invoked by the first thread to invoke
  798    gdImageStringFT, with a very small but real risk of a race condition.
  799    Return 0 on success, nonzero on failure to initialize freetype. */
  800 BGD_DECLARE(int) gdFontCacheSetup (void);
  801 
  802 /* Optional: clean up after application is done using fonts in
  803    gdImageStringFT(). */
  804 BGD_DECLARE(void) gdFontCacheShutdown (void);
  805 /* 2.0.20: for backwards compatibility. A few applications did start calling
  806    this function when it first appeared although it was never documented.
  807    Simply invokes gdFontCacheShutdown. */
  808 BGD_DECLARE(void) gdFreeFontCache (void);
  809 
  810 /* Calls gdImageStringFT. Provided for backwards compatibility only. */
  811 BGD_DECLARE(char *) gdImageStringTTF (gdImage * im, int *brect, int fg, const char *fontlist,
  812                                       double ptsize, double angle, int x, int y,
  813                                       const char *string);
  814 
  815 /* FreeType 2 text output */
  816 BGD_DECLARE(char *) gdImageStringFT (gdImage * im, int *brect, int fg, const char *fontlist,
  817                                      double ptsize, double angle, int x, int y,
  818                                      const char *string);
  819 
  820 
  821 /*
  822   Group: Types
  823 
  824   typedef: gdFTStringExtra
  825 
  826   typedef: gdFTStringExtraPtr
  827 
  828   A structure and associated pointer type used to pass additional
  829   parameters to the <gdImageStringFTEx> function. See
  830   <gdImageStringFTEx> for the structure definition.
  831 
  832   Thanks to Wez Furlong.
  833 */
  834 
  835 /* 2.0.5: provides an extensible way to pass additional parameters.
  836    Thanks to Wez Furlong, sorry for the delay. */
  837 typedef struct {
  838     int flags;      /* Logical OR of gdFTEX_ values */
  839     double linespacing; /* fine tune line spacing for '\n' */
  840     int charmap;        /* TBB: 2.0.12: may be gdFTEX_Unicode,
  841                    gdFTEX_Shift_JIS, gdFTEX_Big5,
  842                    or gdFTEX_Adobe_Custom;
  843                    when not specified, maps are searched
  844                    for in the above order. */
  845     int hdpi;                /* if (flags & gdFTEX_RESOLUTION) */
  846     int vdpi;        /* if (flags & gdFTEX_RESOLUTION) */
  847     char *xshow;             /* if (flags & gdFTEX_XSHOW)
  848                     then, on return, xshow is a malloc'ed
  849                     string containing xshow position data for
  850                     the last string.
  851 
  852                     NB. The caller is responsible for gdFree'ing
  853                     the xshow string.
  854                  */
  855     char *fontpath;          /* if (flags & gdFTEX_RETURNFONTPATHNAME)
  856                     then, on return, fontpath is a malloc'ed
  857                     string containing the actual font file path name
  858                     used, which can be interesting when fontconfig
  859                     is in use.
  860 
  861                     The caller is responsible for gdFree'ing the
  862                     fontpath string.
  863                  */
  864 
  865 }
  866 gdFTStringExtra, *gdFTStringExtraPtr;
  867 
  868 #define gdFTEX_LINESPACE 1
  869 #define gdFTEX_CHARMAP 2
  870 #define gdFTEX_RESOLUTION 4
  871 #define gdFTEX_DISABLE_KERNING 8
  872 #define gdFTEX_XSHOW 16
  873 /* The default unless gdFTUseFontConfig(1); has been called:
  874    fontlist is a full or partial font file pathname or list thereof
  875    (i.e. just like before 2.0.29) */
  876 #define gdFTEX_FONTPATHNAME 32
  877 /* Necessary to use fontconfig patterns instead of font pathnames
  878    as the fontlist argument, unless gdFTUseFontConfig(1); has
  879    been called. New in 2.0.29 */
  880 #define gdFTEX_FONTCONFIG 64
  881 /* Sometimes interesting when fontconfig is used: the fontpath
  882    element of the structure above will contain a gdMalloc'd string
  883    copy of the actual font file pathname used, if this flag is set
  884    when the call is made */
  885 #define gdFTEX_RETURNFONTPATHNAME 128
  886 
  887 /* If flag is nonzero, the fontlist parameter to gdImageStringFT
  888    and gdImageStringFTEx shall be assumed to be a fontconfig font pattern
  889    if fontconfig was compiled into gd. This function returns zero
  890    if fontconfig is not available, nonzero otherwise. */
  891 BGD_DECLARE(int) gdFTUseFontConfig(int flag);
  892 
  893 /* These are NOT flags; set one in 'charmap' if you set the
  894    gdFTEX_CHARMAP bit in 'flags'. */
  895 #define gdFTEX_Unicode 0
  896 #define gdFTEX_Shift_JIS 1
  897 #define gdFTEX_Big5 2
  898 #define gdFTEX_Adobe_Custom 3
  899 
  900 BGD_DECLARE(char *) gdImageStringFTEx (gdImage * im, int *brect, int fg, const char *fontlist,
  901                                        double ptsize, double angle, int x, int y,
  902                                        const char *string, gdFTStringExtraPtr strex);
  903 
  904 
  905 /*
  906   Group: Types
  907 
  908   typedef: gdPoint
  909 
  910   typedef: gdPointPtr
  911 
  912   Represents a point in the coordinate space of the image; used by
  913   <gdImagePolygon>, <gdImageOpenPolygon> and <gdImageFilledPolygon>
  914   for polygon drawing.
  915 
  916   > typedef struct {
  917   >     int x, y;
  918   > } gdPoint, *gdPointPtr;
  919 
  920 */
  921 typedef struct {
  922     int x, y;
  923 }
  924 gdPoint, *gdPointPtr;
  925 
  926 /**
  927  * Typedef: gdRect
  928  *
  929  * A rectangle in the coordinate space of the image
  930  *
  931  * Members:
  932  *   x      - The x-coordinate of the upper left corner.
  933  *   y      - The y-coordinate of the upper left corner.
  934  *   width  - The width.
  935  *   height - The height.
  936  *
  937  * Typedef: gdRectPtr
  938  *
  939  * A pointer to a <gdRect>
  940  */
  941 typedef struct {
  942     int x, y;
  943     int width, height;
  944 }
  945 gdRect, *gdRectPtr;
  946 
  947 
  948 BGD_DECLARE(void) gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c);
  949 BGD_DECLARE(void) gdImageOpenPolygon (gdImagePtr im, gdPointPtr p, int n, int c);
  950 BGD_DECLARE(void) gdImageFilledPolygon (gdImagePtr im, gdPointPtr p, int n, int c);
  951 
  952 /* These functions still work with truecolor images,
  953    for which they never return error. */
  954 BGD_DECLARE(int) gdImageColorAllocate (gdImagePtr im, int r, int g, int b);
  955 /* gd 2.0: palette entries with non-opaque transparency are permitted. */
  956 BGD_DECLARE(int) gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a);
  957 /* Assumes opaque is the preferred alpha channel value */
  958 BGD_DECLARE(int) gdImageColorClosest (gdImagePtr im, int r, int g, int b);
  959 /* Closest match taking all four parameters into account.
  960    A slightly different color with the same transparency
  961    beats the exact same color with radically different
  962    transparency */
  963 BGD_DECLARE(int) gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, int a);
  964 /* An alternate method */
  965 BGD_DECLARE(int) gdImageColorClosestHWB (gdImagePtr im, int r, int g, int b);
  966 /* Returns exact, 100% opaque matches only */
  967 BGD_DECLARE(int) gdImageColorExact (gdImagePtr im, int r, int g, int b);
  968 /* Returns an exact match only, including alpha */
  969 BGD_DECLARE(int) gdImageColorExactAlpha (gdImagePtr im, int r, int g, int b, int a);
  970 /* Opaque only */
  971 BGD_DECLARE(int) gdImageColorResolve (gdImagePtr im, int r, int g, int b);
  972 /* Based on gdImageColorExactAlpha and gdImageColorClosestAlpha */
  973 BGD_DECLARE(int) gdImageColorResolveAlpha (gdImagePtr im, int r, int g, int b, int a);
  974 
  975 /* A simpler way to obtain an opaque truecolor value for drawing on a
  976    truecolor image. Not for use with palette images! */
  977 
  978 #define gdTrueColor(r, g, b) (((r) << 16) + \
  979                   ((g) << 8) +  \
  980                   (b))
  981 
  982 /**
  983  * Group: Color Composition
  984  *
  985  * Macro: gdTrueColorAlpha
  986  *
  987  * Compose a truecolor value from its components
  988  *
  989  * Parameters:
  990  *   r - The red channel (0-255)
  991  *   g - The green channel (0-255)
  992  *   b - The blue channel (0-255)
  993  *   a - The alpha channel (0-127, where 127 is fully transparent, and 0 is
  994  *       completely opaque).
  995  *
  996  * See also:
  997  *   - <gdTrueColorGetAlpha>
  998  *   - <gdTrueColorGetRed>
  999  *   - <gdTrueColorGetGreen>
 1000  *   - <gdTrueColorGetBlue>
 1001  *   - <gdImageColorExactAlpha>
 1002  */
 1003 #define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \
 1004                       ((r) << 16) + \
 1005                       ((g) << 8) +  \
 1006                       (b))
 1007 
 1008 BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color);
 1009 
 1010 /* Converts a truecolor image to a palette-based image,
 1011    using a high-quality two-pass quantization routine
 1012    which attempts to preserve alpha channel information
 1013    as well as R/G/B color information when creating
 1014    a palette. If ditherFlag is set, the image will be
 1015    dithered to approximate colors better, at the expense
 1016    of some obvious "speckling." colorsWanted can be
 1017    anything up to 256. If the original source image
 1018    includes photographic information or anything that
 1019    came out of a JPEG, 256 is strongly recommended.
 1020 
 1021    Better yet, don't use these function -- write real
 1022    truecolor PNGs and JPEGs. The disk space gain of
 1023    conversion to palette is not great (for small images
 1024    it can be negative) and the quality loss is ugly.
 1025 
 1026    DIFFERENCES: gdImageCreatePaletteFromTrueColor creates and
 1027    returns a new image. gdImageTrueColorToPalette modifies
 1028    an existing image, and the truecolor pixels are discarded.
 1029 
 1030    gdImageTrueColorToPalette() returns TRUE on success, FALSE on failure.
 1031 */
 1032 
 1033 BGD_DECLARE(gdImagePtr) gdImageCreatePaletteFromTrueColor (gdImagePtr im, int ditherFlag,
 1034                                int colorsWanted);
 1035 
 1036 BGD_DECLARE(int) gdImageTrueColorToPalette (gdImagePtr im, int ditherFlag,
 1037                         int colorsWanted);
 1038 
 1039 BGD_DECLARE(int) gdImagePaletteToTrueColor(gdImagePtr src);
 1040 
 1041 /* An attempt at getting the results of gdImageTrueColorToPalette to
 1042  * look a bit more like the original (im1 is the original and im2 is
 1043  * the palette version */
 1044 
 1045 BGD_DECLARE(int) gdImageColorMatch(gdImagePtr im1, gdImagePtr im2);
 1046 
 1047 /* Selects quantization method used for subsequent gdImageTrueColorToPalette calls.
 1048    See gdPaletteQuantizationMethod enum (e.g. GD_QUANT_NEUQUANT, GD_QUANT_LIQ).
 1049    Speed is from 1 (highest quality) to 10 (fastest).
 1050    Speed 0 selects method-specific default (recommended).
 1051 
 1052    Returns FALSE if the given method is invalid or not available.
 1053 */
 1054 BGD_DECLARE(int) gdImageTrueColorToPaletteSetMethod (gdImagePtr im, int method, int speed);
 1055 
 1056 /*
 1057   Chooses quality range that subsequent call to gdImageTrueColorToPalette will aim for.
 1058   Min and max quality is in range 1-100 (1 = ugly, 100 = perfect). Max must be higher than min.
 1059   If palette cannot represent image with at least min_quality, then image will remain true-color.
 1060   If palette can represent image with quality better than max_quality, then lower number of colors will be used.
 1061   This function has effect only when GD_QUANT_LIQ method has been selected and the source image is true-color.
 1062 */
 1063 BGD_DECLARE(void) gdImageTrueColorToPaletteSetQuality (gdImagePtr im, int min_quality, int max_quality);
 1064 
 1065 /* Specifies a color index (if a palette image) or an
 1066    RGB color (if a truecolor image) which should be
 1067    considered 100% transparent. FOR TRUECOLOR IMAGES,
 1068    THIS IS IGNORED IF AN ALPHA CHANNEL IS BEING
 1069    SAVED. Use gdImageSaveAlpha(im, 0); to
 1070    turn off the saving of a full alpha channel in
 1071    a truecolor image. Note that gdImageColorTransparent
 1072    is usually compatible with older browsers that
 1073    do not understand full alpha channels well. TBB */
 1074 BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color);
 1075 
 1076 BGD_DECLARE(void) gdImagePaletteCopy (gdImagePtr dst, gdImagePtr src);
 1077 
 1078 typedef int (*gdCallbackImageColor)(gdImagePtr im, int src);
 1079 
 1080 BGD_DECLARE(int) gdImageColorReplace(gdImagePtr im, int src, int dst);
 1081 BGD_DECLARE(int) gdImageColorReplaceThreshold(gdImagePtr im, int src, int dst, float threshold);
 1082 BGD_DECLARE(int) gdImageColorReplaceArray(gdImagePtr im, int len, int *src, int *dst);
 1083 BGD_DECLARE(int) gdImageColorReplaceCallback(gdImagePtr im, gdCallbackImageColor callback);
 1084 
 1085 BGD_DECLARE(void) gdImageGif (gdImagePtr im, FILE * out);
 1086 BGD_DECLARE(void) gdImagePng (gdImagePtr im, FILE * out);
 1087 BGD_DECLARE(void) gdImagePngCtx (gdImagePtr im, gdIOCtx * out);
 1088 BGD_DECLARE(void) gdImageGifCtx (gdImagePtr im, gdIOCtx * out);
 1089 BGD_DECLARE(void) gdImageTiff(gdImagePtr im, FILE *outFile);
 1090 BGD_DECLARE(void *) gdImageTiffPtr(gdImagePtr im, int *size);
 1091 BGD_DECLARE(void) gdImageTiffCtx(gdImagePtr image, gdIOCtx *out);
 1092 
 1093 BGD_DECLARE(void *) gdImageBmpPtr(gdImagePtr im, int *size, int compression);
 1094 BGD_DECLARE(void) gdImageBmp(gdImagePtr im, FILE *outFile, int compression);
 1095 BGD_DECLARE(void) gdImageBmpCtx(gdImagePtr im, gdIOCtxPtr out, int compression);
 1096 
 1097 /* 2.0.12: Compression level: 0-9 or -1, where 0 is NO COMPRESSION at all,
 1098    1 is FASTEST but produces larger files, 9 provides the best
 1099    compression (smallest files) but takes a long time to compress, and
 1100    -1 selects the default compiled into the zlib library. */
 1101 BGD_DECLARE(void) gdImagePngEx (gdImagePtr im, FILE * out, int level);
 1102 BGD_DECLARE(void) gdImagePngCtxEx (gdImagePtr im, gdIOCtx * out, int level);
 1103 
 1104 BGD_DECLARE(void) gdImageWBMP (gdImagePtr image, int fg, FILE * out);
 1105 BGD_DECLARE(void) gdImageWBMPCtx (gdImagePtr image, int fg, gdIOCtx * out);
 1106 
 1107 BGD_DECLARE(int) gdImageFile(gdImagePtr im, const char *filename);
 1108 BGD_DECLARE(int) gdSupportsFileType(const char *filename, int writing);
 1109 
 1110 
 1111 /* Guaranteed to correctly free memory returned by the gdImage*Ptr
 1112    functions */
 1113 BGD_DECLARE(void) gdFree (void *m);
 1114 
 1115 /* Best to free this memory with gdFree(), not free() */
 1116 BGD_DECLARE(void *) gdImageWBMPPtr (gdImagePtr im, int *size, int fg);
 1117 
 1118 /* 100 is highest quality (there is always a little loss with JPEG).
 1119    0 is lowest. 10 is about the lowest useful setting. */
 1120 BGD_DECLARE(void) gdImageJpeg (gdImagePtr im, FILE * out, int quality);
 1121 BGD_DECLARE(void) gdImageJpegCtx (gdImagePtr im, gdIOCtx * out, int quality);
 1122 
 1123 /* Best to free this memory with gdFree(), not free() */
 1124 BGD_DECLARE(void *) gdImageJpegPtr (gdImagePtr im, int *size, int quality);
 1125 
 1126 BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quantization);
 1127 BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile);
 1128 BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size);
 1129 BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quantization);
 1130 BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization);
 1131 
 1132 BGD_DECLARE(void) gdImageHeifEx(gdImagePtr im, FILE *outFile, int quality, gdHeifCodec codec, gdHeifChroma chroma);
 1133 BGD_DECLARE(void) gdImageHeif(gdImagePtr im, FILE *outFile);
 1134 BGD_DECLARE(void *) gdImageHeifPtr(gdImagePtr im, int *size);
 1135 BGD_DECLARE(void *) gdImageHeifPtrEx(gdImagePtr im, int *size, int quality, gdHeifCodec codec, gdHeifChroma chroma);
 1136 BGD_DECLARE(void) gdImageHeifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, gdHeifCodec codec, gdHeifChroma chroma);
 1137 
 1138 BGD_DECLARE(void) gdImageAvif(gdImagePtr im, FILE *outFile);
 1139 BGD_DECLARE(void) gdImageAvifEx(gdImagePtr im, FILE *outFile, int quality, int speed);
 1140 BGD_DECLARE(void *) gdImageAvifPtr(gdImagePtr im, int *size);
 1141 BGD_DECLARE(void *) gdImageAvifPtrEx(gdImagePtr im, int *size, int quality, int speed);
 1142 BGD_DECLARE(void) gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed);
 1143 
 1144 /**
 1145  * Group: GifAnim
 1146  *
 1147  *   Legal values for Disposal. gdDisposalNone is always used by
 1148  *   the built-in optimizer if previm is passed.
 1149  *
 1150  * Constants: gdImageGifAnim
 1151  *
 1152  *   gdDisposalUnknown              - Not recommended
 1153  *   gdDisposalNone                 - Preserve previous frame
 1154  *   gdDisposalRestoreBackground    - First allocated color of palette
 1155  *   gdDisposalRestorePrevious      - Restore to before start of frame
 1156  *
 1157  * See also:
 1158  *   - <gdImageGifAnimAdd>
 1159  */
 1160 enum {
 1161     gdDisposalUnknown,
 1162     gdDisposalNone,
 1163     gdDisposalRestoreBackground,
 1164     gdDisposalRestorePrevious
 1165 };
 1166 
 1167 BGD_DECLARE(void) gdImageGifAnimBegin(gdImagePtr im, FILE *outFile, int GlobalCM, int Loops);
 1168 BGD_DECLARE(void) gdImageGifAnimAdd(gdImagePtr im, FILE *outFile, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);
 1169 BGD_DECLARE(void) gdImageGifAnimEnd(FILE *outFile);
 1170 BGD_DECLARE(void) gdImageGifAnimBeginCtx(gdImagePtr im, gdIOCtx *out, int GlobalCM, int Loops);
 1171 BGD_DECLARE(void) gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);
 1172 BGD_DECLARE(void) gdImageGifAnimEndCtx(gdIOCtx *out);
 1173 BGD_DECLARE(void *) gdImageGifAnimBeginPtr(gdImagePtr im, int *size, int GlobalCM, int Loops);
 1174 BGD_DECLARE(void *) gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm);
 1175 BGD_DECLARE(void *) gdImageGifAnimEndPtr(int *size);
 1176 
 1177 
 1178 
 1179 /*
 1180   Group: Types
 1181 
 1182   typedef: gdSink
 1183 
 1184   typedef: gdSinkPtr
 1185 
 1186     *Note:* This interface is *obsolete* and kept only for
 1187     *compatibility*.  Use <gdIOCtx> instead.
 1188 
 1189     Represents a "sink" (destination) to which a PNG can be
 1190     written. Programmers who do not wish to write PNGs to a file can
 1191     provide their own alternate output mechanism, using the
 1192     <gdImagePngToSink> function. See the documentation of that
 1193     function for an example of the proper use of this type.
 1194 
 1195     > typedef struct {
 1196     >     int (*sink) (void *context, char *buffer, int len);
 1197     >     void *context;
 1198     > } gdSink, *gdSinkPtr;
 1199 
 1200     The _sink_ function must return -1 on error, otherwise the number of
 1201     bytes written, which must be equal to len.
 1202 
 1203     _context_ will be passed to your sink function.
 1204 
 1205 */
 1206 
 1207 typedef struct {
 1208     int (*sink) (void *context, const char *buffer, int len);
 1209     void *context;
 1210 }
 1211 gdSink, *gdSinkPtr;
 1212 
 1213 BGD_DECLARE(void) gdImagePngToSink (gdImagePtr im, gdSinkPtr out);
 1214 
 1215 BGD_DECLARE(void) gdImageGd (gdImagePtr im, FILE * out);
 1216 BGD_DECLARE(void) gdImageGd2 (gdImagePtr im, FILE * out, int cs, int fmt);
 1217 
 1218 /* Best to free this memory with gdFree(), not free() */
 1219 BGD_DECLARE(void *) gdImageGifPtr (gdImagePtr im, int *size);
 1220 
 1221 /* Best to free this memory with gdFree(), not free() */
 1222 BGD_DECLARE(void *) gdImagePngPtr (gdImagePtr im, int *size);
 1223 BGD_DECLARE(void *) gdImagePngPtrEx (gdImagePtr im, int *size, int level);
 1224 
 1225 /* Best to free this memory with gdFree(), not free() */
 1226 BGD_DECLARE(void *) gdImageGdPtr (gdImagePtr im, int *size);
 1227 
 1228 /* Best to free this memory with gdFree(), not free() */
 1229 BGD_DECLARE(void *) gdImageGd2Ptr (gdImagePtr im, int cs, int fmt, int *size);
 1230 
 1231 /* Style is a bitwise OR ( | operator ) of these.
 1232    gdArc and gdChord are mutually exclusive;
 1233    gdChord just connects the starting and ending
 1234    angles with a straight line, while gdArc produces
 1235    a rounded edge. gdPie is a synonym for gdArc.
 1236    gdNoFill indicates that the arc or chord should be
 1237    outlined, not filled. gdEdged, used together with
 1238    gdNoFill, indicates that the beginning and ending
 1239    angles should be connected to the center; this is
 1240    a good way to outline (rather than fill) a
 1241    'pie slice'. */
 1242 #define gdArc   0
 1243 #define gdPie   gdArc
 1244 #define gdChord 1
 1245 #define gdNoFill 2
 1246 #define gdEdged 4
 1247 
 1248 BGD_DECLARE(void) gdImageFilledArc (gdImagePtr im, int cx, int cy, int w, int h, int s,
 1249                                     int e, int color, int style);
 1250 BGD_DECLARE(void) gdImageArc (gdImagePtr im, int cx, int cy, int w, int h, int s, int e,
 1251                               int color);
 1252 BGD_DECLARE(void) gdImageEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
 1253 BGD_DECLARE(void) gdImageFilledEllipse (gdImagePtr im, int cx, int cy, int w, int h,
 1254                                         int color);
 1255 BGD_DECLARE(void) gdImageFillToBorder (gdImagePtr im, int x, int y, int border,
 1256                                        int color);
 1257 BGD_DECLARE(void) gdImageFill (gdImagePtr im, int x, int y, int color);
 1258 BGD_DECLARE(void) gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
 1259                                int srcX, int srcY, int w, int h);
 1260 BGD_DECLARE(void) gdImageCopyMerge (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
 1261                                     int srcX, int srcY, int w, int h, int pct);
 1262 BGD_DECLARE(void) gdImageCopyMergeGray (gdImagePtr dst, gdImagePtr src, int dstX,
 1263                                         int dstY, int srcX, int srcY, int w, int h,
 1264                                         int pct);
 1265 
 1266 /* Stretches or shrinks to fit, as needed. Does NOT attempt
 1267    to average the entire set of source pixels that scale down onto the
 1268    destination pixel. */
 1269 BGD_DECLARE(void) gdImageCopyResized (gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
 1270                                       int srcX, int srcY, int dstW, int dstH, int srcW,
 1271                                       int srcH);
 1272 
 1273 /* gd 2.0: stretches or shrinks to fit, as needed. When called with a
 1274    truecolor destination image, this function averages the
 1275    entire set of source pixels that scale down onto the
 1276    destination pixel, taking into account what portion of the
 1277    destination pixel each source pixel represents. This is a
 1278    floating point operation, but this is not a performance issue
 1279    on modern hardware, except for some embedded devices. If the
 1280    destination is a palette image, gdImageCopyResized is
 1281    substituted automatically. */
 1282 BGD_DECLARE(void) gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX,
 1283                                         int dstY, int srcX, int srcY, int dstW, int dstH,
 1284                                         int srcW, int srcH);
 1285 
 1286 /* gd 2.0.8: gdImageCopyRotated is added. Source
 1287    is a rectangle, with its upper left corner at
 1288    srcX and srcY. Destination is the *center* of
 1289    the rotated copy. Angle is in degrees, same as
 1290    gdImageArc. Floating point destination center
 1291    coordinates allow accurate rotation of
 1292    objects of odd-numbered width or height. */
 1293 BGD_DECLARE(void) gdImageCopyRotated (gdImagePtr dst,
 1294                                       gdImagePtr src,
 1295                                       double dstX, double dstY,
 1296                                       int srcX, int srcY,
 1297                                       int srcWidth, int srcHeight, int angle);
 1298 
 1299 BGD_DECLARE(gdImagePtr) gdImageClone (gdImagePtr src);
 1300 
 1301 BGD_DECLARE(void) gdImageSetBrush (gdImagePtr im, gdImagePtr brush);
 1302 BGD_DECLARE(void) gdImageSetTile (gdImagePtr im, gdImagePtr tile);
 1303 BGD_DECLARE(void) gdImageSetAntiAliased (gdImagePtr im, int c);
 1304 BGD_DECLARE(void) gdImageSetAntiAliasedDontBlend (gdImagePtr im, int c, int dont_blend);
 1305 BGD_DECLARE(void) gdImageSetStyle (gdImagePtr im, int *style, int noOfPixels);
 1306 /* Line thickness (defaults to 1). Affects lines, ellipses,
 1307    rectangles, polygons and so forth. */
 1308 BGD_DECLARE(void) gdImageSetThickness (gdImagePtr im, int thickness);
 1309 /* On or off (1 or 0) for all three of these. */
 1310 BGD_DECLARE(void) gdImageInterlace (gdImagePtr im, int interlaceArg);
 1311 BGD_DECLARE(void) gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg);
 1312 BGD_DECLARE(void) gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg);
 1313 
 1314 BGD_DECLARE(gdImagePtr) gdImageNeuQuant(gdImagePtr im, const int max_color, int sample_factor);
 1315 
 1316 enum gdPixelateMode {
 1317     GD_PIXELATE_UPPERLEFT,
 1318     GD_PIXELATE_AVERAGE
 1319 };
 1320 
 1321 BGD_DECLARE(int) gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode);
 1322 
 1323 typedef struct {
 1324     int sub;
 1325     int plus;
 1326     unsigned int num_colors;
 1327     int *colors;
 1328     unsigned int seed;
 1329 } gdScatter, *gdScatterPtr;
 1330 
 1331 BGD_DECLARE(int) gdImageScatter(gdImagePtr im, int sub, int plus);
 1332 BGD_DECLARE(int) gdImageScatterColor(gdImagePtr im, int sub, int plus, int colors[], unsigned int num_colors);
 1333 BGD_DECLARE(int) gdImageScatterEx(gdImagePtr im, gdScatterPtr s);
 1334 BGD_DECLARE(int) gdImageSmooth(gdImagePtr im, float weight);
 1335 BGD_DECLARE(int) gdImageMeanRemoval(gdImagePtr im);
 1336 BGD_DECLARE(int) gdImageEmboss(gdImagePtr im);
 1337 BGD_DECLARE(int) gdImageGaussianBlur(gdImagePtr im);
 1338 BGD_DECLARE(int) gdImageEdgeDetectQuick(gdImagePtr src);
 1339 BGD_DECLARE(int) gdImageSelectiveBlur( gdImagePtr src);
 1340 BGD_DECLARE(int) gdImageConvolution(gdImagePtr src, float filter[3][3], float filter_div, float offset);
 1341 BGD_DECLARE(int) gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha);
 1342 BGD_DECLARE(int) gdImageContrast(gdImagePtr src, double contrast);
 1343 BGD_DECLARE(int) gdImageBrightness(gdImagePtr src, int brightness);
 1344 BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src);
 1345 BGD_DECLARE(int) gdImageNegate(gdImagePtr src);
 1346 
 1347 BGD_DECLARE(gdImagePtr) gdImageCopyGaussianBlurred(gdImagePtr src, int radius,
 1348                                                    double sigma);
 1349 
 1350 
 1351 /**
 1352  * Group: Accessor Macros
 1353  */
 1354 
 1355 /**
 1356  * Macro: gdImageTrueColor
 1357  *
 1358  * Whether an image is a truecolor image.
 1359  *
 1360  * Parameters:
 1361  *   im - The image.
 1362  *
 1363  * Returns:
 1364  *   Non-zero if the image is a truecolor image, zero for palette images.
 1365  */
 1366 #define gdImageTrueColor(im) ((im)->trueColor)
 1367 
 1368 /**
 1369  * Macro: gdImageSX
 1370  *
 1371  * Gets the width (in pixels) of an image.
 1372  *
 1373  * Parameters:
 1374  *   im - The image.
 1375  */
 1376 #define gdImageSX(im) ((im)->sx)
 1377 
 1378 /**
 1379  * Macro: gdImageSY
 1380  *
 1381  * Gets the height (in pixels) of an image.
 1382  *
 1383  * Parameters:
 1384  *   im - The image.
 1385  */
 1386 #define gdImageSY(im) ((im)->sy)
 1387 
 1388 /**
 1389  * Macro: gdImageColorsTotal
 1390  *
 1391  * Gets the number of colors in the palette.
 1392  *
 1393  * This macro is only valid for palette images.
 1394  *
 1395  * Parameters:
 1396  *   im - The image
 1397  */
 1398 #define gdImageColorsTotal(im) ((im)->colorsTotal)
 1399 
 1400 /**
 1401  * Macro: gdImageRed
 1402  *
 1403  * Gets the red component value of a given color.
 1404  *
 1405  * Parameters:
 1406  *   im - The image.
 1407  *   c  - The color.
 1408  */
 1409 #define gdImageRed(im, c) ((im)->trueColor ? gdTrueColorGetRed(c) : \
 1410                (im)->red[(c)])
 1411 
 1412 /**
 1413  * Macro: gdImageGreen
 1414  *
 1415  * Gets the green component value of a given color.
 1416  *
 1417  * Parameters:
 1418  *   im - The image.
 1419  *   c  - The color.
 1420  */
 1421 #define gdImageGreen(im, c) ((im)->trueColor ? gdTrueColorGetGreen(c) : \
 1422                  (im)->green[(c)])
 1423 
 1424 /**
 1425  * Macro: gdImageBlue
 1426  *
 1427  * Gets the blue component value of a given color.
 1428  *
 1429  * Parameters:
 1430  *   im - The image.
 1431  *   c  - The color.
 1432  */
 1433 #define gdImageBlue(im, c) ((im)->trueColor ? gdTrueColorGetBlue(c) : \
 1434                 (im)->blue[(c)])
 1435 
 1436 /**
 1437  * Macro: gdImageAlpha
 1438  *
 1439  * Gets the alpha component value of a given color.
 1440  *
 1441  * Parameters:
 1442  *   im - The image.
 1443  *   c  - The color.
 1444  */
 1445 #define gdImageAlpha(im, c) ((im)->trueColor ? gdTrueColorGetAlpha(c) : \
 1446                  (im)->alpha[(c)])
 1447 
 1448 /**
 1449  * Macro: gdImageGetTransparent
 1450  *
 1451  * Gets the transparent color of the image.
 1452  *
 1453  * Parameters:
 1454  *   im - The image.
 1455  *
 1456  * See also:
 1457  *   - <gdImageColorTransparent>
 1458  */
 1459 #define gdImageGetTransparent(im) ((im)->transparent)
 1460 
 1461 /**
 1462  * Macro: gdImageGetInterlaced
 1463  *
 1464  * Whether an image is interlaced.
 1465  *
 1466  * Parameters:
 1467  *   im - The image.
 1468  *
 1469  * Returns:
 1470  *   Non-zero for interlaced images, zero otherwise.
 1471  *
 1472  * See also:
 1473  *   - <gdImageInterlace>
 1474  */
 1475 #define gdImageGetInterlaced(im) ((im)->interlace)
 1476 
 1477 /**
 1478  * Macro: gdImagePalettePixel
 1479  *
 1480  * Gets the color of a pixel.
 1481  *
 1482  * Calling this macro is only valid for palette images.
 1483  * No bounds checking is done for the coordinates.
 1484  *
 1485  * Parameters:
 1486  *   im - The image.
 1487  *   x  - The x-coordinate.
 1488  *   y  - The y-coordinate.
 1489  *
 1490  * See also:
 1491  *   - <gdImageTrueColorPixel>
 1492  *   - <gdImageGetPixel>
 1493  */
 1494 #define gdImagePalettePixel(im, x, y) (im)->pixels[(y)][(x)]
 1495 
 1496 /**
 1497  * Macro: gdImageTrueColorPixel
 1498  *
 1499  * Gets the color of a pixel.
 1500  *
 1501  * Calling this macro is only valid for truecolor images.
 1502  * No bounds checking is done for the coordinates.
 1503  *
 1504  * Parameters:
 1505  *   im - The image.
 1506  *   x  - The x-coordinate.
 1507  *   y  - The y-coordinate.
 1508  *
 1509  * See also:
 1510  *   - <gdImagePalettePixel>
 1511  *   - <gdImageGetTrueColorPixel>
 1512  */
 1513 #define gdImageTrueColorPixel(im, x, y) (im)->tpixels[(y)][(x)]
 1514 
 1515 /**
 1516  * Macro: gdImageResolutionX
 1517  *
 1518  * Gets the horizontal resolution in DPI.
 1519  *
 1520  * Parameters:
 1521  *   im - The image.
 1522  *
 1523  * See also:
 1524  *   - <gdImageResolutionY>
 1525  *   - <gdImageSetResolution>
 1526  */
 1527 #define gdImageResolutionX(im) (im)->res_x
 1528 
 1529 /**
 1530  * Macro: gdImageResolutionY
 1531  *
 1532  * Gets the vertical resolution in DPI.
 1533  *
 1534  * Parameters:
 1535  *   im - The image.
 1536  *
 1537  * See also:
 1538  *   - <gdImageResolutionX>
 1539  *   - <gdImageSetResolution>
 1540  */
 1541 #define gdImageResolutionY(im) (im)->res_y
 1542 
 1543 /* I/O Support routines. */
 1544 
 1545 BGD_DECLARE(gdIOCtx *) gdNewFileCtx (FILE *);
 1546 /* If data is null, size is ignored and an initial data buffer is
 1547    allocated automatically. NOTE: this function assumes gd has the right
 1548    to free or reallocate "data" at will! Also note that gd will free
 1549    "data" when the IO context is freed. If data is not null, it must point
 1550    to memory allocated with gdMalloc, or by a call to gdImage[something]Ptr.
 1551    If not, see gdNewDynamicCtxEx for an alternative. */
 1552 BGD_DECLARE(gdIOCtx *) gdNewDynamicCtx (int size, void *data);
 1553 /* 2.0.21: if freeFlag is nonzero, gd will free and/or reallocate "data" as
 1554    needed as described above. If freeFlag is zero, gd will never free
 1555    or reallocate "data", which means that the context should only be used
 1556    for *reading* an image from a memory buffer, or writing an image to a
 1557    memory buffer which is already large enough. If the memory buffer is
 1558    not large enough and an image write is attempted, the write operation
 1559    will fail. Those wishing to write an image to a buffer in memory have
 1560    a much simpler alternative in the gdImage[something]Ptr functions. */
 1561 BGD_DECLARE(gdIOCtx *) gdNewDynamicCtxEx (int size, void *data, int freeFlag);
 1562 BGD_DECLARE(gdIOCtx *) gdNewSSCtx (gdSourcePtr in, gdSinkPtr out);
 1563 BGD_DECLARE(void *) gdDPExtractData (struct gdIOCtx *ctx, int *size);
 1564 
 1565 #define GD2_CHUNKSIZE           128
 1566 #define GD2_CHUNKSIZE_MIN   64
 1567 #define GD2_CHUNKSIZE_MAX       4096
 1568 
 1569 #define GD2_VERS                2
 1570 #define GD2_ID                  "gd2"
 1571 
 1572 #define GD2_FMT_RAW             1
 1573 #define GD2_FMT_COMPRESSED      2
 1574 
 1575 /* Image comparison definitions */
 1576 BGD_DECLARE(int) gdImageCompare (gdImagePtr im1, gdImagePtr im2);
 1577 
 1578 BGD_DECLARE(void) gdImageFlipHorizontal(gdImagePtr im);
 1579 BGD_DECLARE(void) gdImageFlipVertical(gdImagePtr im);
 1580 BGD_DECLARE(void) gdImageFlipBoth(gdImagePtr im);
 1581 
 1582 #define GD_FLIP_HORINZONTAL 1 /* typo, kept for BC */
 1583 #define GD_FLIP_HORIZONTAL 1
 1584 #define GD_FLIP_VERTICAL 2
 1585 #define GD_FLIP_BOTH 3
 1586 
 1587 /**
 1588  * Group: Crop
 1589  *
 1590  * Constants: gdCropMode
 1591  *  GD_CROP_DEFAULT     - Same as GD_CROP_TRANSPARENT
 1592  *  GD_CROP_TRANSPARENT - Crop using the transparent color
 1593  *  GD_CROP_BLACK       - Crop black borders
 1594  *  GD_CROP_WHITE       - Crop white borders
 1595  *  GD_CROP_SIDES       - Crop using colors of the 4 corners
 1596  *
 1597  * See also:
 1598  *   - <gdImageCropAuto>
 1599  **/
 1600 enum gdCropMode {
 1601     GD_CROP_DEFAULT = 0,
 1602     GD_CROP_TRANSPARENT,
 1603     GD_CROP_BLACK,
 1604     GD_CROP_WHITE,
 1605     GD_CROP_SIDES,
 1606     GD_CROP_THRESHOLD
 1607 };
 1608 
 1609 BGD_DECLARE(gdImagePtr) gdImageCrop(gdImagePtr src, const gdRect *crop);
 1610 BGD_DECLARE(gdImagePtr) gdImageCropAuto(gdImagePtr im, const unsigned int mode);
 1611 BGD_DECLARE(gdImagePtr) gdImageCropThreshold(gdImagePtr im, const unsigned int color, const float threshold);
 1612 
 1613 BGD_DECLARE(int) gdImageSetInterpolationMethod(gdImagePtr im, gdInterpolationMethod id);
 1614 BGD_DECLARE(gdInterpolationMethod) gdImageGetInterpolationMethod(gdImagePtr im);
 1615 
 1616 BGD_DECLARE(gdImagePtr) gdImageScale(const gdImagePtr src, const unsigned int new_width, const unsigned int new_height);
 1617 
 1618 BGD_DECLARE(gdImagePtr) gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor);
 1619 
 1620 typedef enum {
 1621     GD_AFFINE_TRANSLATE = 0,
 1622     GD_AFFINE_SCALE,
 1623     GD_AFFINE_ROTATE,
 1624     GD_AFFINE_SHEAR_HORIZONTAL,
 1625     GD_AFFINE_SHEAR_VERTICAL
 1626 } gdAffineStandardMatrix;
 1627 
 1628 BGD_DECLARE(int) gdAffineApplyToPointF (gdPointFPtr dst, const gdPointFPtr src, const double affine[6]);
 1629 BGD_DECLARE(int) gdAffineInvert (double dst[6], const double src[6]);
 1630 BGD_DECLARE(int) gdAffineFlip (double dst_affine[6], const double src_affine[6], const int flip_h, const int flip_v);
 1631 BGD_DECLARE(int) gdAffineConcat (double dst[6], const double m1[6], const double m2[6]);
 1632 
 1633 BGD_DECLARE(int) gdAffineIdentity (double dst[6]);
 1634 BGD_DECLARE(int) gdAffineScale (double dst[6], const double scale_x, const double scale_y);
 1635 BGD_DECLARE(int) gdAffineRotate (double dst[6], const double angle);
 1636 BGD_DECLARE(int) gdAffineShearHorizontal (double dst[6], const double angle);
 1637 BGD_DECLARE(int) gdAffineShearVertical(double dst[6], const double angle);
 1638 BGD_DECLARE(int) gdAffineTranslate (double dst[6], const double offset_x, const double offset_y);
 1639 BGD_DECLARE(double) gdAffineExpansion (const double src[6]);
 1640 BGD_DECLARE(int) gdAffineRectilinear (const double src[6]);
 1641 BGD_DECLARE(int) gdAffineEqual (const double matrix1[6], const double matrix2[6]);
 1642 BGD_DECLARE(int) gdTransformAffineGetImage(gdImagePtr *dst, const gdImagePtr src, gdRectPtr src_area, const double affine[6]);
 1643 BGD_DECLARE(int) gdTransformAffineCopy(gdImagePtr dst, int dst_x, int dst_y, const gdImagePtr src, gdRectPtr src_region, const double affine[6]);
 1644 /*
 1645 gdTransformAffineCopy(gdImagePtr dst, int x0, int y0, int x1, int y1,
 1646               const gdImagePtr src, int src_width, int src_height,
 1647               const double affine[6]);
 1648 */
 1649 BGD_DECLARE(int) gdTransformAffineBoundingBox(gdRectPtr src, const double affine[6], gdRectPtr bbox);
 1650 
 1651 /**
 1652  * Group: Image Comparison
 1653  *
 1654  * Constants:
 1655  *   GD_CMP_IMAGE       - Actual image IS different
 1656  *   GD_CMP_NUM_COLORS  - Number of colors in pallette differ
 1657  *   GD_CMP_COLOR       - Image colors differ
 1658  *   GD_CMP_SIZE_X      - Image width differs
 1659  *   GD_CMP_SIZE_Y      - Image heights differ
 1660  *   GD_CMP_TRANSPARENT - Transparent color differs
 1661  *   GD_CMP_BACKGROUND  - Background color differs
 1662  *   GD_CMP_INTERLACE   - Interlaced setting differs
 1663  *   GD_CMP_TRUECOLOR   - Truecolor vs palette differs
 1664  *
 1665  * See also:
 1666  *   - <gdImageCompare>
 1667  */
 1668 #define GD_CMP_IMAGE        1
 1669 #define GD_CMP_NUM_COLORS   2
 1670 #define GD_CMP_COLOR        4
 1671 #define GD_CMP_SIZE_X       8
 1672 #define GD_CMP_SIZE_Y       16
 1673 #define GD_CMP_TRANSPARENT  32
 1674 #define GD_CMP_BACKGROUND   64
 1675 #define GD_CMP_INTERLACE    128
 1676 #define GD_CMP_TRUECOLOR    256
 1677 
 1678 /* resolution affects ttf font rendering, particularly hinting */
 1679 #define GD_RESOLUTION           96      /* pixels per inch */
 1680 
 1681 
 1682 /* Version information functions */
 1683 BGD_DECLARE(int) gdMajorVersion(void);
 1684 BGD_DECLARE(int) gdMinorVersion(void);
 1685 BGD_DECLARE(int) gdReleaseVersion(void);
 1686 BGD_DECLARE(const char *) gdExtraVersion(void);
 1687 BGD_DECLARE(const char *) gdVersionString(void);
 1688 
 1689 /* newfangled special effects */
 1690 #include "gdfx.h"
 1691 
 1692 #ifdef __cplusplus
 1693 }
 1694 #endif
 1695 
 1696 #endif              /* GD_H */