comparison toolboxes/graph_visualisation/share/graphviz/doc/html/gd.html @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 <!-- REMEMBER TO EDIT index.html.source -->
2 <head>
3 <TITLE>gd 2.0.34</TITLE>
4 </head>
5 <body bgcolor="#FFFFFF">
6 <!-- BANNER HERE -->
7 <H2>gd 2.0.33</H2>
8 <H3>A graphics library for fast image creation</H3>
9 <H3>Follow this link to the
10 <A HREF="http://libgd.org">latest version
11 of this document</A>.</H3>
12 <blockquote>
13 <strong>UPGRADING UNIX USERS: READ THIS FIRST!</strong>
14 Modern versions of gd install by default to /usr/local/lib and
15 /usr/local/include. If you already have an older version of gd
16 in /usr/lib and /usr/include, you may wish to use:
17 <pre>
18 ./configure --prefix=/usr</pre>
19 To ensure that your
20 new installation overwrites the old.
21 <p>
22 <strong>GIF support has been restored in gd 2.0.28 and above.</strong>
23 The well-known patents on LZW compression held by Unisys
24 have expired in all countries. British Telecom and IBM may hold related
25 patents but have never chosen to require royalties for GIF applications,
26 to the best of my knowledge. I am not a lawyer and cannot give
27 legal advice regarding this issue. PNG remains a superior format especially
28 if lossless truecolor images are needed.
29 <p>
30 When building from soruce, gd 2.0.33 <strong>requires</strong> that the
31 following libraries also be installed, in order to produce the related
32 image formats. The win32 binary release (bgd) already contains the
33 appropriate libraries.
34 You may skip libraries associated with formats you do not use:
35 <p>
36 libpng (see the <a href="http://www.libpng.org/pub/png/">libpng home page</a>), if you want PNG
37 <p>
38 zlib (see the <a href="http://www.info-zip.org/pub/infozip/zlib/">info-zip home page</a>), if you want PNG
39 <p>
40 jpeg-6b or later, if desired (see the <a href="http://www.ijg.org/">Independent JPEG Group home page</a>), if you want JPEG
41 <p>
42 If you want to use the TrueType font support, you must also
43 install the <strong>FreeType 2.x library</strong>, including
44 the header files. See the <a href="http://www.freetype.org/">Freetype
45 Home Page</a>, or <a href="http://freetype.sourceforge.net/">SourceForge</a>.
46 No, I cannot explain why that site is down on a particular day, and no, I
47 can't send you a copy.
48 <p>
49 If you want to use the Xpm color bitmap loading support, you must also
50 have the X Window System and the Xpm library installed (Xpm is often
51 included in modern X distributions). Most of the time you won't
52 need Xpm.
53 <p>
54 Please read the documentation and install the required libraries.
55 Do not send email asking why <code>png.h</code> is not found.
56 Do not send email asking why <code>libgd.so</code> is not found, either.
57 See the <a href="#required">requirements section</a> for more
58 information. Thank you!
59 </blockquote>
60 <H3>Table of Contents</H3>
61 <UL>
62 <LI><A HREF="#notice">Credits and license terms</A>
63 <LI><A HREF="#whatsnew2.0.34">What's new in version "XYZ" of GD?</A>
64 <LI><A HREF="#whatis">What is gd?</A>
65 <LI><A HREF="#gdother">What if I want to use another programming language?</A>
66 <LI><A HREF="#required">What else do I need to use gd?</A>
67 <LI><A HREF="#getgd">How do I get gd?</A>
68 <LI><A HREF="#buildgd">How do I build gd?</A>
69 <LI><A HREF="#basics">gd basics: using gd in your program</A>
70 <LI><A HREF="#webpng">webpng: a useful example</A>
71 <LI><A HREF="#reference">Function and type reference by category</A>
72 <LI><A HREF="#gdformat">About the additional .gd image file format</A>
73 <LI><A HREF="#informing"><strong>Please</strong>
74 tell us you're using gd!</A>
75 <LI><A HREF="#support">How do I get support?</A>
76 <LI><A HREF="#issues">How do I report issues, bugs or features request?</A>
77 <LI><A HREF="#index">Alphabetical quick index</A>
78 </UL>
79 <P><A HREF="http://www.libgd.org/">
80 Up to the <EM>LibGD Homepage</EM></A>
81 <A NAME="notice"><H3>Credits and license terms</A></H3>
82 <P>
83 In order to resolve any possible confusion regarding the authorship
84 of gd, the following copyright statement covers all of the authors
85 who have required such a statement. <strong>If you are aware of any oversights
86 in this copyright notice, please contact <A HREF="http://libgd.org/Contact">Pierre-A. Joye</A> who will be
87 pleased to correct them.</strong>
88 <pre>
89 COPYRIGHT STATEMENT FOLLOWS THIS LINE
90 </pre>
91 <blockquote>
92
93 Portions copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 by Cold Spring
94 Harbor Laboratory. Funded under Grant P41-RR02188 by the National
95 Institutes of Health.
96 <P>
97 Portions copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 by Boutell.Com, Inc.
98 <p>
99 Portions relating to GD2 format copyright 1999, 2000, 2001, 2002, 2003, 2004 Philip Warner.
100 <p>
101 Portions relating to PNG copyright 1999, 2000, 2001, 2002, 2003, 2004 Greg Roelofs.
102 <p>
103 Portions relating to gdttf.c copyright 1999, 2000, 2001, 2002, 2003, 2004 John Ellson (ellson@graphviz.org).
104 <p>
105 Portions relating to gdft.c copyright 2001, 2002, 2003, 2004 John Ellson (ellson@graphviz.org).
106 <p>
107 Portions copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Pierre-Alain Joye (pierre@libgd.org).
108
109 <p>
110 Portions relating to JPEG and to color quantization copyright 2000, 2001, 2002, 2003, 2004, Doug Becker and copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Thomas G. Lane. This software is based
111 in part on the work of the Independent JPEG Group. See the file
112 README-JPEG.TXT for more information.
113 <p>
114 Portions relating to GIF compression copyright 1989 by Jef
115 Poskanzer and David Rowley, with modifications for thread safety
116 by Thomas Boutell.
117 <p>
118 Portions relating to GIF decompression copyright 1990, 1991, 1993
119 by David Koblas, with modifications for thread safety by
120 Thomas Boutell.
121 <p>
122 Portions relating to WBMP copyright 2000, 2001, 2002, 2003, 2004 Maurice Szmurlo and Johan Van
123 den Brande.
124 <p>
125 Portions relating to GIF animations copyright 2004 Jaakko Hyv&auml;tti (jaakko.hyvatti@iki.fi)
126 <p>
127 <strong>Permission has been granted to copy, distribute and modify gd in any
128 context without fee, including a commercial application, provided that this notice
129 is present in user-accessible supporting documentation.</strong>
130 <p>
131 This does not affect your ownership of the derived work itself, and the intent
132 is to assure proper credit for the authors of gd, not to interfere
133 with your productive use of gd. If you have questions, ask.
134 "Derived works" includes all programs that utilize the library.
135 Credit must be given in user-accessible documentation.
136 <p>
137 <strong>This software is provided "AS IS."</strong>
138 The copyright holders disclaim all warranties, either express or implied,
139 including but not limited to implied warranties of merchantability and
140 fitness for a particular purpose, with respect to this code and accompanying
141 documentation.
142 <p>
143 Although their code does not appear in the current release, the authors
144 also wish to thank Hutchison Avenue Software Corporation for their
145 prior contributions.
146 </blockquote>
147 <pre>
148 END OF COPYRIGHT STATEMENT
149 </pre>
150 <A NAME="whatis"><H3>What is gd?</H3></A>
151 <P>
152 gd is a graphics library. It allows your code to quickly
153 draw images complete with lines, arcs, text, multiple
154 colors, cut and paste from other images, and flood fills, and
155 write out the result as a PNG or JPEG file. This is particularly
156 useful in World Wide Web applications, where PNG and JPEG are two
157 of the formats accepted for inline images by most browsers.
158 <P>
159 gd is not a paint program.
160 If you are looking for a paint program, you are looking in
161 the wrong place. If you are not a programmer, you are looking
162 in the wrong place, unless you are installing a required
163 library in order to run an application.
164 <P>
165 gd does not provide for every possible desirable graphics
166 operation. It is not necessary or desirable for gd to become
167 a kitchen-sink graphics package, but version 2.0 does include
168 most frequently requested features, including both truecolor and
169 palette images, resampling (smooth resizing of truecolor images)
170 and so forth.
171 <P>
172 <A NAME="gdother"><H3>What if I want to use another programming
173 language?</h3></A>
174 Not all of these tools are necessarily up to date and fully compatible
175 with 2.0.33.
176 <h4>PHP</h4>
177 A variant of gd 2.x is included in PHP 4.3.0. It is also possible
178 to patch PHP 4.2.3 for use with gd 2.0.33; see the
179 <a href="http://www.libgd.org/">gd home page</a> for a link to
180 that information. It would be a Good Idea to merge all of the things
181 that are better in mainstream gd and all of the things that are
182 better in PHP gd at some point in the near future.
183 <h4>Perl</h4>
184 gd can also be used from Perl, courtesy of
185 Lincoln Stein's
186 <a href="http://stein.cshl.org/WWW/software/GD/">
187 GD.pm</a> library, which uses gd as the basis for a set of
188 Perl 5.x classes. Highly recommended.
189 <h4>OCaml</h4>
190 gd can be used from OCaml, thanks to
191 <a href="http://gd4o.sourceforge.net/">Matt Gushee's GD4O project</a>.
192 <h4>Tcl</h4>
193 gd can be used from Tcl with John Ellson's
194 <a href=http://www.graphviz.org/pub/>Gdtclft</a>
195 dynamically loaded extension package.
196 <h4>Pascal</h4>
197 Pascal enthusiasts should look into the
198 <a href="http://www.freepascal.org/">freepascal</a> project, a
199 free Pascal compiler that includes gd support.
200 <h4>REXX</h4>
201 A
202 <a href="http://www.lightlink.com/hessling/RexxGd/index.html">gd interface
203 for the REXX language</a> is available.
204 <h4>Any Language</h4>
205 The "fly" interpreter performs gd operations specified in a text file.
206 You can output the desired commands to a simple
207 text file from whatever scripting language you prefer to use, then
208 invoke the interpreter.
209 <p>
210 <ul>
211 <li><a href="http://martin.gleeson.com/fly/">fly</a>, by Martin Gleeson
212 </ul>
213 <p>
214 <A NAME="whatsnew2.0.34"><h3>What's new in version 2.0.34?</h3></a>
215 <p>
216 From 2.0.34 and later, please check the ISSUES and ChangeLog as well as
217 the releases announcements.
218 <p>
219 <A NAME="whatsnew2.0.33"><h3>What's new in version 2.0.33?</h3></a>
220 <p>
221 Version 2.0.33 restores compatibility with older releases
222 of Freetype 2.x in addition to the latest release. Thanks to
223 John Ellson and the graphviz project.
224 <p>
225 <A NAME="whatsnew2.0.32"><h3>What's new in version 2.0.32?</h3></a>
226 <p>
227 Version 2.0.32 restores correct detection of Unicode character sets
228 for freetype fonts, which repairs a bug that prevented umlauts from
229 displaying properly. Thanks to John Ellson and the graphviz project.
230 Also, version 2.0.32 builds all test programs
231 smoothly in the absence of libpng.
232 <p>
233 <A NAME="whatsnew2.0.31"><h3>What's new in version 2.0.31?</h3></a>
234 <p>
235 A minor type naming conflict prevented bgd.dll from compiling, and it
236 was left out of the distribution as a result. This has been corrected.
237 <p>
238 <A NAME="whatsnew2.0.30"><h3>What's new in version 2.0.30?</h3></a>
239 <p>
240 2.0.29 did not compile correctly when freetype was not available.
241 This has been corrected. Thanks to Alessandro Ranellucci.
242 <p>
243 <A NAME="whatsnew2.0.29"><h3>What's new in version 2.0.29?</h3></a>
244 <p>
245 <ul>
246 <li>A 32-bit multiplication overflow vulnerability reported on
247 the Bugtraq mailing list has been corrected, along with a number
248 of similar issues. These bugs come into play only when attempting
249 to deal with images with <i>extremely large</i> dimensions.
250 The relevant functions now fail gracefully when such extreme
251 parameters are specified. The code in question is also
252 correct for systems with larger bit depths. Thanks to Phil Knirsch,
253 Alan Cox and infamous41md.
254 Since exploits are theoretically possible, upgrading is recommended.
255 <li>Support for the fontconfig library, when available.
256 When fontconfig is available and gdFTUseFontConfig(1) has been invoked
257 or the gdFTEX_FONTCONFIG flag has been set for a particular call, fontconfig
258 patterns can be used to fetch the best available font.
259 For instance, "arial:bold:italic" does the right thing (or as close as
260 the available fonts permit). Also, standard
261 PostScript font names can be mapped to an appropriate font by
262 gdImageStringFTEx and relatives.
263 When fontconfig is available <tt>gdlib-config --features</tt> will list
264 the GD_FONTCONFIG feature. For more information about fontconfig, see the
265 <a href="http://freedesktop.org/software/fontconfig">fontconfig pages</a>.
266 <p>
267 The actual resolved font filename can be returned in the gdFTStringExtra
268 structure as the fontpath element if the gdFTEX_RETURNFONTPATHNAME flag
269 is set. Also, a
270 vector of character position advances can be retrieved if gdFTEX_XSHOW is set
271 in the flags element. .afm files (font metrics) are now used to adjust size
272 calculations
273 when available. When fontconfig is not available, gd falls back to its
274 usual behavior and requires a specific font file name. One can
275 still fetch fonts by filename when gdFTUseFontConfig(1) is in effect, by
276 setting the gdFTEX_FONTPATHNAME flag
277 in the flag element of the gdFTStringExtra structure. Thanks to
278 Dag Lem and John Ellson.
279 <li>Additional freetype fixes: fixed width fonts are now the right
280 size, horizontal advance calculations now better match the
281 PostScript equivalent, and various compiler warning fixes. Also,
282 a fix to the encoding table selection in the was made, addressing a problem
283 with latin1 font encodings. Thanks to Dag Lem and John Ellson.
284 <li>Improved tolerance when reading JPEG files containing some garbage as well
285 as valid image data.
286 <li>Easier compilation on Windows: no errno.h in gd_gd2.c.
287 <li>Support for creating optimized GIF animations has been added
288 by Jaakko Hyv&auml;tti. See
289 <A HREF="#gdImageGifAnimAdd">gdImageGifAnimAdd</A>,
290 <A HREF="#gdImageGifAnimAddCtx">gdImageGifAnimAddCtx</A>,
291 <A HREF="#gdImageGifAnimAddPtr">gdImageGifAnimAddPtr</A>,
292 <A HREF="#gdImageGifAnimBegin">gdImageGifAnimBegin</A>,
293 <A HREF="#gdImageGifAnimBeginCtx">gdImageGifAnimBeginCtx</A>,
294 <A HREF="#gdImageGifAnimBeginPtr">gdImageGifAnimBeginPtr</A>,
295 <A HREF="#gdImageGifAnimEnd">gdImageGifAnimEnd</A>,
296 <A HREF="#gdImageGifAnimEndCtx">gdImageGifAnimEndCtx</A>, and
297 <A HREF="#gdImageGifAnimEndPtr">gdImageGifAnimEndPtr</A>.
298 <li><A HREF="#gdImageOpenPolygon">gdImageOpenPolygon</A> has been
299 added to allow consecutive line segments to be drawn without
300 connecting the end points to form a closed polygon. Thanks to
301 Jaakko Hyv&auml;tti.
302 <li>Better alpha channel blending when the destination color
303 contains an alpha channel. Also, quicker handling of the
304 most common cases. Thanks to Frank Warmerdam.
305 </ul>
306 <P>
307 <A NAME="whatsnew2.0.28"><H3>What's new in version 2.0.28?</H3></A>
308 <P>
309 <ul>
310 <li>GIF support has been restored. See
311 <a href="#gdImageGif">gdImageGif</a>,
312 <a href="#gdImageGifCtx">gdImageGifCtx</a>,
313 <a href="#gdImageGifPtr">gdImageGifPtr</a>,
314 <a href="#gdImageCreateFromGif">gdImageCreateFromGif</a>,
315 <a href="#gdImageCreateFromGifCtx">gdImageCreateFromGifCtx</a>,
316 and <a href="#gdImageCreateFromGifPtr">gdImageCreateFromGifPtr</a>.
317 These functions are now thread-safe, similar to the PNG and JPEG
318 manipulation functions.
319 <li>The new <a href="#gdImageCreatePaletteFromTrueColor">gdImageCreatePaletteFromTrueColor</a> function is identical to <a href="#gdImageTrueColorToPalette">gdImageTrueColorToPalette</a>, except that it returns a new image rather than permanently modifying the original.
320 </ul>
321 <P>
322 <A NAME="whatsnew2.0.27"><H3>What's new in version 2.0.27?</H3></A>
323 <P>
324 <ul>
325 <li>In gd 2.0.26, there was potential for out of bounds fills, and therefore
326 crashes, in the horizontalLine function used by gdImageFilledPolygon.
327 Fixed by John Ellson.
328 <li>The order of the points returned in the bounding rectangle by
329 gdImageStringFT was incorrect in version 2.0.26. This has been
330 corrected in version 2.0.27. Thanks to Riccardo Cohen for pointing
331 this out, and to John Ellson for verifying and fixing it.
332 </ul>
333 <P>
334 <A NAME="whatsnew2.0.26"><H3>What's new in version 2.0.26?</H3></A>
335 <P>
336 The following enhancements and fixes:
337 <ul>
338 <li>Drastically faster, less memory-intensive antialiased drawing, thanks to
339 Pierre-Alain Joye. This code was imported from the PHP "fork"
340 of gd. The API for antialiased drawing has not changed, however the
341 implementation has been completely replaced.
342 Antialiased line drawing does not support widths other
343 than 1, however this did not work properly with the other
344 implementation of antialiasing either. Support has been included
345 for the "non-blending color" option introduced by the previous
346 implementation of antialiased drawing.
347 <li><code>gdlib-config</code>, which has been installed by
348 <code>make install</code> for some time now, has gained
349 a <code>--features</code> option. This option produces a space-separated
350 list of optional features with which the gd library was compiled.
351 Typical usage looks like this:
352 <pre>
353 % gdlib-config --features
354 GD_XPM GD_JPEG GD_FREETYPE GD_PNG GD_GIF
355 </pre>
356 Other <code>configure</code> scripts can conveniently define
357 preprocessor symbols based on this list in order to conditionally
358 compile code. For instance, if
359 GD_PNG is not reported by --features, then gdImagePng is not
360 included in the library.
361 <p>
362 Thanks to Lars Hecking and Lincoln Stein for their advice on
363 implementing this feature. Any blame for the actual implementation
364 is entirely due to me (TBB).
365 <li>Fixes to the behavior of the bounding rectangle returned by
366 gdImageStringFT and relatives when the string is rotated.
367 See fontwheeltest.c. Thanks to John Ellson.
368 <li>Previously, gdImageStringFT and friends accepted either
369 a full path to a font file, or the name of a font with no
370 extension, in which case the GDFONTPATH environment variable
371 and then the compiled-in DEFAULT_FONTPATH was searched. In addition,
372 a font filename with an extension but no full path can now be
373 automatically searched for in the same fashion. Thanks to John Ellson.
374
375 <li>Fixes to freetype antialiased text against a transparent
376 background. See testtr.c. Thanks to John Ellson.
377
378 <li>Support for named entities like &amp;amp; and hex-coded
379 entities such as &amp;#x6C34; in text
380 strings passed to gdImageStringFT and relatives, adding to the
381 previous support for decimal-coded entities like &amp;#197;.
382 These were extracted from entities.html (from the W3C) via
383 the script entities.tcl, which is included for the curious and
384 those with other entities they need support for. Thanks to John Ellson.
385
386 <li>Optimization: gdImageSetPixel no longer calls gdImageAlphaBlend
387 when either the source or the destination pixel is 100% transparent.
388 Thanks to John Ellson.
389
390 <li>Optimization: gdImageLine is potentially faster now in the most
391 common cases.
392 Thanks to John Ellson.
393 <li>Documentation of the entities feature of gdImageStringFT.
394 <li>autoconf/configure fixes. Thanks to many who pointed out an oversight
395 in handling libpng flags.
396 </ul>
397 <P>
398 <A NAME="whatsnew2.0.25"><H3>What's new in version 2.0.25?</H3></A>
399 <P>
400 Owing to an oversight while making changes to better accommodate the use
401 of gd as a DLL, the <b>extern</b> qualifier was dropped from the
402 declarations of font pointers in 2.0.24. This has been corrected.
403 Thanks to Richard ("OpenMacNews").
404 <P>
405 <A NAME="whatsnew2.0.24"><H3>What's new in version 2.0.24?</H3></A>
406 <P>
407 <b>Windows DLL now uses __stdcall calling convention.</b> Existing
408 applications will require a recompile, using the new version of gd.h,
409 in order to use this version of the DLL. However, Visual BASIC and other
410 non-C programmers will now be able to use the DLL, which is an enormous
411 benefit and justifies the one-time inconvenience to existing DLL users.
412 <p>
413 The elaborate #ifdef test for older versions of Freetype without
414 FT_ENCODING_MS_SYMBOL was needed in a second place also. Thanks to
415 David R. Morrison.
416 <p>
417 An off-by-one error in gdImageToPalette caused transparency to be applied
418 to the wrong pixels. Thanks to "Super Pikeman."
419 <P>
420 <A NAME="whatsnew2.0.23"><H3>What's new in version 2.0.23?</H3></A>
421 <P>
422 Output dpi specification option added to the
423 <code>gdFTStringExtra</code> structure, thanks to
424 Mark Shackelford. See <a href="#gdImageStringFTEx">gdImageStringFTEx</a>.
425 <P>
426 <A NAME="whatsnew2.0.22"><H3>What's new in version 2.0.22?</H3></A>
427 <P>
428 <ul>
429 <li>Win32 DLL users: working with pointers exported by DLLs is
430 difficult and causes unexpected results. gd 2.0.22 exports new
431 functions for retrieving the basic gd fonts:
432 <a href="#gdFontGetTiny">gdFontGetTiny()</a>,
433 <a href="#gdFontGetSmall">gdFontGetSmall()</a>,
434 <a href="#gdFontGetMediumBold">gdFontGetMediumBold()</a>,
435 <a href="#gdFontGetLarge">gdFontGetLarge()</a>, and
436 <a href="#gdFontGetHuge">gdFontGetHuge()</a>. You may safely assign the
437 return values from these functions to a local <code>gdFontPtr</code>.
438 Direct use of <code>gdFontLarge</code>, etc. is strongly deprecated
439 for users of <code>bgd.dll</code>; use these new functions instead.
440 <li>Basic support for loading CMYK-colorspace JPEG images. They are
441 of course converted to RGB which is a lossy process, however the
442 results do look quite good and are certainly fine for thumbnails and
443 web previews of DTP work.
444 <li>"make" no longer fails on <code>circletexttest</code> if
445 PNG support is missing.
446 <li>Small performance improvements to gdImageCopyResampled; larger
447 improvements are forthcoming.
448 </ul>
449 <P>
450 <A NAME="whatsnew2.0.21"><H3>What's new in version 2.0.21?</H3></A>
451 <P>
452 <ul>
453 <li>Version 2.0.21 adds a <code>gdImageCreateFrom*Ptr</code> family
454 of functions which make it convenient to load an image in any
455 GD-supported format directly from memory.
456 <li>The new <code>gdNewDynamicCtxEx</code> function was added to
457 support the easy implementation of the above functions and to
458 correct a design problem which made life unpleasant for those passing
459 in memory not originally allocated by gd to the
460 <code>gdNewDynamicCtx</code> function by provoding a way to specify
461 that gd should never free or reallocate a particular block of memory.
462 The <code>gdNewDynamicCtx</code> function and its relatives, although
463 still exported for ABI compatibility, are now <b>deprecated</b> except
464 for internal use, in favor of <a href="#gdImageCreateFromPngPtr"><code>gdImageCreateFromPngPtr</code></a>
465 and its relatives.
466 <li>Version 2.0.21 includes a new patch from Ethan A. Merritt to
467 correct a bug in the conditional compilation of support for
468 symbol fonts in gdft.c. Symbol fonts should now work correctly.
469 Thanks to Mr. Merritt.
470 <li>Version 2.0.20 restores the <code>gdFreeFontCache</code> function,
471 an undocumented function added in an earlier release which now simply
472 calls <code>gdFontCacheShutdown</code> for backwards compatibility.
473 This repairs build problems when compiling PHP against the latest gd.
474 <li>Documentation improvements.
475 </ul>
476 <P>
477 <A NAME="whatsnew2.0.20"><H3>What's new in version 2.0.20?</H3></A>
478 <P>
479 <ul>
480 <li>Version 2.0.20 restores the <code>gdFreeFontCache</code> function,
481 an undocumented function added in an earlier release which now simply
482 calls <code>gdFontCacheShutdown</code> for backwards compatibility.
483 This repairs build problems when compiling PHP against the latest gd.
484 </ul>
485 <P>
486 <A NAME="whatsnew2.0.19"><H3>What's new in version 2.0.19?</H3></A>
487 <P>
488 <ul>
489 <li>Version 2.0.19 restored <code>extern</code> declarations for the
490 gd font pointers inadvertently removed in 2.0.18.
491 </ul>
492 <P>
493 <A NAME="whatsnew2.0.18"><H3>What's new in version 2.0.18?</H3></A>
494 <P>
495 <ul>
496 <li>A Win32 binary distribution of "bgd.dll," built with mingw32 and
497 tested with win32 versions of the demo programs as console applications,
498 is now available.
499 <li>Semicolon rather than space used as the default separator of
500 alternative font file paths in <a href="#gdImageStringFT">gdImageStringFT</a>,
501 for better compatibility with Windows and other environments where
502 spaces are common in paths.
503 <li>The circletexttest demo no longer fails to compile when JPEG
504 support happens to be absent.
505 </ul>
506 <P>
507 <A NAME="whatsnew2.0.17"><H3>What's new in version 2.0.17?</H3></A>
508 <P>
509 Minor compilation and packaging problems with 2.0.16 were corrected.
510 If 2.0.16 compiled without errors for you, then you don't need
511 to upgrade to 2.0.17.
512 <P>
513 <A NAME="whatsnew2.0.16"><H3>What's new in version 2.0.16?</H3></A>
514 <P>
515 <ul>
516 <li>Thread safety for freetype text output. Background: all gd functions
517 were already thread safe, as long as only one thread manipulates each
518 image -- except for gdImageStringFT and gdImageStringFTEx. This is because
519 of a shared freetype font cache. Sharing the cache between images
520 is worthwhile, so "configure" now detects pthreads and uses it to
521 wrap freetype text output in a critical section if available. There is
522 also critical section support under WIN32. Those who wish to be
523 strictly thread-safe should call the new function
524 <a href="#gdFontCacheSetup">gdFontCacheSetup</a> before allowing any
525 thread to use freetype text calls. Otherwise this function is automatically
526 invoked on the first use of freetype, with a very small but real chance
527 of a race condition.
528 <li><a href="#gdImageSquareToCircle">gdImageSquareToCircle</a> performs
529 a "polar coordinate transform," returning a new image in which the
530 X axis of the original has been remapped to theta (angle) and the
531 Y axis of the original has been remapped to rho (distance from center).
532 <li><a href="#gdImageStringFTCircle">gdImageStringFTCircle</a> wraps
533 text in a circle around a specified center point. This function
534 takes advantage of <a href="#gdImageSquareToCircle">gdImageSquareToCircle</a>.
535 The result is very smooth, although it takes some time to compute.
536 Thanks to Steve Bassi for sponsoring this work.
537 <li><a href="#gdImageSharpen">gdImageSharpen</a>, contributed by
538 Paul Troughton. Thank you.
539 <li>Christophe Thomas corrected gdft.c to include freetype header
540 files in the way that is now mandatory in freetype 2.1.6 and above.
541 <li>Gustavo Scotti fixed a memory leak in gdft.c.
542 <li>Clipping rectangle respected in freetype text output. Thanks to Matt
543 McNabb.
544 <li>Paul den Dulk found a degenerate case that crashes
545 gdImageToPalette. Fixed.
546 <li>Optimization by Ilia Chipitsine to avoid wasting time with
547 offscreen scanlines during polygon rasterization.
548 <li>Optimized PNG saving by Phong Tran. Speeds up saves a
549 little bit.
550 <li>Bug in gdImageCopyResized fixed by Mao Morimoto.
551 </ul>
552 <P>
553 <A NAME="whatsnew2.0.15"><H3>What's new in version 2.0.15?</H3></A>
554 <P>
555 <ul>
556 <li>gd.c in 2.0.14 contained an instance of declaring variables
557 after the first line of executable code appears. This is of course
558 not allowed by ANSI C, although many compilers accept it.
559 My apologies. Thanks to Jeff Vendetti for reporting this quickly.
560 </ul>
561 <P>
562 <A NAME="whatsnew2.0.14"><H3>What's new in version 2.0.14?</H3></A>
563 <P>
564 <ul>
565 <li>2.0.13 was available for mere minutes due to a typo
566 in the new bounds-checking code for antialiased line drawing. Fixed.
567 <li>Not all platforms -- notably msys/mingw -- have an ssize_t type.
568 We now call an int an int in gd_jpeg.c, with good results.
569 (Note: ssize_t is signed, unlike size_t, and it needs to be here.)
570 </ul>
571 <P>
572 <A NAME="whatsnew2.0.13"><H3>What's new in version 2.0.13?</H3></A>
573 <P>
574 <ul>
575 <li>The <code>main()</code> function of one of the test programs
576 was accidentally included in the gd shared library, causing problems
577 on some platforms. This has been corrected. Thanks to many people
578 who pointed this out.
579 <li>The antialiased drawing functions now have proper bounds
580 checking. Thanks to Arne Jorgensen.
581 <li>A void function returned a value in gd_png.c, causing warnings
582 and, on some platforms, compilation errors but no reported runtime problems.
583 Thanks to Kevin Smith, among others.
584 <li>Autohinting was being forced ON for freetype text output. This is
585 apparently meant only for testing freetype and does not look as good
586 as the default behavior (FT_LOAD_DEFAULT). Thanks to Bob Ostermann.
587 <li>penf.x is properly reset when newlines are encountered in freetype
588 text output. Thanks to Christopher J. Grayce.
589 </ul>
590 <P>
591 <A NAME="whatsnew2.0.12"><H3>What's new in version 2.0.12?</H3></A>
592 <P>
593 <ul>
594 <li>Small but numerous code cleanups by Dr. Martin Zinser.
595 <li><a href="#gdImageSetClip">gdImageSetClip</a> and
596 <a href="#gdImageGetClip">gdImageGetClip</a> have been added. All
597 drawing routines now stay within the specified clipping rectangle.
598 Note that the <a href="#gdImageBoundsSafe">gdImageBoundsSafe</a> function
599 now returns true only if the specified location is within the
600 clipping rectangle. Of course, the default clipping area is the
601 entire image. The behavior of existing gd applications does not change.
602 <li>Support for fast drawing of antialiased lines and polygons,
603 by Bright Fulton and Frank Faubert. To learn more about this feature,
604 read about the <a href="#gdImageSetAntiAliased">gdImageSetAntiAliased</a>
605 function, which is used to set the foreground color for antialiasing,
606 as well as the <a href="#gdAntiAliased">gdAntiAliased</a> constant, which
607 is passed to line- and polygon-drawing functions in place of a color.
608 This code does not currently support an alpha channel component in the
609 specified foreground color, or in the existing background image,
610 but <em>does</em> perform alpha blending against an opaque background.
611 Also see the
612 <a href="#gdImageSetAntiAliasedDontBlend">gdImageSetAntiAliasedDontBlend</a>
613 function, which allows the specification of a special background
614 color that should never be blended with the foreground.
615 <li>Fixes to color mapping in <a href="#gdImageCopyMergeGray">gdImageCopyMergeGray</a>. Thanks to Philip Warner.
616 <li><a href="#gdImageStringFTEx">gdImageStringFTEx</a> now supports
617 explicit specification of the desired character mapping.
618 This is useful when a font offers more than one of Unicode,
619 Shift_JIS, and Big5.
620 <li>The PNG compression level can now be specified when writing PNG
621 images. See the new <a href="#gdImagePngEx">gdImagePngEx</a>,
622 <a href="#gdImagePngEx">gdImagePngEx</a>,
623 <a href="#gdImagePngCtxEx">gdImagePngCtxEx</a>, and
624 <a href="#gdImagePngPtrEx">gdImagePngPtrEx</a> functions.
625 <li>The annotate utility builds without error in the absence of
626 freetype, although of course it is not useful without freetype.
627 <li>Thorben Kundinger fixed a bug relating to the use of palette-based
628 images as brushes when drawing on truecolor images.
629 <li>Michael Schwartz corrected a problem with his code for drawing
630 thick lines.
631 <li>Prior to 2.0.12, any alpha channel component in the
632 <em>destination</em> image was ignored when drawing with
633 alpha blending in effect (see
634 <a href="#gdImageAlphaBlending">gdImageAlphaBlending</a>). 2.0.12
635 correctly preserves an appropriate proportion of the alpha component
636 of the destination, just as it preserves an appropriate proportion
637 of the red, green and blue components, depending on the opacity
638 of the foreground. Thanks to Frank Warmerdam for pointing out the issue.
639 <li>Memory leaks on failed attempts to load fonts
640 in <a href="#gdImageStringFTEx">gdImageStringFTEx</a> were corrected.
641 Thanks to Frank Faubert.
642 <li>The impact of kerning is now correctly included in the calculation
643 of the bounding box returned by the freetype text routines. This issue
644 was pointed out by several individuals.
645 <li>Color problems with the <code>gd2</code> file format routines
646 were fixed by Steven Brown. These problems were due to the
647 incorrect use of a signed integer.
648 <li>Version 2.0.12 supports the <code>gd</code> file format correctly
649 for truecolor images. Truecolor <code>gd</code> files created with
650 earlier releases in the 2.0 series must be written again. The <code>gd</code>
651 file format is used to quickly load an entire uncompressed image, typically
652 an existing background to which additional material will be added; it is not a
653 general purpose file format. More advanced capabilities are also available
654 via the <code>gd2</code> format. Thanks to Andreas Pfaller for reporting
655 the problem.
656 <li>Signed vs. unsigned problem caused misbehavior when attempting to
657 load a bad JPEG image. Thanks to Geert Jansen.
658 <li>Existing truecolor PNG images with simple single-color transparency are
659 now loaded properly, thanks to Slaven Rezic.
660 <li>The <a href="#gdImageTrueColorToPalette">gdImageTrueColorToPalette</a>
661 function no longer attempts to preserve an alpha channel in the original.
662 My attempt to do so resulted in significantly inferior output even if no
663 alpha channel was present in the original. Thanks to Barend Gehrels for
664 submitting a new adaptation of Tom Lane's jquant2.c which does a very
665 high-quality job of palette conversion. Thanks also to Steven Brown, who
666 submitted patches allowing a single 100% transparent color in the
667 original truecolor image to be preserved. In practice, more complex
668 alpha channels in palettes are ill-supported and difficult to
669 allocate skillfully.
670 </ul>
671 <P>
672 <A NAME="whatsnew2.0.11"><H3>What's new in version 2.0.11?</H3></A>
673 <P>
674 <ul>
675 <li>Support for the "gd2" file format, which allows fast loading of all or
676 only part of an existing image, has been properly debugged for use with
677 truecolor images. (Palette images already worked properly, except for a
678 bug when loading from a regular file with gdImageCreateFromGd2Part, which
679 has also been fixed.) .gd2 files can be either compressed or uncompressed,
680 and they allow useful tricks such as fast loading of a 500x500 pixel
681 region of a 6000x3000 pixel image, without uncompressing <em>all</em> of the
682 image. .gd2 is NOT a general purpose file format and should only be used
683 where quick loading of a background image or subset of a larger image
684 is required. For more information, see
685 <a href="#gdImageGd2">gdImageGd2</a>,
686 <a href="#gdImageCreateFromGd2">gdImageCreateFromGd2</a>,
687 and
688 <a href="#gdImageCreateFromGd2Part">gdImageCreateFromGd2Part</a>.
689 <li>The gd2topng utility has been extended to support extraction of
690 only part of an image from a .gd2 file. This is both a demonstration and
691 a practical tool.
692 <li>Additional <code>configure</code> improvements by Lars Hecking.
693 </ul>
694 <P>
695 <A NAME="whatsnew2.0.10"><H3>What's new in version 2.0.10?</H3></A>
696 <P>
697 <ul>
698 <li>gdImageLine now clips to the edges of the image before drawing
699 lines, which greatly improves performance when many lines extend
700 outside or are entirely outside the actual image. Thanks to
701 Nick Atty for this code.
702 <li>gdImageBoundsSafe is replaced with a macro when called internally;
703 this improves the performance of gdImageSetPixel and gdImageGetPixel
704 a little bit, and therefore everything else as well. Thanks to
705 Nicky Atty for the idea.
706 <li>Transparent indexes are handled properly with non-truecolor
707 source images in gdImageCopy. Thanks to Frank Warmerdam.
708 <li>floor() replaced with a cast to long in gdImageCopyResampled,
709 for a roughly 35% performance boost. Thanks to John Buckman.
710 <li>gdft.c builds correctly on WIN32 without patches.
711 <li>Much faster gdImageCreateFromJpeg routines, thanks to Christian
712 Aberger for more efficient pointer arithmetic.
713 <li>gdtestft correctly builds without PNG tests if PNG support is not present.
714 Thanks to Gabriele Verzeletti.
715 </ul>
716 <P>
717 <A NAME="whatsnew2.0.9"><H3>What's new in version 2.0.9?</H3></A>
718 <P>
719 <ul>
720 <li>Version 2.0.9 contains a fix to gdImageCopyResized which allows
721 correct results when copying a palette-based image with a single
722 transparent index into a truecolor image. Thanks to Thorben
723 Kundinger.
724 <li>More <code>configure</code> fixes from Lars Hecking. Thanks, Lars.
725 </ul>
726 <P>
727 <A NAME="whatsnew2.0.8"><H3>What's new in version 2.0.8?</H3></A>
728 <P>
729 <ul>
730 <li>Version 2.0.8 contains additional fixes to the 'configure' script,
731 allowing a clean out-of-the-box build on more systems.
732 <li>Version 2.0.8 adds the new
733 <a href="#gdImageCopyRotated">gdImageCopyRotated</a> function, which
734 can rotate any rectangular image region by an arbitrary number of degrees.
735 </ul>
736 <P>
737 <A NAME="whatsnew2.0.7"><H3>What's new in version 2.0.7?</H3></A>
738 <P>
739 Version 2.0.7 corrects a problem which caused 'configure' to complain
740 that the directory NONE was not found, in various places, causing
741 the configuration process to stop. There are no code changes.
742 <P>
743 <A NAME="whatsnew2.0.6"><H3>What's new in version 2.0.6?</H3></A>
744 <P>
745 <ul>
746 <li>
747 Fixed a compilation problem with gdft.c. A declaration appeared
748 after executable code, and gcc let it slide by, so it made it
749 out the door. My apologies!
750 <li>As penance, I have seen to it that the entire library
751 now compiles cleanly with the <code>-Wall</code>, <code>-ansi</code>
752 and <code>-pedantic</code> options enabled.
753 </ul>
754 <p>
755 <A NAME="whatsnew2.0.5"><H3>What's new in version 2.0.5?</H3></A>
756 <ul>
757 <li>libgd 2.0.5 INSTALLS IN /usr/local/lib BY DEFAULT. IF YOU WANT
758 IT TO INSTALL IN /usr/lib, YOU MUST SPECIFY THIS at
759 <code>configure</code> time using this syntax:
760 <p>
761 <code>./configure --prefix=/usr</code>
762 <li>gd now uses GNU autoconf. This means that the provided
763 <code>configure</code> script should be compatible with all standard
764 GNU configure options and will figure out the correct settings for a
765 much wider range of operating systems. Many, many thanks to
766 Lars Hecking for taking care of this.
767 <li>The <a href="#gdImageStringFTEx">gdImageStringFTEx</a> function
768 is now included, thanks to Wez Furlong. My apologies to Wez for the
769 unreasonable amount of time this patch has sat in my queue.
770 <li>Additional fixes from Wez Furlong.
771 <li>Arithmetic cleanup by Doug Claar.
772 <li>Corrections to loading and saving of alpha channel
773 information in PNG files, by Andrew Hull.
774 <li>gdImageTrueColorToPalette does not contain
775 unneeded test code.
776 <li>gdImageCopyResized works properly again when copying
777 from a non-truecolor source.
778 </ul>
779 <P>
780 <A NAME="whatsnew2.0.4"><H3>What's new in version 2.0.4?</H3></A>
781 The following contributions from John Ellson:
782 <ul>
783 <li>Various test programs now compile in the absence
784 of PNG support
785 <li>gdIOCtx correctly calls gdFree rather than free
786 <li>Various cleanups to pass -Wall without warnings
787 <li>Support for Adobe-style Type 1 fonts (.pfa and .pfb files)
788 via freetype
789 <li>gdImageColorResolve and gdImageColorResolveAlpha will not
790 attempt to resolve a color request to the transparent color index
791 (for palette-based images)
792 <li>Improved font search path support
793 <li>Antialiased freetype text on palette images works properly
794 when more than one image is created in a single program lifetime
795 with different color indexes
796 <li>Better threshold for two-color "mono" images
797 <li>Memory leak fixes
798 <li>Text rotation fix
799 <li>More extensive default font path
800 <li>fontwheeltest and fontsizetest test programs for freetype
801 </ul>
802 And the following additional fixes:
803 <ul>
804 <li><code>configure</code> now correctly detects and provides
805 support for the Xpm library and its dependencies (Len Makin)
806 </ul>
807 <A NAME="whatsnew2.0.3"><H3>What's new in version 2.0.3?</H3></A>
808 <ul>
809 <li>The <code>configure</code> script has been extensively modified
810 to work properly in tests with both Solaris and Linux. Other platforms
811 should also work based on feedback received and integrated to date.
812 <li>The <code>--prefix</code> option to <code>configure</code>
813 works properly.
814 <li>The <code>annotate</code> utility has been added. This is a
815 very handy tool for adding freetype text to existing JPEGs. After
816 <code>make install</code>, type <code>annotate -h</code> for more
817 information. Thanks to Joel Dubiner.
818 </ul>
819 <P>
820 <A NAME="whatsnew2.0.2"><H3>What's new in version 2.0.2?</H3></A>
821 <ul>
822 <li>A "configure" script has been added. After wrestling with GNU
823 autoconf for a while, I got tired of trying to make it detect libraries
824 but accept their absence gracefully, and so on. Instead, I wrote a short
825 Perl script which does the job and builds a reasonable Makefile. Those
826 who find it doesn't detect their system's needs properly are welcome
827 to contribute patches or the necessary commands.
828 <li>Antialiased freetype text output now works properly in both
829 truecolor and non-truecolor contexts! Hurrah! On a truecolor image
830 it is possible, for instance, to draw antialiased text on an arbitrarily
831 complex background with 50% alpha blending (transparency), and get the
832 expected pretty results. Thanks to Joel Dubiner for his support of this work.
833 <li><strong>By default, alpha blending is now done within the library.</strong>
834 Also, by default, alpha channel is not saved with PNG images. This means
835 that programmers who try loading a JPEG, scribbling some pretty antialiased
836 text on it, and saving the JPEG again will now get the results they
837 expected. It also means that, by default, users will not run afoul of
838 the fact that many web browsers don't properly support full PNG alpha
839 channel.
840 <li>Various submitted bug fixes have been incorporated.
841 <li>Various other submitted changes have not been incorporated. Sorry.
842 The interval between 2.0.1 and 2.0.2 was simply too long, and changes
843 accumulated which were not mutually compatible. I'll do better in
844 the future, especially with bug fixes.
845 </ul>
846 <P><A NAME="whatsnew2.0.1"><H3>What's new in version 2.0.1?</H3></A>
847 <ul>
848 <li>Workaround for a bug in gcc, apparently found in gcc 2.7.2 and up.
849 I reproduced and fixed it while using gcc 2.9.5.2. The bug occurred only
850 when the -g option was in use. This problem caused gcc to spew
851 internal error messages unrelated to the correctness of the code
852 in gd_gd2.c. Howard Jones was first to report it.
853 <li><a href="#gdImageFilledEllipse">gdImageFilledEllipse</a> documented
854 and altered; no longer requires a superfluous style argument. Thanks to
855 Francis James Franklin.
856 <li>The Makefile now offers the correct syntax for
857 optionally creating a static library. Thanks to Jean-Lous Regez,
858 among others.
859 <li>A nested comment, an attempt to return the value of a void function,
860 and a potentially significant error in gdImageCopyResampled were fixed
861 thanks to Joseph Shirley.
862 <li>A bug preventing proper truecolor text rendering was fixed,
863 thanks to Jason Gallagher.
864 <li><a href="#gdImageStringFT">gdImageStringFT</a> (FreeType) should
865 now work better against a transparent or semitransparent background,
866 and should act in a manner consistent with the most recent
867 <a href="#gdImageAlphaBlending">gdImageAlphaBlending</a> setting.
868 Antialiasing is now done via the alpha channel mechanism if the
869 image is a truecolor image.
870 <li>Bugs in the output of gdImageArc and gdImageFilledArc were reported
871 by Bruce Verderaime. A simple and correct but inefficient implementation
872 has been substituted until fixes are contributed for the faster code,
873 which is in gd_arc_f_buggy.c along with the test program that reproduces
874 the bug(s).
875 <li><a href="#gdImageFilledArc">gdImageFilledArc</a> now offers additional
876 style options, which can be combined to produce various effects.
877 <li>Masahito Yamaga (ma@yama-ga.com) sent a patch to improve
878 support for Japanese output via <a href="#gdImageStringFT">gdImageStringFT</a>.
879 He also added a new <code>readme.jpn</code> file.
880 <li>Zillions of documentation fixes.
881 </ul>
882 <P><A NAME="whatsnew2.0"><H3>What's new in version 2.0?</H3></A>
883 <ul>
884 <li><strong>Support for truecolor images!</strong> Version 2.0 can
885 load truecolor PNGs with no loss of color information, and almost
886 no loss of alpha channel information. Version 2.0 can also load
887 truecolor JPEGs with as little loss as possible; however, bear in
888 mind that JPEG is a lossy format, so repeated load/save cycles
889 always reduce image quality. This is not a bug. To create
890 a truecolor image from scratch, call the new
891 <a href="#gdImageCreateTrueColor">gdImageCreateTrueColor</a>
892 function. The <a href="#gdImageCreate">gdImageCreate</a> function
893 is still available to create palette images, and may also be
894 referred to as <a href="#gdImageCreatePalette">gdImageCreatePalette</a>.
895 <li><strong>Support for alpha channels!</strong> In addition to
896 24 bits of color information for each pixel (eight bits of
897 red, green, and blue respectively), version 2.0 supports
898 7 bits of "alpha channel" information. This is used to determine
899 exactly how transparent the pixel should be. There is also support
900 for a full 7 bits of transparency for each individual palette index
901 in a palette-based image. Please note that, as of this writing,
902 only Macintosh Internet Explorer 5.x and Mozilla/Netscape 6.x
903 display partial transparency properly.
904 <li>The new <a href="#gdImageAlphaBlending">gdImageAlphaBlending</a>
905 function allows for two different modes of drawing. In blending mode,
906 the alpha channel component of the color supplied to all drawing
907 functions, such as <a href="#gdImageSetPixel">gdImageSetPixel</a>,
908 determines how much of the underlying color should be allowed to
909 shine through. The resulting image is not transparent. In non-blending
910 mode, drawing color is copied literally with the alpha channel
911 information, resulting in a transparent image. Blending mode is
912 not available when drawing on palette images.
913 <li>The <a href="#gdImageCopyResampled">gdImageCopyResampled</a>
914 function provides "smooth" copying from a large image to a smaller
915 one, using a weighted average of the pixels of the source area rather
916 than selecting one representative pixel. This function is identical
917 to <a href="#gdImageCopyResized">gdImageCopyResized</a> when the
918 destination image is a palette image.
919 <li>The <a href="#gdImageTrueColorToPalette">gdImageTrueColorToPalette</a>
920 function converts a truecolor image to a palette image. The code for
921 this function was originally drawn from the Independent JPEG Group library
922 code, which is excellent. The code has been modified to preserve as much
923 alpha channel information as possible in the resulting palette, in addition
924 to preserving colors as well as possible. This does not work as well as
925 might be hoped. It is usually best to simply produce a truecolor
926 output image instead, which guarantees the highest output quality.
927 <li>A very high degree of backwards compatibility with existing
928 gd 1.x code has been maintained, at both the source code and binary
929 level. <strong>Code which directly accesses the <code>pixels</code> array
930 will fail only if it encounters an existing truecolor image</strong>, which may
931 happen if the code attempts to open and modify an existing JPEG or
932 truecolor PNG. Such code should be modified to check the
933 <code>trueColor</code> flag of the <code>gdImage</code> structure, and
934 refer to the <code>tpixels</code> array instead when it is set.
935 <li>gd is now compiled and installed as a shared library. However,
936 gd still does not use autoconf, because I (TBB) have very limited
937 patience with autoconf. These days, most Unix systems provide a fairly
938 POSIX-standard environment, and the provided Makefile is likely to work well
939 if users read it and follow the instructions at the top.
940 <li>Support for line thickness was added by Michael Schwartz. My apologies
941 to him for sitting on his patches for so long. See the new
942 <a href="#gdImageSetThickness">gdImageSetThickness</a> function, which
943 affects all standard gd functions that draw lines and curves. In addition,
944 Michael added a convenient <a href="#gdImageEllipse">gdImageEllipse</a>
945 function.
946 <li>The new <a href="#gdImageFilledArc">gdImageFilledArc</a> function
947 provides a straightforward way to draw filled arcs. Also,
948 <a href="#gdImageFilledEllipse">gdImageFilledEllipse</a> is a
949 convenient way to fill an ellipse without specifying starting
950 and ending angles. Thanks go out to F J Franklin.
951 <li>To put an end to the confusion, TrueType 1.x support has been
952 removed in favor of TrueType 2.x support. The old
953 gdImageStringTTF function simply invokes gdImageStringFT.
954 <li>The specialized .gd and .gd2 file formats have been upgraded to support
955 truecolor. New images written by the versions of these functions
956 found in 2.0 will be rejected, with varying degrees of grace, by
957 older versions of gd. THIS AFFECTS THE .GD and .GD2 FORMATS ONLY. IF YOU
958 ARE CONFUSED BY THIS PARAGRAPH, IT PROBABLY DOESN'T APPLY TO ANYTHING
959 YOU WILL EVER ENCOUNTER. Since these file formats are absolutely,
960 positively *not* designed for distributing images, just for
961 preprocessing them, this should not be a big problem. gd 2.0 should
962 read old .gd and .gd2 files correctly.
963 </ul>
964 <P><A NAME="whatsnew1.8.4"><H3>What's new in version 1.8.4?</H3></A>
965 <ul>
966 <li>Add support for FreeType2 (John Ellson ellson@graphviz.org)
967 <li>Add support for finding in fonts in a builtin DEFAULT_FONTPATH,
968 or in a path from the GDFONTPATH environment variable.
969 <li>remove some unused symbols to reduce compiler warnings
970 <li>bugfix in size comparisons in gdImageCompare
971 <li>REXX now mentioned
972 <li>All memory allocation functions are now wrapped within the
973 library; gdFree is exported and recommended for freeing memory
974 returned by the gdImage(Something)Ptr family of functions.
975 </ul>
976 <P><A NAME="whatsnew1.8.3"><H3>What's new in version 1.8.3?</H3></A>
977 <ul>
978 <li>WBMP output memory leak fixed
979 <li><code>#include &lt;gd.h&gt;</code> corrected to <code>#include "gd.h"</code> in gd_wbmp.c
980 <li>Documented the fact that the source and output images shouldn't
981 match in the WBMP test except for black and white source images
982 </ul>
983 <P>
984 <A NAME="whatsnew1.8.2"><H3>What's new in version 1.8.2?</H3></A>
985 <ul>
986 <li>WBMP support debugged and improved by Johann Van den Brande
987 <li>WBMP tests added to gdtest.c by Thomas Boutell
988 <li>Use of platform-dependent 'install' command removed by Thomas Boutell
989 <li>Comments added to Makefile warning users to juggle the order of the
990 libraries if the linker complains; is there any portable way to do this
991 automatically, short of using autoconf?
992 <li>Documentation of <a href="#gdImageCreateFromXpm">gdImageCreateFromXpm</a>
993 corrected
994 <li>Updated links to fast-moving, always dodging libpng and zlib web sites
995 </ul>
996 <P><A NAME="whatsnew1.8.1"><H3>What's new in version 1.8.1?</H3></A>
997 <ul>
998 <li>Optional components no longer built by default (following the
999 documentation)
1000 <li>JPEG code no longer requires inappropriate header files
1001 <li>Win32 patches from Joe Gregorio
1002 <li>16-bit font support for bdftogd, from Honza Pazdziora
1003 </ul>
1004 <P><A NAME="whatsnew1.8"><H3>What's new in version 1.8?</H3></A>
1005 <ul>
1006 <li>Support for JPEG output, courtesy of Doug Becker
1007 <li>A link to Michael Bradbery's Pascal wrapper
1008 <li>Support for WBMP output, courtesy of Maurice Szmurlo
1009 <li>gdImageColorClosestHWB function based on hue, whiteness, blackness,
1010 superior to the regular gdImageColorClosest function, courtesy
1011 of Philip Warner
1012 <li>License clarification: yes, you can modify gd
1013 </ul>
1014 <h4>Additional JPEG Information</h4>
1015 Support for reading and writing JPEG-format images is courtesy
1016 of Doug Becker and the Independent JPEG Group / Thomas G. Lane. You
1017 can get the latest version of the IJG JPEG software from <A
1018 HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>
1019 (e.g., the <A
1020 HREF="ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz">jpegsrc.v6b.tar.gz</A>
1021 file). You <strong>must</strong> use
1022 version 6b or later of the IJG JPEG software. You might also consult
1023 the <A HREF="http://www.faqs.org/faqs/jpeg-faq/">JPEG FAQ</A> at
1024 <A HREF="http://www.faqs.org/faqs/jpeg-faq/">http://www.faqs.org/faqs/jpeg-faq/</A>.
1025 <P><A NAME="whatsnew1.7.3"><H3>What's new in version 1.7.3?</H3></A>
1026 Another attempt at Makefile fixes to permit
1027 linking with all libraries required on platforms with order-
1028 dependent linkers. Perhaps it will work this time.
1029 <P><A NAME="whatsnew1.7.2"><H3>What's new in version 1.7.2?</H3></A>
1030 An uninitialized-pointer bug in <code>gdtestttf.c</code> was corrected.
1031 This bug caused crashes at the end of each call to gdImageStringTTF on
1032 some platforms. Thanks to Wolfgang Haefelinger.
1033 <p>
1034 Documentation fixes. Thanks to Dohn Arms.
1035 <p>
1036 Makefile fixes to permit
1037 linking with all libraries required on platforms with order-
1038 dependent linkers.
1039 <P><A NAME="whatsnew1.7.1"><H3>What's new in version 1.7.1?</H3></A>
1040 A minor buglet in the Makefile was corrected, as well as an inaccurate
1041 error message in <code>gdtestttf.c</code>. Thanks to Masahito Yamaga.
1042 <P><A NAME="whatsnew1.7"><H3>What's new in version 1.7?</H3></A>
1043 Version 1.7 contains the following changes:
1044 <ul>
1045 <li>Japanese language support for the TrueType functions.
1046 Thanks to Masahito Yamaga.
1047 <li><code>autoconf</code> and <code>configure</code> have been removed, in favor of a
1048 carefully designed Makefile which produces and properly installs
1049 the library and the binaries. System-dependent variables are
1050 at the top of the Makefile for easy modification. I'm sorry,
1051 folks, but autoconf generated <strong>many, many confused email
1052 messages</strong> from people who didn't have things where autoconf
1053 expected to find them. I am not an autoconf/automake wizard, and
1054 gd is a simple, very compact library which does not need to
1055 be a shared library. I <strong>did</strong> make many improvements
1056 over the old gd 1.3 Makefile, which were directly inspired by the
1057 autoconf version found in the 1.6 series (thanks to John Ellson).
1058 <li>Completely ANSI C compliant, according to the <code>-pedantic-errors</code>
1059 flag of gcc. Several pieces of not-quite-ANSI-C code were causing problems
1060 for those with non-gcc compilers.
1061 <li><code>gdttf.c</code> patched to allow the use of Windows symbol
1062 fonts, when present (thanks to Joseph Peppin).
1063 <li><code>extern "C"</code> wrappers added to <code>gd.h</code> and the
1064 font header files for the convenience of C++ programmers.
1065 <code>bdftogd</code> was also modified to automatically insert these
1066 wrappers into future font header files. Thanks to John Lindal.
1067 <li>Compiles correctly on platforms that don't define <code>SEEK_SET</code>.
1068 Thanks to Robert Bonomi.
1069 <li>Loads Xpm images via the
1070 <a href="#gdImageCreateFromXpm"><code>gdImageCreateFromXpm</code></a>
1071 function, if the Xpm library is available. Thanks to Caolan McNamara.
1072 </ul>
1073 <P><A NAME="whatsnew1.6.3"><H3>What's new in version 1.6.3?</H3></A>
1074 Version 1.6.3 corrects a memory leak in gd_png.c. This leak caused
1075 a significant amount of memory to be allocated and not freed when
1076 writing a PNG image.
1077 <P><A NAME="whatsnew1.6.2"><H3>What's new in version 1.6.2?</H3></A>
1078 Version 1.6.2 from John Ellson <ellson@graphviz.org> adds two new functions:
1079 <ul>
1080 <li>gdImageStringTTF - scalable, rotatable, anti-aliased, TrueType strings using
1081 the FreeType library, but only if libttf is found by configure.
1082 <strong>We do not provide TrueType fonts. Obtaining them
1083 is entirely up to you.</strong>
1084 <li>gdImageColorResolve - an efficient alternative for the
1085 common code fragment:
1086 <pre>
1087
1088 if ((color=gdImageColorExact(im,R,G,B)) < 0)
1089 if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
1090 color=gdImageColorClosest(im,R,G,B);
1091 </pre>
1092 </ul>
1093 <p>
1094 Also in this release the build process has been converted to
1095 GNU autoconf/automake/libtool conventions so that both (or either)
1096 static and shared libraries can be built.
1097 <P><A NAME="whatsnew1.6.1"><H3>What's new in version 1.6.1?</H3></A>
1098 Version 1.6.1 incorporates superior PNG reading and writing code
1099 from Greg Roelofs, with minor modifications by Tom Boutell.
1100 Specifically, I altered his code to read non-palette images
1101 (converting them to palette images badly, by dithering them),
1102 and to tolerate palette images with types of transparency that
1103 gd doesn't actually support (it just ignores the advanced
1104 transparency features). Any bugs in this area are therefore my
1105 fault, not Greg's.
1106 <p>
1107 Unlike gd 1.6, users should have no trouble linking with
1108 gd 1.6.1 if they follow the instructions and install all of
1109 the pieces. However, <strong>If you get undefined symbol errors,
1110 be sure to check for older versions of libpng in your
1111 library directories!</strong>
1112 <P><A NAME="whatsnew1.6"><H3>What's new in version 1.6?</H3></A>
1113 Version 1.6 features the following changes:
1114 <p>
1115 <strong>Support for 8-bit palette PNG images has been added.
1116 Support for GIF has been removed.</strong> This step was taken
1117 to completely avoid the legal controversy regarding the LZW
1118 compression algorithm used in GIF. Unisys holds a patent which
1119 is relevant to LZW compression. PNG is a superior image format
1120 in any case. Now that PNG is supported by both Microsoft
1121 Internet Explorer and Netscape (in their recent releases),
1122 we highly recommend that GD users upgrade in order to get
1123 well-compressed images in a format which is legally unemcumbered.
1124
1125 <P><A NAME="whatsnew1.5"><H3>What's new in version 1.5?</H3></A>
1126
1127 Version 1.5 featured the following changes:
1128
1129 <dl>
1130 <dt><b>New GD2 format</b>
1131 <dd> An improvement over the GD format, the GD2 format uses the zlib
1132 compression library to compress the image in chunks. This results
1133 in file sizes comparable to GIFs, with the ability to access parts
1134 of large images without having to read the entire image into memory.
1135 <p>
1136 This format also supports version numbers and rudimentary validity
1137 checks, so it should be more 'supportable' than the previous GD format.
1138 <p>
1139 <dt><b>Re-arranged source files</b>
1140 <dd> gd.c has been broken into constituant parts: io, gif, gd, gd2 and
1141 graphics functions are now in separate files.
1142 <p>
1143 <dt><b>Extended I/O capabilities.</b>
1144 <dd> The source/sink feature has been extended to support GD2 file formats (which
1145 require seek/tell functions; seek must return 1 for success, 0 for failure), and to allow more general non-file I/O.
1146 <p>
1147 <dt><b>Better support for Lincoln Stein's Perl Module</b>
1148 <dd> The new gdImage*Ptr function returns the chosen format stored in a block of memory.
1149 This can be directly used by the GD perl module.
1150 <p>
1151 <dt><b>Added functions</b>
1152 <dd>gdImageCreateFromGd2Part - allows retrieval of part of an image (good for huge images, like maps),
1153 <br>gdImagePaletteCopy - Copies a palette from one image to another, doing it's best to match the colors in the target image to the colors in the source palette.
1154 <br>gdImageGd2, gdImageCreateFromGd2 - Support for new format
1155 <br>gdImageCopyMerge - Merges two images (useful to highlight part of an image)
1156 <br>gdImageCopyMergeGray - Similar to gdImageCopyMerge, but tries to preserve source image hue.
1157 <br>gdImagePngPtr, gdImageJpegPtr, gdImageWBMPPtr, gdImageGdPtr, gdImageGd2Ptr - return memory blocks for each type of image.
1158 <br>gdImageCreateFromPngCtx, gdImageCreateFromGdCtx, gdImageCreateFromGd2Ctx, gdImageCreateFromGd2PartCtx - Support for new I/O context.
1159
1160 </dl>
1161
1162 <b>NOTE:</b> In fairness to Thomas Boutell, any bug/problems with any of the above features should
1163 probably be reported to <a href=mailto:pjw@rhyme.com.au>Philip Warner</a>.
1164
1165 <P><A NAME="whatsnew1.4"><H3>What's new in version 1.4?</H3></A>
1166
1167 Version 1.4 features the following changes:
1168 <dl>
1169 <dt>Fixed polygon fill routine (again)
1170 <dd>Thanks to Kirsten Schulz, version 1.4 is able to fill
1171 numerous types of polygons that caused problems with
1172 previous releases, including version 1.3.
1173 <dt>Support for alternate data sources
1174 <dd>Programmers who wish to load a GIF from something other
1175 than a stdio FILE * stream can use the new
1176 <a href="#gdImageCreateFromPngSource">gdImageCreateFromPngSource</a> function.
1177 <dt>Support for alternate data destinations
1178 <dd>Programmers who wish to write a GIF to something other
1179 than a stdio FILE * stream can use the new
1180 <a href="#gdImagePngToSink">gdImagePngToSink</a> function.
1181 <dt>More tolerant when reading GIFs
1182 <dd>
1183 Version 1.4 does not crash when reading certain animated GIFs,
1184 although it still only reads the first frame. Version 1.4 also has
1185 overflow testing code to prevent crashes when reading
1186 damaged GIFs.
1187 </dl>
1188 <P><A NAME="whatsnew1.3"><H3>What's new in version 1.3?</H3></A>
1189 Version 1.3 features the following changes:
1190 <dl>
1191 <dt>Non-LZW-based GIF compression code
1192 <dd>
1193 Version 1.3 contained GIF compression code that uses simple Run Length
1194 Encoding instead of LZW compression, while still retaining compatibility
1195 with normal LZW-based GIF decoders (your browser will still like your GIFs).
1196 <strong>LZW compression is patented by Unisys. We are currently reevaluating
1197 the approach taken by gd 1.3. The current release of gd does not support
1198 this approach. We recommend that you use the current release, and generate
1199 PNG images.</strong> Thanks to
1200 Hutchison Avenue Software Corporation for contributing
1201 the RLE GIF code.
1202 <dt>8-bit fonts, and 8-bit font support
1203 <dd>This improves support for European languages. Thanks are due
1204 to Honza Pazdziora <adelton@informatics.muni.cz> and also to
1205 Jan Pazdziora <adelton@fi.muni.cz>. Also see the provided bdftogd
1206 Perl script if you wish to convert fixed-width X11 fonts
1207 to gd fonts.
1208 <dt>16-bit font support (no fonts provided)
1209 <dd>Although no such fonts are provided in the distribution,
1210 fonts containing more than 256 characters should work if the
1211 gdImageString16 and gdImageStringUp16 routines are used.
1212 <dt>Improvements to the "webpng" example/utility
1213 <dd>The "webpng" utility is now a slightly more useful application. Thanks to
1214 Brian Dowling for this code.
1215 <dt>Corrections to the color resolution field of GIF output
1216 <dd>Thanks to Bruno Aureli.
1217 <dt>Fixed polygon fills
1218 <dd>A one-line patch for the infamous polygon fill bug, courtesy
1219 of Jim Mason. I believe this fix is sufficient. However, if you
1220 find a situation where polygon fills still fail to behave properly,
1221 please send code that demonstrates the problem, <em>and</em> a fix if
1222 you have one. Verifying the fix is important.
1223 <dt>Row-major, not column-major
1224 <dd>Internally, gd now represents the array of pixels as
1225 an array of rows of pixels, rather than an array of columns
1226 of pixels. This improves the performance of compression and
1227 decompression routines slightly, because horizontally adjacent
1228 pixels are now next to each other in memory. <strong>This should
1229 not affect properly written gd applications, but applications that
1230 directly manipulate the <code>pixels</code> array will require
1231 changes.</strong>
1232 </dl>
1233 <A NAME="required"><H3>What else do I need to use gd?</H3></A>
1234 <P>
1235 To use gd, you will need an ANSI C compiler. <strong>All popular
1236 Windows 95 and NT C compilers are ANSI C compliant.</strong> Any
1237 full-ANSI-standard C compiler should be adequate. <strong>The cc
1238 compiler released with SunOS 4.1.3 is not an ANSI C compiler.
1239 Most Unix users who do not already have gcc should get it.
1240 gcc is free, ANSI compliant and a de facto industry standard.
1241 Ask your ISP why it is missing.</strong>
1242 <P>
1243 As of version 1.6, you also need the zlib compression library,
1244 and the libpng library. As of version 1.6.2, you can draw text
1245 using antialiased TrueType fonts if you also have the libttf
1246 library installed, but this is not mandatory.
1247 zlib is available for a variety of platforms from
1248 <a href="http://www.freesoftware.com/pub/infozip/index.html">the zlib web site</a>.
1249 libpng is available for a variety of platforms from
1250 <a href="http://www.cdrom.com/pub/png/">the PNG web site</a>.
1251
1252 <P>
1253 You will also want a PNG viewer, if you do not already have
1254 one for your system, since you will need a good way to check the
1255 results of your work. Netscape 4.04 and higher, and Microsoft
1256 Internet Explorer 4.0 or higher, both support PNG.
1257 <strong>Not every PNG-compatible viewer supports alpha channel
1258 transparency,</strong> which is why gd 2.0.2 and above do alpha
1259 blending in the library by default; it is possible to turn on the
1260 saving of alpha channel information to the file instead.
1261 <P>
1262 <A NAME="getgd"><H3>How do I get gd?</H3></A>
1263 <h4>Binaries (DLL for Windows programmers):</h4>
1264 <ul>
1265 <li><a href="http://www.libgd.org/Downloads">.ZIP File of DLL, Headers, Et Cetera</a>
1266 <p>
1267 </ul>
1268 <h4>Source Code:</h4>
1269 <ul>
1270 <li><a href="http://www.libgd.org/Downloads">Gzipped Tar File (Unix)</a>
1271 <li><a href="http://www.boutell.com/gd/http/gd-2.0.33.tar.gz">.ZIP File of SOURCE CODE (Windows)</a>
1272 </ul>
1273 <P>
1274 <A NAME="buildgd"><H3>How do I build gd?</H3></A>
1275 <blockquote>
1276 Win32 DLL users: if you are using MSVC, use the provided batch file
1277 <code>makemsvcimport.bat</code> to make a bgd.lib import library
1278 corresponding to the provided bgd.dll. Copy bgd.dll to your
1279 application directory, or to your Windows sytem directory. In the
1280 settings of your MSVC project, you <b>MUST</b> choose the
1281 "multithreaded DLL" library option under "code generation."
1282 mingw32 and cygwin users can simply link with the provided libbgd.a
1283 stub library in order to use the DLL.
1284 </blockquote>
1285 Building gd From the Source
1286 <p>
1287 In order to build gd, you must first unpack the archive you have
1288 downloaded. If you are not familiar with <code>tar</code> and
1289 <code>gunzip</code> (Unix) or <code>ZIP</code> (Windows), please
1290 consult with an experienced user of your system. Sorry, we cannot
1291 answer questions about basic Internet skills.
1292 <p>
1293 Unpacking the archive will produce a directory called "gd-2.0.33".
1294 <p>
1295 <h4>For Unix</h4>
1296 <code>cd</code> to the 2.0.33 directory and type:
1297 <p>
1298 <code>./configure</code>
1299 <P>
1300 <blockquote>
1301 <STRONG>NOTE: BY DEFAULT, THE LIBRARY IS INSTALLED IN
1302 <code>/usr/local/lib</code></strong> and the include files are
1303 installed in <code>/usr/local/include</code>. IF YOU ARE
1304 UPGRADING, you may wish to use:
1305 <pre>
1306 ./configure --prefix=/usr
1307 </pre>
1308 Rather than just <code>./configure</code>, before typing
1309 <code>make</code> and <code>make install</code>.
1310 </blockquote>
1311 <p>
1312 If all goes well, this will create a Makefile. If all does not go well --
1313 for instance, if neither the the JPEG nor the PNG and ZLIB libraries
1314 are found -- you will need to install those libraries, then come back
1315 and run <code>configure</code> again.
1316 <p>
1317 If necessary, make changes to the resulting Makefile. Then,
1318 type "make". If there are no errors, follow this with "make install".
1319 Because gd 2.0 and above installs as a shared library, it is necessary to
1320 install the library properly before running gd-based programs.
1321 <p>
1322 If you get errors, type <code>./configure --help</code> for more
1323 information about the available options. In the unlikely event
1324 that the GNU autoconf-produced configure script does not work well
1325 for you, you may wish to try <code>configure.pl</code>, a
1326 simple Perl script with similar but less complete capabilities.
1327 If all else fails, try renaming <code>makefile.sample</code>
1328 to <code>Makefile</code>. However, <code>./configure</code> is
1329 almost always your best bet.
1330 <blockquote>
1331 <h4>For Windows</h4>
1332 Use the DLL version! See the paragraph at the beginning of this sectino.
1333 If you really want to compile it yourself for some strange reason, read on.
1334 <p>
1335 Create a project using your favorite programming environment.
1336 Copy all of the gd files to the project directory. Add <code>gd.c</code>
1337 to your project. Add other source files as appropriate. Learning the
1338 basic skills of creating projects with your chosen C environment
1339 is up to you. Alternatively, use the free <code>mingw32</code>
1340 or <code>cygwin</code> tools, which may prove to be compatible
1341 with the provided <code>configure</code> script.
1342 </blockquote>
1343 <P>
1344 If you wish to test the library, type "make test" AFTER you have
1345 successfully executed "make install". This will build
1346 several test programs, including "gddemo". (Not all of these
1347 programs are expected to print completely successful messages,
1348 depending on the nature of the image formats with which some of
1349 the tests are tried; for instance, WBMP is a black and white
1350 format, so loss of color information is expected there.)
1351 Run gddemo to see some of the capabilities of gd. Run
1352 gdtestft to play with the freetype support, if you have built
1353 gd with it and have access to truetype fonts.
1354 <P>
1355 gddemo should execute without incident, creating the file
1356 demoout.png. (Note there is also a file named demoin.png,
1357 which is provided in the package as part of the demonstration.)
1358 <P>
1359 Display demoout.png in your PNG viewer. The image should
1360 be 128x128 pixels and should contain an image of the
1361 space shuttle with quite a lot of graphical elements drawn
1362 on top of it.
1363 <P>
1364 (If you are missing the demoin.png file, the other items
1365 should appear anyway.)
1366 <P>
1367 Look at demoin.png to see the original space shuttle
1368 image which was scaled and copied into the output image.
1369 <P>
1370 <A NAME="basics"><H3>gd basics: using gd in your program</H3></A>
1371 gd lets you create PNG or JPEG images on the fly. To use gd in your
1372 program, include the file gd.h, and link with the gd
1373 library and the other required libraries; the syntax for
1374 most Unix flavors is:
1375 <pre>
1376 -lgd -lpng -lz -ljpeg -lfreetype -lm
1377 </pre>
1378 Assuming that all of these libraries are available.
1379 <P>
1380 If you want to use the provided simple fonts, include
1381 gdfontt.h, gdfonts.h, gdfontmb.h, gdfontl.h and/or gdfontg.h. For
1382 more impressive results, install FreeType 2.x and use the
1383 <a href="#gdImageStringFT">gdImageStringFT</a>
1384 function. If you are not using the provided Makefile and/or a
1385 library-based approach, be sure to include the source modules as well in your
1386 project. (They may be too large for 16-bit memory models,
1387 that is, 16-bit DOS and Windows.)
1388 <P>
1389 Here is a short example program. <strong>(For a more advanced example,
1390 see gddemo.c, included in the distribution. gddemo.c is NOT the same program;
1391 it demonstrates additional features!)</strong>
1392 <P>
1393 <PRE>
1394 /* Bring in gd library functions */
1395 #include "gd.h"
1396
1397 /* Bring in standard I/O so we can output the PNG to a file */
1398 #include &lt;stdio.h&gt;
1399
1400 int main() {
1401 /* Declare the image */
1402 <A HREF="#gdImagePtr">gdImagePtr</A> im;
1403 /* Declare output files */
1404 FILE *pngout, *jpegout;
1405 /* Declare color indexes */
1406 int black;
1407 int white;
1408
1409 /* Allocate the image: 64 pixels across by 64 pixels tall */
1410 im = <A HREF="#gdImageCreate">gdImageCreate</A>(64, 64);
1411
1412 /* Allocate the color black (red, green and blue all minimum).
1413 Since this is the first color in a new image, it will
1414 be the background color. */
1415 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
1416
1417 /* Allocate the color white (red, green and blue all maximum). */
1418 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
1419
1420 /* Draw a line from the upper left to the lower right,
1421 using white color index. */
1422 <A HREF="#gdImageLine">gdImageLine</A>(im, 0, 0, 63, 63, white);
1423
1424 /* Open a file for writing. "wb" means "write binary", important
1425 under MSDOS, harmless under Unix. */
1426 pngout = fopen("test.png", "wb");
1427
1428 /* Do the same for a JPEG-format file. */
1429 jpegout = fopen("test.jpg", "wb");
1430
1431 /* Output the image to the disk file in PNG format. */
1432 <A HREF="#gdImagePng">gdImagePng</A>(im, pngout);
1433
1434 /* Output the same image in JPEG format, using the default
1435 JPEG quality setting. */
1436 <A HREF="#gdImageJpeg">gdImageJpeg</A>(im, jpegout, -1);
1437
1438 /* Close the files. */
1439 fclose(pngout);
1440 fclose(jpegout);
1441
1442 /* Destroy the image in memory. */
1443 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
1444 }
1445 </PRE>
1446 When executed, this program creates an image, allocates
1447 two colors (the first color allocated becomes the background
1448 color), draws a diagonal line (note that 0, 0 is the upper
1449 left corner), writes the image to PNG and JPEG files, and
1450 destroys the image.
1451 <P>
1452 The above example program should
1453 give you an idea of how the package works.
1454 gd provides many additional functions, which are listed
1455 in the following reference chapters, complete with code
1456 snippets demonstrating each. There is also an
1457 <A HREF="#index">alphabetical index</A>.
1458 <H3><A NAME="webpng">Webpng: a more powerful gd example</A></H3>
1459 Webpng is a simple utility program to manipulate PNGs from the
1460 command line. It is written for Unix and similar command-line
1461 systems, but should be easily adapted for other environments.
1462 Webpng allows you to set transparency and interlacing and
1463 output interesting information about the PNG in question.
1464 <P>
1465 webpng.c is provided in the distribution. Unix users can
1466 simply type "make webpng" to compile the program. Type
1467 "webpng" with no arguments to see the available options.
1468 <H2><A NAME="reference">Function and type reference</A></H2>
1469 <UL>
1470 <LI><A HREF="#types">Types</A></LI>
1471 <LI><A HREF="#creating">Image creation, destruction, loading and saving</A></LI>
1472 <LI><A HREF="#drawing">Drawing, styling, brushing, tiling and
1473 filling functions</A></LI>
1474 <LI><A HREF="#query">Query functions (not color-related)</A></LI>
1475 <LI><A HREF="#fonts">Font and text-handling functions</A></LI>
1476 <LI><A HREF="#colors">Color handling functions</A></LI>
1477 <LI><A HREF="#copying">Copying, resizing, rotating, deformation and filter
1478 functions</A></LI>
1479 <LI><A HREF="#misc">Miscellaneous Functions</A></LI>
1480 <LI><A HREF="#constants">Constants</A></LI>
1481 </UL>
1482 <H3><A NAME="types">Types</A></H3>
1483 <DL>
1484 <DT><A NAME="gdImage"><code>gdImage</code><strong>(TYPE)</strong></A>
1485 <DD>
1486 The data structure in which gd stores images. <A HREF="#gdImageCreate">
1487 gdImageCreate</A>, <a href="#gdImageCreateTrueColor">gdImageCreateTrueColor</a>
1488 and the various image file-loading functions return
1489 a pointer to this type, and the other functions expect to receive
1490 a pointer to this type as their first argument. It is reasonably safe to
1491 examine any of the members of this structure. It is also reasonably
1492 safe to modify individual pixels within the <code>pixels</code>
1493 or <code>tpixels</code> arrays. If the <code>trueColor</code> flag
1494 is set, the <code>tpixels</code> array is valid; otherwise the
1495 <code>pixels</code> array is valid.
1496 <p>
1497 The <code>colorsTotal</code>, <code>red</code>, <code>green</code>,
1498 <code>blue</code>, <code>alpha</code> and <code>open</code> arrays
1499 manage the palette. They are valid only when the <code>trueColor</code>
1500 flag is not set.
1501 The <code>transparent</code> value contains the palette index of the first
1502 transparent color as read-only information for backwards compatibility;
1503 gd 2.0 stores this information in the <code>alpha</code> array so that
1504 variable transparency can be supported for each palette entry. However,
1505 for truecolor images, <code>transparent</code> represents a single
1506 RGB color which is <strong>always 100% transparent</strong>, and this
1507 feature is generally supported by browsers which do not support
1508 full alpha channels.
1509 <PRE>
1510 typedef struct {
1511 /* Palette-based image pixels */
1512 unsigned char ** pixels;
1513 int sx;
1514 int sy;
1515 /* These are valid in palette images only. See also
1516 /* 'alpha', which appears later in the structure to
1517 preserve binary backwards compatibility */
1518 int colorsTotal;
1519 int red[gdMaxColors];
1520 int green[gdMaxColors];
1521 int blue[gdMaxColors];
1522 int open[gdMaxColors];
1523 /* For backwards compatibility, this is set to the
1524 first palette entry with 100% transparency,
1525 and is also set and reset by the
1526 gdImageColorTransparent function. Newer
1527 applications can allocate palette entries
1528 with any desired level of transparency; however,
1529 bear in mind that many viewers, notably
1530 many web browsers, fail to implement
1531 full alpha channel for PNG and provide
1532 support for full opacity or transparency only. */
1533 int transparent;
1534 int *polyInts;
1535 int polyAllocated;
1536 struct gdImageStruct *brush;
1537 struct gdImageStruct *tile;
1538 int brushColorMap[gdMaxColors];
1539 int tileColorMap[gdMaxColors];
1540 int styleLength;
1541 int stylePos;
1542 int *style;
1543 int interlace;
1544 /* New in 2.0: alpha channel for palettes. Note that only
1545 Macintosh Internet Explorer and (possibly) Netscape 6
1546 really support multiple levels of transparency in
1547 palettes, to my knowledge, as of 2/15/01. Most
1548 common browsers will display 100% opaque and
1549 100% transparent correctly, and do something
1550 unpredictable and/or undesirable for levels
1551 in between. TBB */
1552 int alpha[gdMaxColors];
1553 /* Truecolor flag and pixels. New 2.0 fields appear here at the
1554 end to minimize breakage of existing object code. */
1555 int trueColor;
1556 int ** tpixels;
1557 /* Should alpha channel be copied, or applied, each time a
1558 pixel is drawn? This applies to truecolor images only.
1559 No attempt is made to alpha-blend in palette images,
1560 even if semitransparent palette entries exist.
1561 To do that, build your image as a truecolor image,
1562 then quantize down to 8 bits. */
1563 int alphaBlendingFlag;
1564 /* Should the alpha channel of the image be saved? This affects
1565 PNG at the moment; other future formats may also
1566 have that capability. JPEG doesn't. */
1567 int saveAlphaFlag;
1568 } gdImage;
1569 </PRE>
1570 <p>
1571 The order of the structure members may appear confusing, but was chosen
1572 deliberately to increase backwards compatibility with existing gd 1.x-based
1573 binary code that references particular structure members.
1574 <DT><A NAME="gdImagePtr">gdImagePtr</A> <strong>(TYPE)</strong>
1575 <DD>
1576 A pointer to an image structure. <A HREF="#gdImageCreate">gdImageCreate</A>
1577 returns this type, and the other functions expect it as the first
1578 argument.
1579 <DT><A NAME="gdIoCtx">gdIOCtx</a> <strong>(TYPE)</strong>
1580 <DD>
1581 Most of the gd functions that read and write files, such as
1582 <a href="#gdImagePng">gdImagePng</a> and <a href="#gdImageCreateFromJpeg"></a>,
1583 also have variants that accept a gdIOCtx structure; see
1584 <a href="#gdImagePngCtx">gdImagePngCtx</a> and
1585 <a href="#gdImageCreateFromJpegCtx">gdImageCreateFromJpegCtx</a>. Those who wish to provide
1586 their own custom routines to read and write images can populate a
1587 gdIOCtx structure with functions of their own devising to
1588 to read and write data. For image reading, the only mandatory
1589 functions are getC and getBuf, which must return the number of
1590 characters actually read, or a negative value on error or EOF.
1591 These functions must read the number of characters requested
1592 unless at the end of the file. For image writing, the only mandatory
1593 functions are putC and putBuf, which return the number of
1594 characters written; these functions must write the number of
1595 characters requested except in the event of an error. The seek
1596 and tell functions are only required in conjunction with the
1597 <code>gd2</code> file format, which supports quick loading of
1598 partial images. The gd_free function will not be invoked when
1599 calling the standard Ctx functions; it is an implementation
1600 convenience when adding new data types to gd. For examples,
1601 see gd_png.c, gd_gd2.c, gd_jpeg.c, etc., all of which rely
1602 on gdIOCtx to implement the standard image read and write functions.
1603
1604 <pre>
1605 typedef struct gdIOCtx
1606 {
1607 int (*getC) (struct gdIOCtx *);
1608 int (*getBuf) (struct gdIOCtx *, void *, int wanted);
1609
1610 void (*putC) (struct gdIOCtx *, int);
1611 int (*putBuf) (struct gdIOCtx *, const void *, int wanted);
1612
1613 /* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
1614 int (*seek) (struct gdIOCtx *, const int);
1615
1616 long (*tell) (struct gdIOCtx *);
1617
1618 void (*gd_free) (struct gdIOCtx *);
1619
1620 } gdIOCtx;
1621 </pre>
1622
1623
1624 <DT><A NAME="gdFont">gdFont</A> <strong>(TYPE)</strong>
1625 <DD>
1626 A font structure. Used to declare the characteristics of a font.
1627 Please see the files gdfontl.c and gdfontl.h for an example of the
1628 proper declaration of this structure. You can provide your
1629 own font data by providing such a structure and the associated
1630 pixel array. You can determine the width and height of a single
1631 character in a font by examining the w and h members of the
1632 structure. If you will not be creating your own fonts, you will
1633 not need to concern yourself with the rest of the components of this
1634 structure.
1635 <PRE>
1636 typedef struct {
1637 /* # of characters in font */
1638 int nchars;
1639 /* First character is numbered... (usually 32 = space) */
1640 int offset;
1641 /* Character width and height */
1642 int w;
1643 int h;
1644 /* Font data; array of characters, one row after another.
1645 Easily included in code, also easily loaded from
1646 data files. */
1647 char *data;
1648 } gdFont;
1649 </PRE>
1650 <DT><A NAME="gdFontPtr">gdFontPtr</A> <strong>(TYPE)</strong>
1651 <DD>
1652 A pointer to a font structure. Text-output functions expect these
1653 as their second argument, following the <A HREF="#gdImagePtr">
1654 gdImagePtr</A> argument. Two such pointers are declared in the
1655 provided include files gdfonts.h and gdfontl.h.
1656 <DT><A NAME="gdPoint">gdPoint</A> <strong>(TYPE)</strong>
1657 <DD>
1658 Represents a point in the coordinate space of the image; used
1659 by <A HREF="#gdImagePolygon">gdImagePolygon</A>,
1660 <A HREF="#gdImageOpenPolygon">gdImageOpenPolygon</A> and
1661 <A HREF="#gdImageFilledPolygon">gdImageFilledPolygon</A>.
1662 <PRE>
1663 typedef struct {
1664 int x, y;
1665 } gdPoint, *gdPointPtr;
1666 </PRE>
1667 <DT><A NAME="gdPointPtr">gdPointPtr</A> <strong>(TYPE)</strong>
1668 <DD>
1669 A pointer to a <A HREF="#gdPoint">gdPoint</A> structure; passed
1670 as an argument to <A HREF="#gdImagePolygon">gdImagePolygon</A>,
1671 <A HREF="#gdImageOpenPolygon">gdImageOpenPolygon</A>
1672 and <A HREF="#gdImageFilledPolygon">gdImageFilledPolygon</A>.
1673 </DL>
1674 <DT><A NAME="gdFTStringExtra">gdFTStringExtra</a> <strong>(TYPE)</strong>
1675 <DD>
1676 A structure used to pass additional parameters to the
1677 <a href="#gdImageStringFTEx">gdImageStringFTEx</a> function. See
1678 <a href="#gdImageStringFTEx">gdImageStringFTEx</a> for the
1679 structure definition.
1680 </DD>
1681 <DT><A NAME="gdFTStringExtraPtr">gdFTStringExtraPtr</a> <strong>(TYPE)</strong>
1682 <DD>
1683 A pointer to a structure used to pass additional parameters to the
1684 <a href="#gdImageStringFTEx">gdImageStringFTEx</a> function. See
1685 <a href="#gdImageStringFTEx">gdImageStringFTEx</a> for the
1686 structure definition.
1687 </DD>
1688 <DT><A NAME="gdSource">gdSource</A> <strong>(TYPE)</strong>
1689 <DD>
1690 <pre>
1691 typedef struct {
1692 int (*source) (void *context, char *buffer, int len);
1693 void *context;
1694 } gdSource, *gdSourcePtr;
1695 </pre>
1696 Represents a source from which a PNG can be read.
1697 Programmers who do not wish to read PNGs from a file can provide
1698 their own alternate input mechanism, using the
1699 <a href="#gdImageCreateFromPngSource">gdImageCreateFromPngSource</a> function.
1700 See the documentation of that function for an example of the
1701 proper use of this type.
1702 <DT><A NAME="gdSink">gdSink</A> <strong>(TYPE)</strong>
1703 <DD>
1704 <PRE>
1705 typedef struct {
1706 int (*sink) (void *context, char *buffer, int len);
1707 void *context;
1708 } gdSink, *gdSinkPtr;
1709 </PRE>
1710 Represents a "sink" (destination) to which a PNG can be written.
1711 Programmers who do not wish to write PNGs to a file can provide
1712 their own alternate output mechanism, using the
1713 <a href="#gdImagePngToSink">gdImagePngToSink</a> function.
1714 See the documentation of that function for an example of the
1715 proper use of this type.
1716 <H3><A NAME="creating">Image creation, destruction, loading and saving</A></H3>
1717 <DL>
1718 <DT><A NAME="gdImageCreate">gdImageCreate(sx, sy)</A>
1719 <strong>(FUNCTION)</strong>
1720 <DD>
1721 gdImageCreate is called to create palette-based images, with no
1722 more than 256 colors. Invoke gdImageCreate
1723 with the x and y dimensions of the desired image. gdImageCreate
1724 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or
1725 NULL if unable to
1726 allocate the image. The image must eventually be destroyed
1727 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
1728 <PRE>
1729 ... inside a function ...
1730 <A HREF="#gdImagePtr">gdImagePtr</A> im;
1731 im = gdImageCreate(64, 64);
1732 /* ... Use the image ... */
1733 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
1734 </PRE>
1735 <DT><A NAME="gdImageCreateTrueColor">gdImageCreateTrueColor(sx, sy)</A>
1736 <strong>(FUNCTION)</strong>
1737 <DD>
1738 gdImageCreateTrueColor is called to create truecolor images, with
1739 an essentially unlimited number of colors. Invoke gdImageCreateTrueColor
1740 with the x and y dimensions of the desired image. gdImageCreateTrueColor
1741 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or
1742 NULL if unable to
1743 allocate the image. The image must eventually be destroyed
1744 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
1745 <p>
1746 Truecolor images are always filled with black at creation time.
1747 There is no concept of a "background" color index.
1748 <PRE>
1749 ... inside a function ...
1750 <A HREF="#gdImagePtr">gdImagePtr</A> im;
1751 im = gdImageCreateTrueColor(64, 64);
1752 /* ... Use the image ... */
1753 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
1754 </PRE>
1755 <DT><A NAME="gdImageCreateFromJpeg">gdImageCreateFromJpeg(FILE *in)</A>
1756 <strong>(FUNCTION)</strong>
1757 <br>
1758 <A NAME="gdImageCreateFromJpegPtr">gdImageCreateFromJpegPtr(int size, void *data)</A>
1759 <strong>(FUNCTION)</strong>
1760 <br>
1761 <A NAME="gdImageCreateFromJpegCtx">gdImageCreateFromJpegCtx(gdIOCtx *in)</A>
1762 <strong>(FUNCTION)</strong>
1763 <p>
1764 <DD>
1765 gdImageCreateFromJpeg is called to load truecolor images from JPEG format files.
1766 Invoke gdImageCreateFromJpeg with an already opened pointer to a file
1767 containing the desired image.
1768 gdImageCreateFromJpeg
1769 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new
1770 truecolor image, or NULL
1771 if unable to load the image (most often because the file is corrupt or
1772 does not contain a JPEG image). gdImageCreateFromJpeg does <em>not</em>
1773 close the file. You can inspect the sx and sy members of the
1774 image to determine its size. The image must eventually be destroyed
1775 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>. <strong>The
1776 returned image is always a truecolor image.</strong>
1777 <p>
1778 If you already have the
1779 image file in memory, pass the size of the file and a pointer to the
1780 file's data to gdImageCreateFromJpegPtr, which is otherwise identical
1781 to gdImageCreateFromJpeg.
1782 <p>
1783 <PRE>
1784 <A HREF="#gdImagePtr">gdImagePtr</A> im;
1785 ... inside a function ...
1786 FILE *in;
1787 in = fopen("myjpeg.jpg", "rb");
1788 im = gdImageCreateFromJpeg(in);
1789 fclose(in);
1790 /* ... Use the image ... */
1791 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
1792 </PRE>
1793 <DT><A NAME="gdImageCreateFromPng">gdImageCreateFromPng(FILE *in)</A>
1794 <strong>(FUNCTION)</strong>
1795 <BR><A NAME="gdImageCreateFromPngPtr">gdImageCreateFromPngPtr(int size, void *data)</A>
1796 <strong>(FUNCTION)</strong>
1797 <BR><A NAME="gdImageCreateFromPngCtx">gdImageCreateFromPngCtx(<a href=#gdioctx>gdIOCtx</a> *in)</A>
1798 <strong>(FUNCTION)</strong>
1799 <p>
1800 <DD>
1801 gdImageCreateFromPng is called to load images from PNG format files.
1802 Invoke gdImageCreateFromPng with an already opened pointer to a file
1803 containing the desired image.
1804 gdImageCreateFromPng
1805 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or NULL
1806 if unable to load the image (most often because the file is corrupt or
1807 does not contain a PNG image). gdImageCreateFromPng does <em>not</em>
1808 close the file. You can inspect the sx and sy members of the
1809 image to determine its size. The image must eventually be destroyed
1810 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
1811 <p>
1812 If you already have the
1813 image file in memory, pass the size of the file and a pointer to the
1814 file's data to gdImageCreateFromPngPtr, which is otherwise identical
1815 to gdImageCreateFromPng.
1816 <p>
1817 If the PNG image being loaded is a truecolor image, the resulting
1818 gdImagePtr will refer to a truecolor image. If the PNG image
1819 being loaded is a palette or grayscale image, the resulting
1820 gdImagePtr will refer to a palette image. gd retains only 8 bits
1821 of resolution for each of the red, green and blue channels, and
1822 only 7 bits of resolution for the alpha channel. The former
1823 restriction affects only a handful of very rare 48-bit color
1824 and 16-bit grayscale PNG images. The second restriction affects
1825 all semitransparent PNG images, but the difference is essentially
1826 invisible to the eye. 7 bits of alpha channel resolution is,
1827 in practice, quite a lot.
1828 <PRE>
1829 <A HREF="#gdImagePtr">gdImagePtr</A> im;
1830 ... inside a function ...
1831 FILE *in;
1832 in = fopen("mypng.png", "rb");
1833 im = gdImageCreateFromPng(in);
1834 fclose(in);
1835 /* ... Use the image ... */
1836 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
1837 </PRE>
1838 <DT><A NAME="gdImageCreateFromPngSource">gdImageCreateFromPngSource(gdSourcePtr in)</A>
1839 <strong>(FUNCTION)</strong>
1840 <dd>
1841 <b>Deprecated</b> in favor of
1842 <a href="#gdImageCreateFromPngCtx">gdImageCreateFromPngCtx</a>. Should
1843 not be used in new applications.
1844 <p>
1845 gdImageCreateFromPngSource is called to load a PNG from
1846 a data source other than a file. Usage is very similar to
1847 the <a href="#gdImageCreateFromPng">gdImageCreateFromPng</a> function,
1848 except that the programmer provides a custom data source.
1849 <p>
1850 The programmer must write an input function which accepts
1851 a context pointer, a buffer, and a number of bytes to be
1852 read as arguments. This function must read the number of
1853 bytes requested, unless the end of the file has been reached,
1854 in which case the function should return zero, or an error
1855 has occurred, in which case the function should return
1856 <code>-1</code>. The programmer then creates a
1857 <a href="#gdSource">gdSource</a> structure and sets
1858 the <code>source</code> pointer to the input function and
1859 the context pointer to any value which is useful to the
1860 programmer.
1861 <p>
1862 The example below
1863 implements <a href="#gdImageCreateFromPng">gdImageCreateFromPng</a>
1864 by creating a custom data source and invoking gdImageCreateFromPngSource.
1865 <pre>
1866 static int freadWrapper(void *context, char *buf, int len);
1867
1868 gdImagePtr gdImageCreateFromPng(FILE *in)
1869 {
1870 gdSource s;
1871 s.source = freadWrapper;
1872 s.context = in;
1873 return gdImageCreateFromPngSource(&s);
1874 }
1875
1876 static int freadWrapper(void *context, char *buf, int len)
1877 {
1878 int got = fread(buf, 1, len, (FILE *) context);
1879 return got;
1880 }
1881 </pre>
1882 <DT><A NAME="gdImageCreateFromGif">gdImageCreateFromGif(FILE *in)</A>
1883 <strong>(FUNCTION)</strong>
1884 <BR><A NAME="gdImageCreateFromGifPtr">gdImageCreateFromGifPtr(int size, void *data)</A>
1885 <strong>(FUNCTION)</strong>
1886 <BR><A NAME="gdImageCreateFromGifCtx">gdImageCreateFromGifCtx(<a href=#gdioctx>gdIOCtx</a> *in)</A>
1887 <strong>(FUNCTION)</strong>
1888 <p>
1889 <DD>
1890 gdImageCreateFromGif is called to load images from GIF format files.
1891 Invoke gdImageCreateFromGif with an already opened pointer to a file
1892 containing the desired image.
1893 gdImageCreateFromGif
1894 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or NULL
1895 if unable to load the image (most often because the file is corrupt or
1896 does not contain a GIF image). gdImageCreateFromGif does <em>not</em>
1897 close the file. You can inspect the sx and sy members of the
1898 image to determine its size. The image must eventually be destroyed
1899 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
1900 <p>
1901 If you already have the
1902 image file in memory, pass the size of the file and a pointer to the
1903 file's data to gdImageCreateFromGifPtr, which is otherwise identical
1904 to gdImageCreateFromGif.
1905 <PRE>
1906 <A HREF="#gdImagePtr">gdImagePtr</A> im;
1907 ... inside a function ...
1908 FILE *in;
1909 in = fopen("mygif.gif", "rb");
1910 im = gdImageCreateFromGif(in);
1911 fclose(in);
1912 /* ... Use the image ... */
1913 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
1914 </PRE>
1915 <DT><A NAME="gdImageCreateFromGd">gdImageCreateFromGd(FILE *in)</A>
1916 <strong>(FUNCTION)</strong>
1917 <br><DT><A NAME="gdImageCreateFromGdPtr">gdImageCreateFromGdPtr(int size, void *data)</A>
1918 <strong>(FUNCTION)</strong>
1919 <BR><A NAME="gdImageCreateFromGdCtx">gdImageCreateFromGdCtx(<a href=#gdioctx>gdIOCtx</a> *in)</A>
1920 <strong>(FUNCTION)</strong>
1921 <p>
1922 <DD>
1923 gdImageCreateFromGd is called to load images from gd format files.
1924 Invoke gdImageCreateFromGd
1925 with an already opened pointer to a file containing the desired image
1926 in the <A HREF="#gdformat">gd file format</A>, which is specific to
1927 gd and intended for very fast loading. (It is <em>not</em> intended for
1928 compression; for compression, use PNG or JPEG.)
1929 <p>
1930 If you already have the
1931 image file in memory, pass the size of the file and a pointer to the
1932 file's data to gdImageCreateFromGdPtr, which is otherwise identical
1933 to gdImageCreateFromGd.
1934 <p>
1935 gdImageCreateFromGd
1936 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or NULL
1937 if unable to load the image (most often because the file is corrupt or
1938 does not contain a gd format image). gdImageCreateFromGd does <em>not</em>
1939 close the file. You can inspect the sx and sy members of the
1940 image to determine its size. The image must eventually be destroyed
1941 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
1942 <PRE>
1943 ... inside a function ...
1944 <A HREF="#gdImagePtr">gdImagePtr</A> im;
1945 FILE *in;
1946 in = fopen("mygd.gd", "rb");
1947 im = gdImageCreateFromGd(in);
1948 fclose(in);
1949 /* ... Use the image ... */
1950 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
1951 </PRE>
1952
1953 <DT><A NAME="gdImageCreateFromGd2">gdImageCreateFromGd2(FILE *in)</A>
1954 <strong>(FUNCTION)</strong>
1955 <br><A NAME="gdImageCreateFromGd2Ptr">gdImageCreateFromGd2Ptr(int size, void *data)</A>
1956 <strong>(FUNCTION)</strong>
1957 <BR><A NAME="gdImageCreateFromGd2Ctx">gdImageCreateFromGd2Ctx(<a href=#gdioctx>gdIOCtx</a> *in)</A>
1958 <strong>(FUNCTION)</strong>
1959 <p>
1960
1961 <DD>
1962 gdImageCreateFromGd2 is called to load images from gd2 format files.
1963 Invoke gdImageCreateFromGd2
1964 with an already opened pointer to a file containing the desired image
1965 in the <A HREF="#gdformat">gd2 file format</A>, which is specific to
1966 gd2 and intended for fast loading of parts of large images.
1967 (It is a compressed format, but generally not as good as maximum
1968 compression of the entire image would be.)
1969 <p>
1970 If you already have the
1971 image file in memory, pass the size of the file and a pointer to the
1972 file's data to gdImageCreateFromGd2Ptr, which is otherwise identical
1973 to gdImageCreateFromGd2.
1974 <p>
1975 gdImageCreateFromGd2
1976 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or NULL
1977 if unable to load the image (most often because the file is corrupt or
1978 does not contain a gd format image). gdImageCreateFromGd2 does <em>not</em>
1979 close the file. You can inspect the sx and sy members of the
1980 image to determine its size. The image must eventually be destroyed
1981 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
1982 <PRE>
1983 ... inside a function ...
1984 <A HREF="#gdImagePtr">gdImagePtr</A> im;
1985 FILE *in;
1986 in = fopen("mygd.gd2", "rb");
1987 im = gdImageCreateFromGd2(in);
1988 fclose(in);
1989 /* ... Use the image ... */
1990 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
1991 </PRE>
1992
1993 <DT><A NAME="gdImageCreateFromGd2Part">gdImageCreateFromGd2Part(FILE *in, int srcX, int srcY, int w, int h)</A>
1994 <strong>(FUNCTION)</strong>
1995 <br><A NAME="gdImageCreateFromGd2PartPtr">gdImageCreateFromGd2PartPtr(int size, void *data, int srcX, int srcY, int w, int h)</A>
1996 <strong>(FUNCTION)</strong>
1997 <BR><A NAME="gdImageCreateFromGd2PartCtx">gdImageCreateFromGd2PartCtx(<a href=#gdioctx>gdIOCtx</a> *in)</A>
1998 <strong>(FUNCTION)</strong>
1999 <p>
2000
2001 <DD>
2002 gdImageCreateFromGd2Part is called to load parts of images from <A HREF="#gdformat">gd2 format files</a>.
2003 Invoked in the same way as <a href=#gdImageCreateFromGd2>gdImageCreateFromGd2</a>,
2004 but with extra parameters
2005 indicating the source (x, y) and width/height of the desired image.
2006 gdImageCreateFromGd2Part returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the
2007 new image, or NULL if unable to load the image.
2008 The image must eventually be destroyed using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
2009 <p>
2010 If you already have the image file in memory, you may use
2011 gdImageCreateFromGd2PartPtr. Pass the size of the image file,
2012 in bytes, as the first argument and the pointer to the image file data
2013 as the second argument.
2014 <p>
2015 <DT><A NAME="gdImageCreateFromWBMP">gdImageCreateFromWBMP(FILE *in)</A>
2016 <strong>(FUNCTION)</strong>
2017 <BR><A NAME="gdImageCreateFromWBMPPtr">gdImageCreateFromWBMPPtr(int size, void *data)</A>
2018 <strong>(FUNCTION)</strong>
2019 <BR><A NAME="gdImageCreateFromWBMPCtx">gdImageCreateFromWBMPCtx(<a href=#gdioctx>gdIOCtx</a> *in)</A>
2020 <strong>(FUNCTION)</strong>
2021 <p>
2022 <DD>
2023 gdImageCreateFromWBMP is called to load images from WBMP format files.
2024 Invoke gdImageCreateFromWBMP with an already opened pointer to a file
2025 containing the desired image.
2026 gdImageCreateFromWBMP
2027 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or NULL
2028 if unable to load the image (most often because the file is corrupt or
2029 does not contain a PNG image). gdImageCreateFromWBMP does <em>not</em>
2030 close the file. You can inspect the sx and sy members of the
2031 image to determine its size. The image must eventually be destroyed
2032 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
2033 <p>
2034 If you already have the
2035 image file in memory, pass the size of the file and a pointer to the
2036 file's data to gdImageCreateFromWBMPPtr, which is otherwise identical
2037 to gdImageCreateFromWBMP.
2038 <PRE>
2039 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2040 ... inside a function ...
2041 FILE *in;
2042 in = fopen("mywbmp.wbmp", "rb");
2043 im = gdImageCreateFromWBMP(in);
2044 fclose(in);
2045 /* ... Use the image ... */
2046 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2047 </PRE>
2048 <p>
2049 <DT><A NAME="gdImageCreateFromXbm">gdImageCreateFromXbm(FILE *in)</A>
2050 <strong>(FUNCTION)</strong>
2051 <DD>
2052 gdImageCreateFromXbm is called to load images from X bitmap format
2053 files. Invoke gdImageCreateFromXbm
2054 with an already opened pointer to a file containing the desired image.
2055 gdImageCreateFromXbm
2056 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or NULL
2057 if unable to load the image (most often because the file is corrupt or
2058 does not contain an X bitmap format image). gdImageCreateFromXbm does
2059 <em>not</em> close the file. You can inspect the sx and sy members of the
2060 image to determine its size. The image must eventually be destroyed
2061 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
2062 <PRE>
2063 ... inside a function ...
2064 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2065 FILE *in;
2066 in = fopen("myxbm.xbm", "rb");
2067 im = gdImageCreateFromXbm(in);
2068 fclose(in);
2069 /* ... Use the image ... */
2070 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2071 </PRE>
2072 <DT><A NAME="gdImageCreateFromXpm">gdImageCreateFromXpm(char *filename)</A>
2073 <strong>(FUNCTION)</strong>
2074 <DD>
2075 gdImageCreateFromXbm is called to load images from XPM X Window System
2076 color bitmap format files. This function is available only if HAVE_XPM
2077 is selected in the Makefile and the Xpm library is linked with the
2078 application. Unlike most gd file functions, the Xpm functions require
2079 filenames, not file pointers.
2080 gdImageCreateFromXpm
2081 returns a <A HREF="#gdImagePtr">gdImagePtr</A> to the new image, or NULL
2082 if unable to load the image (most often because the file is corrupt or
2083 does not contain an XPM bitmap format image). You can inspect the sx and sy members of the
2084 image to determine its size. The image must eventually be destroyed
2085 using <A HREF="#gdImageDestroy">gdImageDestroy()</A>.
2086 <PRE>
2087 ... inside a function ...
2088 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2089 FILE *in;
2090 in = fopen("myxpm.xpm", "rb");
2091 im = gdImageCreateFromXpm(in);
2092 fclose(in);
2093 /* ... Use the image ... */
2094 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2095 </PRE>
2096 <DT><A NAME="gdImageDestroy">gdImageDestroy(gdImagePtr im)</A> <STRONG>(FUNCTION)</STRONG>
2097 <DD>gdImageDestroy is used to free the memory associated with
2098 an image. It is important to invoke gdImageDestroy before
2099 exiting your program or assigning a new image to
2100 a <A HREF="#gdImagePtr">gdImagePtr</A> variable.
2101 <PRE>
2102 ... inside a function ...
2103 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2104 im = <A HREF="#gdImageCreate">gdImageCreate</A>(10, 10);
2105 /* ... Use the image ... */
2106 /* Now destroy it */
2107 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2108 </PRE>
2109 <DT><A NAME="gdImageJpeg">
2110 void gdImageJpeg(gdImagePtr im, FILE *out, int quality)</A>
2111 <STRONG>(FUNCTION)</STRONG><BR>
2112 <a name="gdImageJpegCtx">void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality)</A>
2113 <STRONG>(FUNCTION)</STRONG><BR>
2114 <DD>
2115 gdImageJpeg outputs the specified image to the specified
2116 file in JPEG format. The file must be open for writing. Under MSDOS
2117 and all versions of Windows, it is important to use "wb" as opposed
2118 to simply "w" as the mode when opening the file, and under Unix there
2119 is no penalty for doing so. gdImageJpeg does <em>not</em>
2120 close the file; your code must do so.
2121 <P>
2122 If quality is negative, the default IJG JPEG quality value (which
2123 should yield a good general quality / size tradeoff for most
2124 situations) is used. Otherwise, for practical purposes, quality
2125 should be a value in the range 0-95, higher quality values usually
2126 implying both higher quality and larger image sizes.
2127 <P>
2128 If you have set image interlacing using
2129 <A HREF="#gdImageInterlace">gdImageInterlace</A>, this function will
2130 interpret that to mean you wish to output a progressive JPEG. Some
2131 programs (e.g., Web browsers) can display progressive JPEGs
2132 incrementally; this can be useful when browsing over a relatively slow
2133 communications link, for example. Progressive JPEGs can also be
2134 slightly smaller than sequential (non-progressive) JPEGs.
2135 <PRE>
2136 ... inside a function ...
2137 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2138 int black, white;
2139 FILE *out;
2140 /* Create the image */
2141 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2142 /* Allocate background */
2143 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2144 /* Allocate drawing color */
2145 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2146 /* Draw rectangle */
2147 <A HREF="#gdImageRectangle">gdImageRectangle</A>(im, 0, 0, 99, 99, black);
2148 /* Open output file in binary mode */
2149 out = fopen("rect.jpg", "wb");
2150 /* Write JPEG using default quality */
2151 gdImageJpeg(im, out, -1);
2152 /* Close file */
2153 fclose(out);
2154 /* Destroy image */
2155 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2156 </PRE>
2157 <DT><A NAME="gdImageJpegPtr">
2158 void* gdImageJpegPtr(gdImagePtr im, int *size, int quality)</A>
2159 <STRONG>(FUNCTION)</STRONG>
2160 <DD>Identical to gdImageJpeg except that it returns a pointer to a memory
2161 area with the JPEG data. This memory must be freed by the caller when it is
2162 no longer needed. <strong>The caller must invoke gdFree(), not free(),
2163 unless the caller is absolutely certain that the same implementations of
2164 malloc, free, etc. are used both at library build time and at application
2165 build time.</strong> The 'size' parameter receives the total size of the block
2166 of memory.
2167 <DT><A NAME="gdImageGif">
2168 void gdImageGif(gdImagePtr im, FILE *out)</A>
2169 <br>
2170 <A NAME="gdImageGifCtx">
2171 void gdImageGifCtx(gdImagePtr im, gdIOCtx *out)</A>
2172
2173 <STRONG>(FUNCTION)</STRONG>
2174 <DD>
2175 gdImageGif outputs the specified image to the specified
2176 file in GIF format. The file must be open for writing. Under MSDOS
2177 and all versions of Windows, it is important to use "wb" as opposed
2178 to simply "w" as the mode when opening the file, and under Unix there
2179 is no penalty for doing so. gdImageGif does <em>not</em>
2180 close the file; your code must do so.
2181 <p>
2182 GIF does not support true color; GIF images can contain a maximum
2183 of 256 colors. If the image to be written is a
2184 truecolor image, such as those created with
2185 <a href="#gdImageCreateTrueColor">gdImageCreateTrueColor</a> or loaded
2186 from a JPEG or a truecolor PNG image file, a palette-based
2187 temporary image will automatically be created internally using the
2188 <a href="#gdImageCreatePaletteFromTrueColor">gdImageCreatePaletteFromTrueColor</a> function. The original image pixels are not modified. This conversion
2189 produces high quality palettes but does require some CPU time. If you are
2190 regularly converting truecolor to palette in this way, you should consider
2191 creating your image as a palette-based image in the first place.
2192 <PRE>
2193 ... inside a function ...
2194 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2195 int black, white;
2196 FILE *out;
2197 /* Create the image */
2198 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2199 /* Allocate background */
2200 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2201 /* Allocate drawing color */
2202 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2203 /* Draw rectangle */
2204 <A HREF="#gdImageRectangle">gdImageRectangle</A>(im, 0, 0, 99, 99, black);
2205 /* Open output file in binary mode */
2206 out = fopen("rect.gif", "wb");
2207 /* Write GIF */
2208 gdImageGif(im, out);
2209 /* Close file */
2210 fclose(out);
2211 /* Destroy image */
2212 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2213 </PRE>
2214 <DT><A NAME="gdImageGifPtr">
2215 void* gdImageGifPtr(gdImagePtr im, int *size)</A>
2216 <STRONG>(FUNCTION)</STRONG>
2217 <DD>Identical to gdImageGif except that it returns a pointer to a memory
2218 area with the GIF data. This memory must be freed by the caller when it is
2219 no longer needed. <strong>The caller must invoke gdFree(), not free(),
2220 unless the caller is absolutely certain that the same implementations of
2221 malloc, free, etc. are used both at library build time and at application
2222 build time.</strong> The 'size' parameter receives the total size of the block
2223 of memory.
2224
2225 <DT><A NAME="gdImageGifAnimBegin">
2226 void gdImageGifAnimBegin(gdImagePtr im, FILE *out, int GlobalCM, int Loops)</A>
2227 <br>
2228 <A NAME="gdImageGifAnimBeginCtx">
2229 void gdImageGifAnimBeginCtx(gdImagePtr im, gdIOCtx *out, int GlobalCM, int Loops)</A>
2230
2231 <STRONG>(FUNCTION)</STRONG>
2232
2233 <DD>This function must be called as the first function when creating a
2234 GIF animation. It writes the correct GIF file headers to selected
2235 file output, and prepares for frames to be added for the animation.
2236 The image argument is not used to produce an image frame to the file,
2237 it is only used to establish the GIF animation frame size, interlacing
2238 options and the color palette. gdImageGifAnimAdd is used to
2239 add the first and subsequent frames to the animation, and the animation
2240 must be terminated by writing a semicolon character (;) to it or by using
2241 gdImageGifAnimEnd to do that.
2242 <p>
2243
2244 The GlobalCM flag indicates if a global color map (or palette) is used
2245 in the GIF89A header. A nonzero value specifies that a global color
2246 map should be used to reduce the size of the animation.
2247 Of course, if the color maps of
2248 individual frames differ greatly, a global color map may not be a good idea.
2249 GlobalCM=1 means write global color map, GlobalCM=0 means do not, and
2250 GlobalCM=-1 means to do the default, which currently is to use a global
2251 color map.
2252
2253 <p>
2254
2255 If Loops is 0 or greater, the Netscape 2.0 extension for animation
2256 loop count is written. 0 means infinite loop count. -1 means that
2257 the extension is not added which results in no looping. -1 is the
2258 default.
2259
2260 <DT><A NAME="gdImageGifAnimBeginPtr">
2261 void* gdImageGifAnimBeginPtr(gdImagePtr im, int *size, int GlobalCM, int Loops)</A>
2262 <STRONG>(FUNCTION)</STRONG>
2263 <DD>Identical to gdImageGifAnimBegin except that it returns a pointer
2264 to a memory area with the GIF data. This memory must be freed by the
2265 caller when it is no longer needed. <strong>The caller must invoke
2266 gdFree(), not free(), unless the caller is absolutely certain that the
2267 same implementations of malloc, free, etc. are used both at library
2268 build time and at application build time.</strong> The 'size'
2269 parameter receives the total size of the block of memory.
2270
2271 <DT><A NAME="gdImageGifAnimAdd">
2272 void gdImageGifAnimAdd(gdImagePtr im, FILE *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm)</A>
2273 <br>
2274 <A NAME="gdImageGifAnimAddCtx">
2275 void gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm)</A>
2276
2277 <STRONG>(FUNCTION)</STRONG>
2278
2279 <DD> This function writes GIF animation frames to GIF animation, which
2280 was initialized with <a
2281 href="#gdImageGifAnimBegin">gdImageGifAnimBegin</a>. With LeftOfs and
2282 TopOfs you can place this frame in different offset than (0,0) inside
2283 the image screen as defined in gdImageGifAnimBegin. Delay between the
2284 previous frame and this frame is in 1/100s units. Disposal is usually
2285 <code>gdDisposalNone</code>, meaning that the pixels changed by this
2286 frame should remain on the display when the next frame begins to render, but
2287 can also be <code>gdDisposalUnknown</code> (not recommended),
2288 <code>gdDisposalRestoreBackground</code> (restores the first
2289 allocated color of the global palette), or
2290 <code>gdDisposalRestorePrevious</code> (restores the appearance of the
2291 affected area before the frame was rendered). Only
2292 <code>gdDisposalNone</code> is a sensible choice for the first frame.
2293 If <code>previm</code> is
2294 passed, the built-in GIF optimizer will always use <code>gdDisposalNone</code>
2295 regardless of the Disposal parameter.
2296 <p>
2297 Setting the LocalCM flag to 1 adds a local palette for this image to the
2298 animation. Otherwise the global palette is assumed and the user must make
2299 sure the palettes match. Use <A HREF="#gdImagePaletteCopy">gdImagePaletteCopy</A> to do that.
2300
2301 <p>
2302
2303 Automatic optimization is activated by giving the previous image as a
2304 parameter. This function then compares the images and only writes the changed
2305 pixels to the new frame in animation. The Disposal parameter for
2306 optimized animations must be set to 1, also for the first frame.
2307 LeftOfs and TopOfs parameters are ignored for optimized frames. To
2308 achieve good optimization, it is usually best to use a single global
2309 color map. To allow gdImageGifAnimAdd to compress unchanged pixels via
2310 the use of a transparent color, the image must include a transparent color.
2311
2312 <PRE>
2313 ... inside a function ...
2314 gdImagePtr im, im2, im3;
2315 int black, white, trans;
2316 FILE *out;
2317 /* Create the image */
2318 im = gdImageCreate(100, 100);
2319 /* Allocate background */
2320 white = gdImageColorAllocate(im, 255, 255, 255);
2321 /* Allocate drawing color */
2322 black = gdImageColorAllocate(im, 0, 0, 0);
2323 /* Allocate transparent color for animation compression */
2324 trans = gdImageColorAllocate(im, 1, 1, 1);
2325 /* Draw rectangle */
2326 gdImageRectangle(im, 0, 0, 10, 10, black);
2327 /* Open output file in binary mode */
2328 out = fopen("anim.gif", "wb");
2329 /* Write GIF header. Use global color map. Loop a few times */
2330 gdImageGifAnimBegin(im, out, 1, 3);
2331 /* Write the first frame. No local color map. Delay = 1s */
2332 gdImageGifAnimAdd(im, out, 0, 0, 0, 100, 1, NULL);
2333 /* construct the second frame */
2334 im2 = gdImageCreate(100, 100);
2335 /* Allocate background to make it white */
2336 (void)gdImageColorAllocate(im2, 255, 255, 255);
2337 /* Make sure the palette is identical */
2338 gdImagePaletteCopy (im2, im);
2339 /* Draw something */
2340 gdImageRectangle(im2, 0, 0, 15, 15, black);
2341 /* Allow animation compression with transparent pixels */
2342 gdImageColorTransparent (im2, trans);
2343 /* Add the second frame */
2344 gdImageGifAnimAdd(im2, out, 0, 0, 0, 100, 1, im);
2345 /* construct the second frame */
2346 im3 = gdImageCreate(100, 100);
2347 /* Allocate background to make it white */
2348 (void)gdImageColorAllocate(im3, 255, 255, 255);
2349 /* Make sure the palette is identical */
2350 gdImagePaletteCopy (im3, im);
2351 /* Draw something */
2352 gdImageRectangle(im3, 0, 0, 15, 20, black);
2353 /* Allow animation compression with transparent pixels */
2354 gdImageColorTransparent (im3, trans);
2355 /* Add the third frame, compressing against the second one */
2356 gdImageGifAnimAdd(im3, out, 0, 0, 0, 100, 1, im2);
2357 /* Write the end marker */
2358 /* gdImageGifAnimEnd(out); is the same as the following: */
2359 putc (';', out);
2360 /* Close file */
2361 fclose(out);
2362 /* Destroy images */
2363 gdImageDestroy(im);
2364 gdImageDestroy(im2);
2365 gdImageDestroy(im3);
2366 </PRE>
2367
2368 <DT><A NAME="gdImageGifAnimAddPtr">
2369 void* gdImageGifAnimAddPtr(gdImagePtr im, int *size, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm)</A>
2370 <STRONG>(FUNCTION)</STRONG>
2371 <DD>Identical to gdImageGifAnimAdd except that it returns a pointer
2372 to a memory area with the GIF data. This memory must be freed by the
2373 caller when it is no longer needed. <strong>The caller must invoke
2374 gdFree(), not free(), unless the caller is absolutely certain that the
2375 same implementations of malloc, free, etc. are used both at library
2376 build time and at application build time.</strong> The 'size'
2377 parameter receives the total size of the block of memory.
2378
2379 <DT><A NAME="gdImageGifAnimEnd">
2380 void gdImageGifAnimEnd(FILE *out)</A>
2381 <br>
2382 <A NAME="gdImageGifAnimEndCtx">
2383 void gdImageGifAnimEndCtx(gdIOCtx *out)</A>
2384
2385 <STRONG>(FUNCTION)</STRONG>
2386
2387 <DD>Writes semicolon character (;) to the output file. This
2388 terminates the GIF file properly. You can omit the call to
2389 gdImageGifAnimEnd and just print out the semicolon.
2390
2391 <DT><A NAME="gdImageGifAnimEndPtr">
2392 void* gdImageGifAnimEndPtr(int *size)</A>
2393 <STRONG>(FUNCTION)</STRONG>
2394
2395 <DD>Returns a one byte string containing the semicolon character (;).
2396 Returns a pointer to a memory area with that string. This memory must
2397 be freed by the caller when it is no longer needed. <strong>The caller
2398 must invoke gdFree(), not free(), unless the caller is absolutely
2399 certain that the same implementations of malloc, free, etc. are used
2400 both at library build time and at application build time.</strong> The
2401 'size' parameter receives the total size of the block of memory. The
2402 string ";" can be used in place of this function.
2403
2404 <DT><A NAME="gdImagePng">
2405 void gdImagePng(gdImagePtr im, FILE *out)</A>
2406 <br>
2407 <A NAME="gdImagePngCtx">
2408 void gdImagePngCtx(gdImagePtr im, gdIOCtx *out)</A>
2409
2410 <STRONG>(FUNCTION)</STRONG>
2411 <DD>
2412 gdImagePng outputs the specified image to the specified
2413 file in PNG format. The file must be open for writing. Under MSDOS
2414 and all versions of Windows, it is important to use "wb" as opposed
2415 to simply "w" as the mode when opening the file, and under Unix there
2416 is no penalty for doing so. gdImagePng does <em>not</em>
2417 close the file; your code must do so.
2418 <PRE>
2419 ... inside a function ...
2420 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2421 int black, white;
2422 FILE *out;
2423 /* Create the image */
2424 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2425 /* Allocate background */
2426 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2427 /* Allocate drawing color */
2428 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2429 /* Draw rectangle */
2430 <A HREF="#gdImageRectangle">gdImageRectangle</A>(im, 0, 0, 99, 99, black);
2431 /* Open output file in binary mode */
2432 out = fopen("rect.png", "wb");
2433 /* Write PNG */
2434 gdImagePng(im, out);
2435 /* Close file */
2436 fclose(out);
2437 /* Destroy image */
2438 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2439 </PRE>
2440 <DT><A NAME="gdImagePngEx">
2441 void gdImagePngEx(gdImagePtr im, FILE *out, int level)</A>
2442 <br>
2443 <A NAME="gdImagePngCtxEx">
2444 void gdImagePngCtxEx(gdImagePtr im, gdIOCtx *out, int level)</A>
2445
2446 <STRONG>(FUNCTION)</STRONG>
2447 <DD>
2448 Like <a href="#gdImagePng">gdImagePng</a>, gdImagePngEx outputs the
2449 specified image to the specified file in PNG format. In addition,
2450 gdImagePngEx allows the level of compression to be specified. A compression
2451 level of 0 means "no compression." A compression level of 1 means
2452 "compressed, but as quickly as possible." A compression level of 9
2453 means "compressed as much as possible to produce the smallest possible
2454 file." A compression level of -1 will use the default compression level
2455 at the time zlib was compiled on your system.
2456 <p>
2457 For more information, see <a href="#gdImagePng">gdImagePng</a>.
2458 <DT><A NAME="gdImagePngPtr">
2459 void* gdImagePngPtr(gdImagePtr im, int *size)</A>
2460 <STRONG>(FUNCTION)</STRONG>
2461 <DD>Identical to gdImagePng except that it returns a pointer to a memory
2462 area with the PNG data. This memory must be freed by the caller when it is
2463 no longer needed. <strong>The caller must invoke gdFree(), not free(),
2464 unless the caller is absolutely certain that the same implementations of
2465 malloc, free, etc. are used both at library build time and at application
2466 build time.</strong> The 'size' parameter receives the total size of the block
2467 of memory.
2468 <DT><A NAME="gdImagePngPtrEx">
2469 void* gdImagePngPtrEx(gdImagePtr im, int *size, int level)</A>
2470 <STRONG>(FUNCTION)</STRONG>
2471 <DD>
2472 Like <a href="#gdImagePngPtr">gdImagePngPtr</a>, gdImagePngPtrEx returns a
2473 pointer to a PNG image in allocated memory.
2474 In addition, gdImagePngPtrEx allows the level of compression to be
2475 specified. A compression level of 0 means "no compression." A compression level of 1 means
2476 "compressed, but as quickly as possible." A compression level of 9
2477 means "compressed as much as possible to produce the smallest possible
2478 file." A compression level of -1 will use the default compression level
2479 at the time zlib was compiled on your system.
2480 <p>
2481 For more information, see <a href="#gdImagePngPtr">gdImagePngPtr</a>.
2482 <DT><A NAME="gdImagePngToSink">gdImagePngToSink(gdImagePtr im, gdSinkPtr out)</A>
2483 <strong>(FUNCTION)</strong>
2484 <dd>
2485 gdImagePngToSink is called to write a PNG to
2486 a data "sink" (destination) other than a file. Usage is very similar to
2487 the <a href="#gdImagePng">gdImagePng</a> function,
2488 except that the programmer provides a custom data sink.
2489 <p>
2490 The programmer must write an output function which accepts
2491 a context pointer, a buffer, and a number of bytes to be
2492 written as arguments. This function must write the number of
2493 bytes requested and return that number, unless an error
2494 has occurred, in which case the function should return
2495 <code>-1</code>. The programmer then creates a
2496 <a href="#gdSink">gdSink</a> structure and sets
2497 the <code>sink</code> pointer to the output function and
2498 the context pointer to any value which is useful to the
2499 programmer.
2500 <p>
2501 The example below
2502 implements <a href="#gdImagePng">gdImagePng</a>
2503 by creating a custom data source and invoking gdImagePngFromSink.
2504 <pre>
2505 static int stdioSink(void *context, char *buffer, int len)
2506 {
2507 return fwrite(buffer, 1, len, (FILE *) context);
2508 }
2509
2510 void gdImagePng(gdImagePtr im, FILE *out)
2511 {
2512 gdSink mySink;
2513 mySink.context = (void *) out;
2514 mySink.sink = stdioSink;
2515 gdImagePngToSink(im, &mySink);
2516 }
2517 </pre>
2518 <DT><A NAME="gdImageWBMP">
2519 void gdImageWBMP(gdImagePtr im, int fg, FILE *out)</A>
2520 <BR><A NAME="gdImageWBMPCtx">gdImageWBMPCtx(<a href=#gdioctx>gdIOCtx</a> *out)</A>
2521 <strong>(FUNCTION)</strong><STRONG>(FUNCTION)</STRONG>
2522 <DD>
2523 gdImageWBMP outputs the specified image to the specified
2524 file in WBMP format. The file must be open for writing. Under MSDOS
2525 and all versions of Windows, it is important to use "wb" as opposed
2526 to simply "w" as the mode when opening the file, and under Unix there
2527 is no penalty for doing so. gdImageWBMP does <em>not</em>
2528 close the file; your code must do so.
2529 <p>
2530 <strong>WBMP file support is black and white only. The color index
2531 specified by the fg argument is the "foreground," and only pixels
2532 of this color will be set in the WBMP file.</strong> All other pixels
2533 will be considered "background."
2534 <PRE>
2535 ... inside a function ...
2536 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2537 int black, white;
2538 FILE *out;
2539 /* Create the image */
2540 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2541 /* Allocate background */
2542 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2543 /* Allocate drawing color */
2544 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2545 /* Draw rectangle */
2546 <A HREF="#gdImageRectangle">gdImageRectangle</A>(im, 0, 0, 99, 99, black);
2547 /* Open output file in binary mode */
2548 out = fopen("rect.wbmp", "wb");
2549 /* Write WBMP, with black as foreground */
2550 gdImageWBMP(im, black, out);
2551 /* Close file */
2552 fclose(out);
2553 /* Destroy image */
2554 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2555 </PRE>
2556 <DT><A NAME="gdImageWBMPPtr">
2557 void* gdImageWBMPPtr(gdImagePtr im, int *size)</A>
2558 <STRONG>(FUNCTION)</STRONG>
2559 <DD>Identical to gdImageWBMP except that it returns a pointer to a memory
2560 area with the WBMP data. This memory must be freed by the caller when it is
2561 no longer needed. <strong>The caller must invoke gdFree(), not free(),
2562 unless the caller is absolutely certain that the same implementations of
2563 malloc, free, etc. are used both at library build time and at application
2564 build time.</strong> The 'size' parameter receives the total size of the block
2565 of memory.
2566 <DT><A NAME="gdImageGd">
2567 void gdImageGd(gdImagePtr im, FILE *out)</A>
2568 <STRONG>(FUNCTION)</STRONG>
2569 <DD>
2570 gdImageGd outputs the specified image to the specified
2571 file in the <A HREF="#gdformat">gd image format</A>. The file must
2572 be open for writing. Under MSDOS and all versions of Windows, it is
2573 important to use "wb" as
2574 opposed to simply "w" as the mode when opening the file, and under
2575 Unix there is no penalty for doing so. gdImagePng does <em>not</em>
2576 close the file; your code must do so.
2577 <P>
2578 The gd image format is intended for fast reads and writes of
2579 images your program will need frequently to build other
2580 images. It is <em>not</em> a compressed format, and is not intended
2581 for general use.
2582 <PRE>
2583 ... inside a function ...
2584 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2585 int black, white;
2586 FILE *out;
2587 /* Create the image */
2588 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2589 /* Allocate background */
2590 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2591 /* Allocate drawing color */
2592 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2593 /* Draw rectangle */
2594 <A HREF="#gdImageRectangle">gdImageRectangle</A>(im, 0, 0, 99, 99, black);
2595 /* Open output file in binary mode */
2596 out = fopen("rect.gd", "wb");
2597 /* Write gd format file */
2598 gdImageGd(im, out);
2599 /* Close file */
2600 fclose(out);
2601 /* Destroy image */
2602 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2603 </PRE>
2604
2605 <DT><A NAME="gdImageGdPtr">
2606 void* gdImageGdPtr(gdImagePtr im, int *size)</A>
2607 <STRONG>(FUNCTION)</STRONG>
2608 <DD>Identical to gdImageGd except that it returns a pointer to a memory
2609 area with the GD data. This memory must be freed by the caller when it is
2610 no longer needed. <strong>The caller must invoke gdFree(), not free(),
2611 unless the caller is absolutely certain that the same implementations of
2612 malloc, free, etc. are used both at library build time and at application
2613 build time.</strong> The 'size' parameter receives the total size of the block
2614 of memory.
2615
2616 <DT><A NAME="gdImageGd2">
2617 void gdImageGd2(gdImagePtr im, FILE *out, int chunkSize, int fmt)</A>
2618 <br>
2619 <A NAME="gdImageGd2Ctx">
2620 void gdImageGd2Ctx(gdImagePtr im, gdIOCtx *out, int chunkSize, int fmt)</A>
2621 <STRONG>(FUNCTION)</STRONG>
2622 <DD>
2623 gdImageGd2 outputs the specified image to the specified
2624 file in the <A HREF="#gd2format">gd2 image format</A>. The file must
2625 be open for writing. Under MSDOS and all versions of Windows, it is
2626 important to use "wb" as
2627 opposed to simply "w" as the mode when opening the file, and under
2628 Unix there is no penalty for doing so. gdImageGd2 does <em>not</em>
2629 close the file; your code must do so.
2630 <P>
2631 The gd2 image format is intended for fast reads and writes of
2632 parts of images.
2633 It is a compressed format, and well suited to retrieving smll sections of
2634 much larger images.
2635
2636 The third and fourth parameters are the 'chunk size' and format resposectively.
2637 <p>
2638 The file is stored as a series of compressed subimages, and the
2639 <strong>Chunk Size</strong> determines the sub-image size - a value of
2640 zero causes the GD library to use the default.
2641 <p>
2642 It is also possible to store GD2 files in an uncompressed format, in which case the
2643 fourth parameter should be GD2_FMT_RAW.
2644
2645 <PRE>
2646 ... inside a function ...
2647 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2648 int black, white;
2649 FILE *out;
2650 /* Create the image */
2651 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2652 /* Allocate background */
2653 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2654 /* Allocate drawing color */
2655 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2656 /* Draw rectangle */
2657 <A HREF="#gdImageRectangle">gdImageRectangle</A>(im, 0, 0, 99, 99, black);
2658 /* Open output file in binary mode */
2659 out = fopen("rect.gd", "wb");
2660 /* Write gd2 format file */
2661 gdImageGd2(im, out, 0, GD2_FMT_COMPRESSED);
2662 /* Close file */
2663 fclose(out);
2664 /* Destroy image */
2665 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2666 </PRE>
2667
2668 <DT><A NAME="gdImageGd2Ptr">
2669 void* gdImageGd2Ptr(gdImagePtr im, int chunkSize, int fmt, int *size)</A>
2670 <STRONG>(FUNCTION)</STRONG>
2671 <DD>Identical to gdImageGd2 except that it returns a pointer to a memory
2672 area with the GD2 data. This memory must be freed by the caller when it is
2673 no longer needed. <strong>The caller must invoke gdFree(), not free(),
2674 unless the caller is absolutely certain that the same implementations of
2675 malloc, free, etc. are used both at library build time and at application
2676 build time.</strong> The 'size' parameter receives the total size of the block
2677 of memory.
2678 <DT><A NAME="gdImageTrueColorToPalette">
2679 void gdImageTrueColorToPalette(gdImagePtr im, int ditherFlag, int colorsWanted)</A>
2680 <br>
2681 <A NAME="gdImageCreatePaletteFromTrueColor">
2682 gdImagePtr gdImageCreatePaletteFromTrueColor(gdImagePtr im, int ditherFlag, int colorsWanted)</A>
2683
2684 <STRONG>(FUNCTION)</STRONG>
2685 <DD>
2686 <blockquote>
2687 gdImageCreatePaletteFromTrueColor returns a <b>new</b>
2688 image. gdImageTrueColorToPalette permanently converts the
2689 <b>existing</b> image. The two functions are otherwise identical.
2690 </blockquote>
2691 <p>
2692 The function converts a truecolor image to a palette-based image,
2693 using a high-quality two-pass quantization routine.
2694 If ditherFlag is set, the image will be
2695 dithered to approximate colors better, at the expense
2696 of some obvious "speckling." colorsWanted can be
2697 anything up to 256. If the original source image
2698 includes photographic information or anything that
2699 came out of a JPEG, 256 is strongly recommended.
2700 100% transparency of a single transparent color in the
2701 original truecolor image will be preserved. There is no other
2702 support for preservation of alpha channel or transparency in
2703 the destination image.
2704 <p>
2705 For best results, don't use this function -- write real
2706 truecolor PNGs and JPEGs. The disk space gain of
2707 conversion to palette is not great (for small images
2708 it can be negative) and the quality loss is ugly. However,
2709 the version of this function included in version 2.0.12 and later does
2710 do a better job than the version included prior to 2.0.12.
2711 </DL>
2712 <H3><A NAME="drawing">Drawing Functions</A></H3>
2713 <DL>
2714 <DT><A NAME="gdImageSetPixel">void gdImageSetPixel(gdImagePtr im, int x, int y, int color)</A> <STRONG>(FUNCTION)</STRONG>
2715 <DD>gdImageSetPixel sets a pixel to a particular color index. Always use
2716 this function or one of the other drawing functions to access pixels;
2717 do not access the pixels of the <A HREF="#gdImage">gdImage</A> structure
2718 directly.
2719 <PRE>
2720 ... inside a function ...
2721 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2722 int black;
2723 int white;
2724 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2725 /* Background color (first allocated) */
2726 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2727 /* Allocate the color white (red, green and blue all maximum). */
2728 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2729 /* Set a pixel near the center. */
2730 gdImageSetPixel(im, 50, 50, white);
2731 /* ... Do something with the image, such as
2732 saving it to a file... */
2733 /* Destroy it */
2734 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2735 </PRE>
2736 <DT><A NAME="gdImageLine">void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color)</A>
2737 <STRONG>(FUNCTION)</STRONG>
2738 <DD>
2739 gdImageLine is used to draw a line between two endpoints (x1,y1 and x2, y2).
2740 The line is drawn using the color index specified. Note that the color
2741 index can be an actual color returned by <A HREF="#gdImageColorAllocate">
2742 gdImageColorAllocate</A> or one of <A HREF="#gdStyled">gdStyled</A>,
2743 <A HREF="#gdBrushed">gdBrushed</A> or <A HREF="#gdStyledBrushed">
2744 gdStyledBrushed</A>.
2745 <PRE>
2746 ... inside a function ...
2747 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2748 int black;
2749 int white;
2750 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2751 /* Background color (first allocated) */
2752 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2753 /* Allocate the color white (red, green
2754 and blue all maximum). */
2755 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2756 /* Draw a line from the upper left corner to the
2757 lower right corner. */
2758 gdImageLine(im, 0, 0, 99, 99, white);
2759 /* ... Do something with the image, such as
2760 saving it to a file... */
2761 /* Destroy it */
2762 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2763 </PRE>
2764 <DT><A NAME="gdImageDashedLine">void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2, int color)</A>
2765 <STRONG>(FUNCTION)</STRONG>
2766 <DD>
2767 gdImageDashedLine is provided <strong>solely for backwards compatibility
2768 </strong> with gd 1.0. New programs should draw dashed lines using
2769 the normal <A HREF="#gdImageLine">gdImageLine</A> function and the
2770 new <A HREF="#gdImageSetStyle">gdImageSetStyle</A> function.
2771 <P>
2772 gdImageDashedLine is used to draw a dashed line between two endpoints
2773 (x1,y1 and x2, y2).
2774 The line is drawn using the color index specified. The portions of the line
2775 that are not drawn are left transparent so the background is visible.
2776 <PRE>
2777 ... inside a function ...
2778 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2779 int black;
2780 int white;
2781 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2782 /* Background color (first allocated) */
2783 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2784 /* Allocate the color white (red, green and blue
2785 all maximum). */
2786 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2787 /* Draw a dashed line from the upper left corner
2788 to the lower right corner. */
2789 gdImageDashedLine(im, 0, 0, 99, 99);
2790 /* ... Do something with the image, such as
2791 saving it to a file... */
2792 /* Destroy it */
2793 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2794 </PRE>
2795 <DT><A NAME="gdImagePolygon">void gdImagePolygon(gdImagePtr im, gdPointPtr points, int pointsTotal, int color)</A>
2796 <STRONG>(FUNCTION)</STRONG>
2797 <DD>
2798 gdImagePolygon is used to draw a polygon with the verticies
2799 (at least 3) specified, using the color index specified.
2800 See also <A HREF="#gdImageFilledPolygon">gdImageFilledPolygon</A>.
2801 <PRE>
2802 ... inside a function ...
2803 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2804 int black;
2805 int white;
2806 /* Points of polygon */
2807 <A HREF="#gdPoint">gdPoint</A> points[3];
2808 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2809 /* Background color (first allocated) */
2810 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2811 /* Allocate the color white (red, green and
2812 blue all maximum). */
2813 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2814 /* Draw a triangle. */
2815 points[0].x = 50;
2816 points[0].y = 0;
2817 points[1].x = 99;
2818 points[1].y = 99;
2819 points[2].x = 0;
2820 points[2].y = 99;
2821 gdImagePolygon(im, points, 3, white);
2822 /* ... Do something with the image, such as
2823 saving it to a file... */
2824 /* Destroy it */
2825 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2826 </PRE>
2827 <DT><A NAME="gdImageOpenPolygon">void gdImageOpenPolygon(gdImagePtr im, gdPointPtr points, int pointsTotal, int color)</A>
2828 <STRONG>(FUNCTION)</STRONG>
2829 <DD>
2830 gdImageOpenPolygon is used to draw a sequence of lines with the verticies
2831 (at least 3) specified, using the color index specified. Unlike
2832 <A HREF="#gdImagePolygon">gdImagePolygon</A>, the enpoints of the line
2833 sequence are not connected to a closed polygon.
2834 <DT><A NAME="gdImageRectangle">void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)</A>
2835 <STRONG>(FUNCTION)</STRONG>
2836 <DD>
2837 gdImageRectangle is used to draw a rectangle with the two corners
2838 (upper left first, then lower right) specified, using the
2839 color index specified.
2840 <PRE>
2841 ... inside a function ...
2842 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2843 int black;
2844 int white;
2845 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2846 /* Background color (first allocated) */
2847 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2848 /* Allocate the color white (red, green and blue all maximum). */
2849 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2850 /* Draw a rectangle occupying the central area. */
2851 gdImageRectangle(im, 25, 25, 74, 74, white);
2852 /* ... Do something with the image, such as
2853 saving it to a file... */
2854 /* Destroy it */
2855 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2856 </PRE>
2857 <DT><A NAME="gdImageFilledPolygon">void gdImageFilledPolygon(gdImagePtr im, gdPointPtr points, int pointsTotal, int color)</A>
2858 <STRONG>(FUNCTION)</STRONG>
2859 <DD>
2860 gdImageFilledPolygon is used to fill a polygon with the verticies
2861 (at least 3) specified, using the color index specified.
2862 See also <A HREF="#gdImageFilledPolygon">gdImagePolygon</A>.
2863 <PRE>
2864 ... inside a function ...
2865 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2866 int black;
2867 int white;
2868 int red;
2869 /* Points of polygon */
2870 <A HREF="#gdPoint">gdPoint</A> points[3];
2871 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2872 /* Background color (first allocated) */
2873 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2874 /* Allocate the color white (red, green and blue all maximum). */
2875 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2876 /* Allocate the color red. */
2877 red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);
2878 /* Draw a triangle. */
2879 points[0].x = 50;
2880 points[0].y = 0;
2881 points[1].x = 99;
2882 points[1].y = 99;
2883 points[2].x = 0;
2884 points[2].y = 99;
2885 /* Paint it in white */
2886 gdImageFilledPolygon(im, points, 3, white);
2887 /* Outline it in red; must be done second */
2888 <A HREF="#gdImagePolygon">gdImagePolygon</A>(im, points, 3, red);
2889 /* ... Do something with the image, such as
2890 saving it to a file... */
2891 /* Destroy it */
2892 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2893 </PRE>
2894 <DT><A NAME="gdImageFilledRectangle">void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int y2, int color)</A>
2895 <STRONG>(FUNCTION)</STRONG>
2896 <DD>
2897 gdImageFilledRectangle is used to draw a solid rectangle with the two corners
2898 (upper left first, then lower right) specified, using the
2899 color index specified.
2900 <PRE>
2901 ... inside a function ...
2902 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2903 int black;
2904 int white;
2905 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
2906 /* Background color (first allocated) */
2907 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2908 /* Allocate the color white (red, green and blue all maximum). */
2909 white = <A HREF="#gdImageColorAllocate">int gdImageColorAllocate</A>(im, 255, 255, 255);
2910 /* Draw a filled rectangle occupying the central area. */
2911 gdImageFilledRectangle(im, 25, 25, 74, 74, white);
2912 /* ... Do something with the image, such as
2913 saving it to a file... */
2914 /* Destroy it */
2915 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2916 </PRE>
2917 <DT><A NAME="gdImageArc">void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color)</A>
2918 <STRONG> (FUNCTION)</STRONG>
2919 <DD>
2920 gdImageArc is used to draw a partial ellipse centered at the given point,
2921 with the specified width and height in pixels. The arc begins at
2922 the position in degrees specified by <code>s</code> and ends at
2923 the position specified by <code>e</code>. The arc is drawn in
2924 the color specified by the last argument. A circle can be drawn
2925 by beginning from 0 degrees and ending at 360 degrees, with
2926 width and height being equal. e must be greater than s. Values greater
2927 than 360 are interpreted modulo 360.
2928 <PRE>
2929 ... inside a function ...
2930 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2931 int black;
2932 int white;
2933 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 50);
2934 /* Background color (first allocated) */
2935 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2936 /* Allocate the color white (red, green and blue all maximum). */
2937 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2938 /* Inscribe an ellipse in the image. */
2939 gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
2940 /* ... Do something with the image, such as
2941 saving it to a file... */
2942 /* Destroy it */
2943 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2944 </PRE>
2945 <DT><A NAME="gdImageFilledArc">void gdImageFilledArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int color, int style)</A>
2946 <STRONG> (FUNCTION)</STRONG>
2947 <DD>
2948 gdImageFilledArc is used to draw a partial ellipse centered at the given point,
2949 with the specified width and height in pixels. The arc begins at
2950 the position in degrees specified by <code>s</code> and ends at
2951 the position specified by <code>e</code>. The arc is filled in
2952 the color specified by the second to last argument. A circle can be drawn
2953 by beginning from 0 degrees and ending at 360 degrees, with
2954 width and height being equal. e must be greater than s. Values greater
2955 than 360 are interpreted modulo 360. The last argument is a bitwise
2956 OR of the following possibilities:
2957 <ul>
2958 <li>gdArc
2959 <li>gdChord
2960 <li>gdPie (synonym for gdChord)
2961 <li>gdNoFill
2962 <li>gdEdged
2963 </ul>
2964 gdArc and gdChord are mutually exclusive;
2965 gdChord just connects the starting and ending
2966 angles with a straight line, while gdArc produces
2967 a rounded edge. gdPie is a synonym for gdArc.
2968 gdNoFill indicates that the arc or chord should be
2969 outlined, not filled. gdEdged, used together with
2970 gdNoFill, indicates that the beginning and ending
2971 angles should be connected to the center; this is
2972 a good way to outline (rather than fill) a
2973 'pie slice'.
2974
2975 <PRE>
2976 ... inside a function ...
2977 <A HREF="#gdImagePtr">gdImagePtr</A> im;
2978 int black;
2979 int white;
2980 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 50);
2981 /* Background color (first allocated) */
2982 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
2983 /* Allocate the color white (red, green and blue all maximum). */
2984 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
2985 /* Inscribe a filled pie slice in the image. */
2986 gdImageFilledArc(im, 50, 25, 98, 48, 0, 45, white, gdArc);
2987 /* ... Do something with the image, such as
2988 saving it to a file... */
2989 /* Destroy it */
2990 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
2991 </PRE>
2992 <DT><A NAME="gdImageFilledEllipse">void gdImageFilledEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color)</A>
2993 <STRONG> (FUNCTION)</STRONG>
2994 <DD>
2995 gdImageFilledEllipse is used to draw an ellipse centered at the given point,
2996 with the specified width and height in pixels. The ellipse is filled in
2997 the color specified by the last argument.
2998 <PRE>
2999 ... inside a function ...
3000 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3001 int black;
3002 int white;
3003 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 50);
3004 /* Background color (first allocated) */
3005 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3006 /* Allocate the color white (red, green and blue all maximum). */
3007 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3008 /* Inscribe a filled ellipse in the image. */
3009 gdImageFilledEllipse(im, 50, 25, 98, 48, white);
3010 /* ... Do something with the image, such as
3011 saving it to a file... */
3012 /* Destroy it */
3013 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3014 </PRE>
3015 <DT><A NAME="gdImageFillToBorder">void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color)
3016 <STRONG> (FUNCTION)</STRONG>
3017 <DD>
3018 gdImageFillToBorder floods a portion of the image with the specified
3019 <code>color</code>, beginning at the specified point and stopping at
3020 the specified <code>border</code> color. For a way of flooding an
3021 area defined by the color of the starting point, see
3022 <A HREF="#gdImageFill">gdImageFill</A>.
3023 <P>
3024 The border color <em>cannot</em> be a special color
3025 such as <A HREF="#gdTiled">gdTiled</A>; it must be a proper
3026 solid color. The fill color can be, however.
3027 <P>
3028 Note that gdImageFillToBorder is recursive. It is not the most
3029 naive implementation possible, and the implementation is
3030 expected to improve, but there will always be degenerate
3031 cases in which the stack can become very deep. This can be
3032 a problem in MSDOS and MS Windows 3.1 environments. (Of course,
3033 in a Unix or Windows 95/98/NT environment with a proper stack, this is
3034 not a problem at all.)
3035 <PRE>
3036 ... inside a function ...
3037 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3038 int black;
3039 int white;
3040 int red;
3041 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 50);
3042 /* Background color (first allocated) */
3043 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3044 /* Allocate the color white (red, green and blue all maximum). */
3045 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3046 /* Allocate the color red. */
3047 red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);
3048 /* Inscribe an ellipse in the image. */
3049 gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
3050 /* Flood-fill the ellipse. Fill color is red, border color is
3051 white (ellipse). */
3052 gdImageFillToBorder(im, 50, 50, white, red);
3053 /* ... Do something with the image, such as
3054 saving it to a file... */
3055 /* Destroy it */
3056 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3057 </PRE>
3058 <DT><A NAME="gdImageFill">void gdImageFill(gdImagePtr im, int x, int y, int color)
3059 <STRONG> (FUNCTION)</STRONG>
3060 <DD>
3061 gdImageFill floods a portion of the image with the specified
3062 <code>color</code>, beginning at the specified point and flooding the
3063 surrounding region of the same color as the starting point.
3064 For a way of flooding a region defined by a specific border
3065 color rather than by its interior color, see
3066 <A HREF="#gdImageFillToBorder">gdImageFillToBorder</A>.
3067 <P>
3068 The fill color can be <A HREF="#gdTiled">gdTiled</A>, resulting
3069 in a tile fill using another image as the tile. However,
3070 the tile image cannot be transparent. If the image you wish
3071 to fill with has a transparent color index, call
3072 <A HREF="#gdImageTransparent">gdImageTransparent</A> on the
3073 tile image and set the transparent color index to -1
3074 to turn off its transparency.
3075 <P>
3076 Note that gdImageFill is recursive. It is not the most
3077 naive implementation possible, and the implementation is
3078 expected to improve, but there will always be degenerate
3079 cases in which the stack can become very deep. This can be
3080 a problem in MSDOS and MS Windows environments. (Of course,
3081 in a Unix or Windows 95/98/NT environment with a proper stack, this is
3082 not a problem at all.)
3083 <PRE>
3084 ... inside a function ...
3085 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3086 int black;
3087 int white;
3088 int red;
3089 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 50);
3090 /* Background color (first allocated) */
3091 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3092 /* Allocate the color white (red, green and blue all maximum). */
3093 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3094 /* Allocate the color red. */
3095 red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);
3096 /* Inscribe an ellipse in the image. */
3097 gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
3098 /* Flood-fill the ellipse. Fill color is red, and will replace the
3099 black interior of the ellipse. */
3100 gdImageFill(im, 50, 50, red);
3101 /* ... Do something with the image, such as
3102 saving it to a file... */
3103 /* Destroy it */
3104 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3105 </PRE>
3106 <DT><A NAME="gdImageSetAntiAliased">void gdImageSetAntiAliased(gdImagePtr im, int c)</A>
3107 <STRONG>(FUNCTION)</STRONG>
3108 <DD>
3109 "Antialiasing" is a process by which jagged edges associated with line
3110 drawing can be reduced by blending the foreground color with an appropriate
3111 percentage of the background, depending on how much of the pixel in question
3112 is actually within the boundaries of the line being drawn.
3113 All line-drawing functions,
3114 such as <A HREF="#gdImageLine">gdImageLine</A>,
3115 <A HREF="#gdImageOpenPolygon">gdImageOpenPolygon</A> and
3116 <A HREF="#gdImagePolygon">gdImagePolygon</A>, will draw antialiased lines
3117 if the special "color" <A HREF="#gdAntiAliased">
3118 gdAntiAliased</A> is used when calling them.
3119 <P>
3120 gdImageSetAntiAliased is used to specify the actual foreground color
3121 to be used when drawing antialiased lines. You may set any color to
3122 be the foreground, however as of version 2.0.12 an alpha channel
3123 component is not supported.
3124 <p>
3125 Antialiased lines can be drawn on both truecolor and palette-based
3126 images. However, attempts to draw antialiased lines on
3127 highly complex palette-based backgrounds may not give satisfactory
3128 results, due to the limited number of colors available in the
3129 palette. Antialiased line-drawing on simple backgrounds should
3130 work well with palette-based images; otherwise create or fetch
3131 a truecolor image instead.
3132 <P>
3133 You need not take any special action when you are finished
3134 with antialised line drawing.
3135 <PRE>
3136 ... inside a function ...
3137 <A HREF="#gdImagePtr">gdImagePtr</A> im, brush;
3138 int black;
3139 int blue;
3140 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3141 /* Background color (first allocated) */
3142 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3143 blue = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 255);
3144 gdImageSetAntiAliased(im, blue);
3145 /* Draw a smooth line from the upper left corner to the
3146 lower right corner. */
3147 <A HREF="#gdImageLine">gdImageLine</A>(im, 0, 0, 99, 99, <A HREF="#gdBrushed">gdAntiAliased</A>);
3148 /* ... Do something with the image, such as
3149 saving it to a file... */
3150 /* Destroy it */
3151 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3152 </PRE>
3153 See also <a href="#gdAntiAliased">gdAntiAliased</a> and
3154 <a href="#gdSetAntiAliasedDontBlend">gdSetAntiAliasedDontBlend</a>.
3155 <DT><A NAME="gdImageSetAntiAliasedDontBlend">void gdImageSetAntiAliasedDontBlend(gdImagePtr im, int c)</A>
3156 <STRONG>(FUNCTION)</STRONG>
3157 <DD>
3158 Normally, when drawing lines with the special
3159 <a href="#gdAntiAliased">gdAntiAliased</a> "color," blending with the
3160 background to reduce jagged edges is the desired behavior. However, when
3161 it is desired that lines not be blended with one particular color when
3162 it is encountered in the background, the
3163 gdImageSetAntiAliasedDontBlend function can be used to indicate the
3164 special color that the foreground should stand out more clearly against.
3165 <PRE>
3166 ... inside a function ...
3167 <A HREF="#gdImagePtr">gdImagePtr</A> im, brush;
3168 int black;
3169 int blue;
3170 int white;
3171 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3172 /* Background color (first allocated) */
3173 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3174 blue = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 255);
3175 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3176
3177 gdImageSetAntiAliased(im, blue);
3178 /* The portion of the line that crosses this white rectangle will
3179 not be blended smoothly */
3180 gdImageSetAntiAliasedDontBlend(im, white);
3181 gdImageFilledRectangle(im, 25, 25, 75, 75, white);
3182 /* Draw a smooth line from the upper left corner
3183 to the lower right corner. */
3184 <A HREF="#gdImageLine">gdImageLine</A>(im, 0, 0, 99, 99, <A HREF="#gdBrushed">gdAntiAliased</A>);
3185 /* ... Do something with the image, such as
3186 saving it to a file... */
3187 /* Destroy it */
3188 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3189 </PRE>
3190 See also <a href="#gdAntiAliased">gdAntiAliased</a> and
3191 <a href="#gdSetAntiAliased">gdSetAntiAliased</a>.
3192 <DT><A NAME="gdImageSetBrush">void gdImageSetBrush(gdImagePtr im, gdImagePtr brush)</A>
3193 <STRONG>(FUNCTION)</STRONG>
3194 <DD>
3195 A "brush" is an image used to draw wide, shaped strokes in another image. Just
3196 as a paintbrush is not a single point, a brush image need not be
3197 a single pixel. <em>Any</em> gd image can be used as a brush, and by
3198 setting the transparent color index of the brush image with
3199 <A HREF="#gdImageColorTransparent">gdImageColorTransparent</A>,
3200 a brush of any shape can be created. All line-drawing functions,
3201 such as <A HREF="#gdImageLine">gdImageLine</A>,
3202 <A HREF="#gdImageOpenPolygon">gdImageOpenPolygon</A> and
3203 <A HREF="#gdImagePolygon">gdImagePolygon</A>, will use the
3204 current brush if the special "color" <A HREF="#gdBrushed">
3205 gdBrushed</A> or <A HREF="#gdStyledBrushed">gdStyledBrushed</A>
3206 is used when calling them.
3207 <P>
3208 gdImageSetBrush is used to specify the brush to be used in a
3209 particular image. You can set any image to be the brush.
3210 If the brush image does not have the same color map as the
3211 first image, any colors missing from the first image
3212 will be allocated. If not enough colors can be allocated,
3213 the closest colors already available will be used. This
3214 allows arbitrary PNGs to be used as brush images. It also
3215 means, however, that you should not set a brush unless you
3216 will actually use it; if you set a rapid succession of
3217 different brush images, you can quickly fill your color map,
3218 and the results will not be optimal.
3219 <P>
3220 You need not take any special action when you are finished
3221 with a brush. As for any other image, if you will not
3222 be using the brush image for any further purpose,
3223 you should call <A HREF="#gdImageDestroy">gdImageDestroy</A>.
3224 You must not use the color <A HREF="#gdBrushed">gdBrushed</A>
3225 if the current brush has been destroyed; you can of
3226 course set a new brush to replace it.
3227 <PRE>
3228 ... inside a function ...
3229 <A HREF="#gdImagePtr">gdImagePtr</A> im, brush;
3230 FILE *in;
3231 int black;
3232 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3233 /* Open the brush PNG. For best results, portions of the
3234 brush that should be transparent (ie, not part of the
3235 brush shape) should have the transparent color index. */
3236 in = fopen("star.png", "rb");
3237 brush = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
3238 /* Background color (first allocated) */
3239 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3240 gdImageSetBrush(im, brush);
3241 /* Draw a line from the upper left corner to the lower right corner
3242 using the brush. */
3243 <A HREF="#gdImageLine">gdImageLine</A>(im, 0, 0, 99, 99, <A HREF="#gdBrushed">gdBrushed</A>);
3244 /* ... Do something with the image, such as
3245 saving it to a file... */
3246 /* Destroy it */
3247 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3248 /* Destroy the brush image */
3249 <A HREF="#gdImageDestroy">gdImageDestroy</A>(brush);
3250 </PRE>
3251 <DT><A NAME="gdImageSetTile">void gdImageSetTile(gdImagePtr im, gdImagePtr tile)</A>
3252 <STRONG>(FUNCTION)</STRONG>
3253 <DD>
3254 A "tile" is an image used to fill an area with a repeated pattern.
3255 <em>Any</em> gd image can be used as a tile, and by
3256 setting the transparent color index of the tile image with
3257 <A HREF="#gdImageColorTransparent">gdImageColorTransparent</A>,
3258 a tile that allows certain parts of the underlying area to shine
3259 through can be created. All region-filling functions,
3260 such as <A HREF="#gdImageFill">gdImageFill</A> and
3261 <A HREF="#gdImageFilledPolygon">gdImageFilledPolygon</A>, will use the
3262 current tile if the special "color" <A HREF="#gdTiled">
3263 gdTiled</A> is used when calling them.
3264 <P>
3265 gdImageSetTile is used to specify the tile to be used in a
3266 particular image. You can set any image to be the tile.
3267 If the tile image does not have the same color map as the
3268 first image, any colors missing from the first image
3269 will be allocated. If not enough colors can be allocated,
3270 the closest colors already available will be used. This
3271 allows arbitrary PNGs to be used as tile images. It also
3272 means, however, that you should not set a tile unless you
3273 will actually use it; if you set a rapid succession of
3274 different tile images, you can quickly fill your color map,
3275 and the results will not be optimal.
3276 <P>
3277 You need not take any special action when you are finished
3278 with a tile. As for any other image, if you will not
3279 be using the tile image for any further purpose,
3280 you should call <A HREF="#gdImageDestroy">gdImageDestroy</A>.
3281 You must not use the color <A HREF="#gdBrushed">gdTiled</A>
3282 if the current tile has been destroyed; you can of
3283 course set a new tile to replace it.
3284 <PRE>
3285 ... inside a function ...
3286 <A HREF="#gdImagePtr">gdImagePtr</A> im, tile;
3287 FILE *in;
3288 int black;
3289 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3290 /* Open the tile PNG. For best results, portions of the
3291 tile that should be transparent (ie, allowing the
3292 background to shine through) should have the transparent
3293 color index. */
3294 in = fopen("star.png", "rb");
3295 tile = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
3296 /* Background color (first allocated) */
3297 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3298 gdImageSetTile(im, tile);
3299 /* Fill an area using the tile. */
3300 <A HREF="#gdImageFilledRectangle">gdImageFilledRectangle</A>(im, 25, 25, 75, 75, <A HREF="#gdTiled">gdTiled</A>);
3301 /* ... Do something with the image, such as
3302 saving it to a file... */
3303 /* Destroy it */
3304 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3305 /* Destroy the tile image */
3306 <A HREF="#gdImageDestroy">gdImageDestroy</A>(tile);
3307 </PRE>
3308 <DT><A NAME="gdImageSetStyle">void gdImageSetStyle(gdImagePtr im, int *style, int styleLength)</A>
3309 <STRONG>(FUNCTION)</STRONG>
3310 <DD>
3311 It is often desirable to draw dashed lines, dotted lines, and other
3312 variations on a broken line. gdImageSetStyle can be used to set
3313 any desired series of colors, including a special color that
3314 leaves the background intact, to be repeated during the drawing
3315 of a line.
3316 <P>
3317 To use gdImageSetStyle, create an array of integers and assign
3318 them the desired series of color values to be repeated.
3319 You can assign the special color value <A HREF="#gdTransparent">
3320 gdTransparent</A> to indicate that the existing color should
3321 be left unchanged for that particular pixel (allowing a dashed
3322 line to be attractively drawn over an existing image).
3323 <P>
3324 Then, to draw a line using the style, use the normal
3325 <A HREF="#gdImageLine">gdImageLine</A> function with the
3326 special color value <A HREF="#gdStyled">gdStyled</A>.
3327 <P>
3328 As of <A HREF="#whatsnew1.1.1">version 1.1.1</A>, the style
3329 array is copied when you set the style, so you need not
3330 be concerned with keeping the array around indefinitely.
3331 This should not break existing code that assumes styles
3332 are not copied.
3333 <P>
3334 You can also combine styles and brushes to draw the brush
3335 image at intervals instead of in a continuous stroke.
3336 When creating a style for use with a brush, the
3337 style values are interpreted differently: zero (0) indicates
3338 pixels at which the brush should not be drawn, while one (1)
3339 indicates pixels at which the brush should be drawn.
3340 To draw a styled, brushed line, you must use the
3341 special color value <A HREF="#gdStyledBrushed">
3342 gdStyledBrushed</A>. For an example of this feature
3343 in use, see gddemo.c (provided in the distribution).
3344 <PRE>
3345 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3346 int styleDotted[2], styleDashed[6];
3347 FILE *in;
3348 int black;
3349 int red;
3350 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3351 /* Background color (first allocated) */
3352 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3353 red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);
3354 /* Set up dotted style. Leave every other pixel alone. */
3355 styleDotted[0] = red;
3356 styleDotted[1] = gdTransparent;
3357 /* Set up dashed style. Three on, three off. */
3358 styleDashed[0] = red;
3359 styleDashed[1] = red;
3360 styleDashed[2] = red;
3361 styleDashed[3] = gdTransparent;
3362 styleDashed[4] = gdTransparent;
3363 styleDashed[5] = gdTransparent;
3364 /* Set dotted style. Note that we have to specify how many pixels are
3365 in the style! */
3366 gdImageSetStyle(im, styleDotted, 2);
3367 /* Draw a line from the upper left corner to the lower right corner. */
3368 <A HREF="#gdImageLine">gdImageLine</A>(im, 0, 0, 99, 99, <A HREF="#gdStyled">gdStyled</A>);
3369 /* Now the dashed line. */
3370 gdImageSetStyle(im, styleDashed, 6);
3371 <A HREF="#gdImageLine">gdImageLine</A>(im, 0, 99, 0, 99, <A HREF="#gdStyled">gdStyled</A>);
3372
3373 /* ... Do something with the image, such as
3374 saving it to a file ... */
3375
3376 /* Destroy it */
3377 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3378 </PRE>
3379 <DT><A NAME="gdImageSetThickness">void gdImageSetThickness(gdImagePtr im, int thickness)</A> <STRONG>(FUNCTION)</STRONG>
3380 <DD>gdImageSetThickness determines the width of lines drawn by the
3381 <a href="#gdImageLine">gdImageLine</a>, <a href="#gdImagePolygon">gdImagePolygon</a>, <a href="#gdImageOpenPolygon">gdImageOpenPolygon</a>
3382 and related functions, in pixels.
3383 <PRE>
3384 ... inside a function ...
3385 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3386 int black;
3387 int white;
3388 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3389 /* Background color (first allocated) */
3390 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3391 /* Allocate the color white (red, green and blue all maximum). */
3392 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3393 /* Set thickness. */
3394 gdImageSetThickness(im, 4);
3395 /* Draw a fat line from the upper left corner to the lower right corner. */
3396 gdImageLine(im, 0, 0, 99, 99, white);
3397 /* ... Do something with the image, such as
3398 saving it to a file... */
3399 /* Destroy it */
3400 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3401 </PRE>
3402 <DT><A NAME="gdImageAlphaBlending">void gdImageAlphaBlending(gdImagePtr im, int blending)</A>
3403 <STRONG>(FUNCTION)</STRONG>
3404 <DD>
3405 The <a href="#gdImageAlphaBlending">gdImageAlphaBlending</a>
3406 function allows for two different modes of drawing on truecolor
3407 images. In blending mode, which is <strong>on by default (gd 2.0.2
3408 and above)</strong>, the alpha channel component of the color
3409 supplied to all drawing functions, such as
3410 <a href="#gdImageSetPixel">gdImageSetPixel</a>, determines how much of
3411 the underlying color should be allowed to shine through. As a result,
3412 gd automatically blends the existing color at that point with the
3413 drawing color, and stores the result in the image. The resulting pixel
3414 is opaque. In non-blending mode, the drawing color is copied literally
3415 with its alpha channel information, replacing the destination pixel.
3416 Blending mode is not available when drawing on palette images.
3417 <PRE>
3418 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3419 int red, blue;
3420 im = <A HREF="#gdImageCreate">gdImageCreateTrueColor</A>(100, 100);
3421 /* Background color */
3422 red = <A HREF="#gdTrueColor">gdTrueColor</A>(255, 0, 0);
3423 gdImageFilledRectangle(im, 0, 0, 100, 100, red);
3424 /* Drawing color. Full transparency would be an alpha channel value
3425 of 127 (gd has a 7 bit alpha chnanel). 0 is opaque,
3426 127 is transparent. So cut gdAlphaTransparent in half to get
3427 50% blending. */
3428 blue = <A HREF="#gdTrueColor">gdTrueColorAlpha</A>(0, 0, 255, gdAlphaTransparent / 2);
3429 /* Draw with blending. Result will be 50% red, 50% blue: yellow
3430 (emitted light, remember, not reflected light. What you learned
3431 in Kindergarten is wrong here). */
3432 gdImageAlphaBlending(im, 1);
3433 <a href="#gdImageFilledRectangle">gdImageFilledRectangle</a>(im, 0, 0, 25, 25, blue);
3434 /* Draw without blending. Result will be 50% blue, 50%
3435 the background color of the image viewer or web browser
3436 used; results in browsers that don't support
3437 semi-transparent pixels are unpredictable! */
3438 gdImageAlphaBlending(im, 0);
3439 <a href="#gdImageFilledRectangle">gdImageFilledRectangle</a>(im, 75, 75, 25, 25, blue);
3440 /* Write the image to disk, etc. */
3441 </pre>
3442 <DT><A NAME="gdImageSaveAlpha">
3443 void gdImageSaveAlpha(gdImagePtr im, int saveFlag)</A>
3444 <STRONG>(FUNCTION)</STRONG>
3445 <DD>
3446 By default, gd 2.0.2 and above do not attempt to save full alpha channel information
3447 (as opposed to single-color transparency) when saving PNG images. (PNG
3448 is currently the only output format supported by gd which can accommodate
3449 alpa channel information.) This saves space in the output file. If you wish
3450 to create an image with alpha channel information for use with tools that
3451 support it, call gdImageSaveAlpha(im, 1) to turn on saving of such
3452 information, and call <a href="#gdImageAlphaBlending">gdImageAlphaBlending(im, 0)</a>
3453 to turn off alpha blending within the library so that alpha channel
3454 information is actually stored in the image rather than being composited
3455 immediately at the time that drawing functions are invoked.
3456 <DT><A NAME="gdImageSetClip">
3457 void gdImageSetClip(gdImagePtr im, int x1, int y1, int x2, int y2)</A>
3458 <STRONG>(FUNCTION)</STRONG>
3459 <DD>
3460 Establishes a clipping rectangle. Once gdImageSetClip has been called,
3461 all future drawing operations will remain within the specified clipping
3462 area, until a new gdImageSetClip call takes place. For instance,
3463 if a clipping rectangle of 25, 25, 75, 75 has been set within a
3464 100x100 image, a diagonal line from 0,0 to 99,99 will appear only
3465 between 25,25 and 75,75.
3466 <p>
3467 If gdImageSetClip is never called, the clipping area will be the
3468 entire image.
3469 <p>
3470 The parameters passed to gdImageSetClip are checked against the dimensions
3471 of the image and limited to "safe" values.
3472 <PRE>
3473 ... inside a function ...
3474 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3475 int black;
3476 int white;
3477 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3478 /* Background color (first allocated) */
3479 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3480 /* Allocate the color white (red, green and blue all maximum). */
3481 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3482 /* Set the clipping rectangle. */
3483 gdImageSetClip(im, 25, 25, 75, 75);
3484 /* Draw a line from the upper left corner to the lower right corner.
3485 Only the part within the clipping rectangle will appear. */
3486 <a href="#gdImageLine">gdImageLine</a>(im, 0, 0, 99, 99, white);
3487 /* ... Do something with the image, such as
3488 saving it to a file ... */
3489 /* Destroy it */
3490 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3491 </PRE>
3492 See also <a href="#gdImageGetClip">gdImageGetClip</a>.
3493 <DT><A NAME="gdImageGetClip">
3494 void gdImageGetClip(gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P)</A>
3495 <STRONG>(FUNCTION)</STRONG>
3496 <DD>
3497 Fetches the boundaries of the current clipping rectangle.
3498 <pre>
3499 ... Inside a function ...
3500 gdImagePtr im = <a href="#gdImageCreateTrueColor">gdImageCreateTrueColor</a>(100, 100);
3501 int x1, y1, x2, y2;
3502 gdImageSetClip(im, 25, 25, 75, 75);
3503 gdImageGetClip(im, &x1, &y1, &x2, &y2);
3504 printf("%d %d %d %d\n", x1, y1, x2, y2);
3505 </pre>
3506 The above code would print:
3507 <pre>
3508 25 25 75 75
3509 </pre>
3510 See also <a href="#gdImageSetClip">gdImageSetClip</a>.
3511 </DL>
3512 <H3><A NAME="query">Query Functions</A></H3>
3513 <DL>
3514 <DT><A NAME="gdImageBlue">
3515 int gdImageAlpha(gdImagePtr im, int color)</A>
3516 <STRONG>(MACRO)</STRONG>
3517 <DD>
3518 gdImageAlpha is a macro which returns the alpha channel component of
3519 the specified color index. Alpha channel values vary between
3520 0 (gdAlphaOpaque), which does not blend at all with the background,
3521 through 127 (gdAlphaTransparent), which allows the background to
3522 shine through 100%. Use this macro rather than accessing the
3523 structure members directly.
3524 int gdImageBlue(gdImagePtr im, int color)</A>
3525 <STRONG>(MACRO)</STRONG>
3526 <DD>
3527 gdImageBlue is a macro which returns the blue component of
3528 the specified color index. Use this macro rather than accessing the
3529 structure members directly.
3530 <DT><A NAME="gdImageGetPixel">int gdImageGetPixel(gdImagePtr im, int x, int y)</A>
3531 <STRONG>(FUNCTION)</STRONG>
3532 <DD>
3533 gdImageGetPixel() retrieves the color index of a particular
3534 pixel. Always use this function to query pixels;
3535 do not access the pixels of the <A HREF="#gdImage">gdImage</A> structure
3536 directly.
3537 <PRE>
3538 ... inside a function ...
3539 FILE *in;
3540 gdImagePtr im;
3541 int c;
3542 in = fopen("mypng.png", "rb");
3543 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
3544 fclose(in);
3545 c = gdImageGetPixel(im, gdImageSX(im) / 2, gdImageSY(im) / 2);
3546 printf("The value of the center pixel is %d; RGB values are %d,%d,%d\n",
3547 c, im->red[c], im->green[c], im->blue[c]);
3548 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3549 </PRE>
3550 <DT><A NAME="gdImageBoundsSafe">
3551 int gdImageBoundsSafe(gdImagePtr im, int x, int y)</A>
3552 <STRONG>(FUNCTION)</STRONG>
3553 <DD>
3554 gdImageBoundsSafe returns true (1) if the specified point is within the
3555 current clipping rectangle, false (0) if not. The clipping rectangle is
3556 set by <a href="#gdImageSetClip">gdImageSetClip</a> and defaults
3557 to the entire image. This function is intended primarily for
3558 use by those who wish to add functions to gd. All of the gd drawing
3559 functions already clip safely using this function or its macro
3560 equivalent in gd.c, gdImageBoundsSafeMacro.
3561 <PRE>
3562 ... inside a function ...
3563 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3564 int black;
3565 int white;
3566 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3567 if (gdImageBoundsSafe(im, 50, 50)) {
3568 printf("50, 50 is within the image bounds\n");
3569 } else {
3570 printf("50, 50 is outside the image bounds\n");
3571 }
3572 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3573 </PRE>
3574 <DT><A NAME="gdImageGreen">
3575 int gdImageGreen(gdImagePtr im, int color)</A>
3576 <STRONG>(MACRO)</STRONG>
3577 <DD>
3578 gdImageGreen is a macro which returns the green component of
3579 the specified color index. Use this macro rather than accessing the
3580 structure members directly.
3581 <DT><A NAME="gdImageRed">
3582 int gdImageRed(gdImagePtr im, int color)</A>
3583 <STRONG>(MACRO)</STRONG>
3584 <DD>
3585 gdImageRed is a macro which returns the red component of
3586 the specified color index. Use this macro rather than accessing the
3587 structure members directly.
3588 <DT><A NAME="gdImageSX">
3589 int gdImageSX(gdImagePtr im)</A>
3590 <STRONG>(MACRO)</STRONG>
3591 <DD>
3592 gdImageSX is a macro which returns the width of the image
3593 in pixels. Use this macro rather than accessing the
3594 structure members directly.
3595 <DT><A NAME="gdImageSY">
3596 int gdImageSY(gdImagePtr im)</A>
3597 <STRONG>(MACRO)</STRONG>
3598 <DD>
3599 gdImageSY is a macro which returns the height of the image
3600 in pixels. Use this macro rather than accessing the
3601 structure members directly.
3602 </DL>
3603 <H3><A NAME="fonts">Fonts and text-handling functions</A></H3>
3604 <DL>
3605 <DT><A NAME="gdFontGetSmall">
3606 gdFontPtr gdFontGetSmall(void)</a>
3607 <STRONG>(FUNCTION)</STRONG>
3608 <DD>
3609 Returns a font pointer for the "small" gd font. Your code must
3610 include the header file <code>gdfonts.h</code> before
3611 calling this function. Under Windows, due to the nature of DLLs,
3612 the use of this function is strongly recommended rather than attempting
3613 to use the <code>gdFontSmall</code> pointer directly. (You may
3614 safely assign the result to a local <code>gdFontPtr</code> variable
3615 in your own code.)
3616 <p>
3617 See <a href="#gdImageString">gdImageString</a> for more information
3618 and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
3619 freetype-based alternative that supports truetype fonts.
3620 <DT><A NAME="gdFontGetLarge">
3621 gdFontPtr gdFontGetLarge(void)</a>
3622 <STRONG>(FUNCTION)</STRONG>
3623 <DD>
3624 Returns a font pointer for the "large" gd font. Your code must
3625 include the header file <code>gdfontl.h</code> before
3626 calling this function. Under Windows, due to the nature of DLLs,
3627 the use of this function is strongly recommended rather than attempting
3628 to use the <code>gdFontLarge</code> pointer directly. (You may
3629 safely assign the result to a local <code>gdFontPtr</code> variable
3630 in your own code.)
3631 <p>
3632 See <a href="#gdImageString">gdImageString</a> for more information
3633 and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
3634 freetype-based alternative that supports truetype fonts.
3635 <DT><A NAME="gdFontGetMediumBold">
3636 gdFontPtr gdFontGetMediumBold(void)</a>
3637 <STRONG>(FUNCTION)</STRONG>
3638 <DD>
3639 Returns a font pointer for the "medium bold" gd font. Your code must
3640 include the header file <code>gdfontmb.h</code> before
3641 calling this function. Under Windows, due to the nature of DLLs,
3642 the use of this function is strongly recommended rather than attempting
3643 to use the <code>gdFontMediumBold</code> pointer directly. (You may
3644 safely assign the result to a local <code>gdFontPtr</code> variable
3645 in your own code.)
3646 <p>
3647 See <a href="#gdImageString">gdImageString</a> for more information
3648 and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
3649 freetype-based alternative that supports truetype fonts.
3650 <DT><A NAME="gdFontGetGiant">
3651 gdFontPtr gdFontGetGiant(void)</a>
3652 <STRONG>(FUNCTION)</STRONG>
3653 <DD>
3654 Returns a font pointer for the "giant" gd font. Your code must
3655 include the header file <code>gdfontg.h</code> before
3656 calling this function. Under Windows, due to the nature of DLLs,
3657 the use of this function is strongly recommended rather than attempting
3658 to use the <code>gdFontGiant</code> pointer directly. (You may
3659 safely assign the result to a local <code>gdFontPtr</code> variable
3660 in your own code.)
3661 <p>
3662 See <a href="#gdImageString">gdImageString</a> for more information
3663 and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
3664 freetype-based alternative that supports truetype fonts.
3665 <DT><A NAME="gdFontGetTiny">
3666 gdFontPtr gdFontGetTiny(void)</a>
3667 <STRONG>(FUNCTION)</STRONG>
3668 <DD>
3669 Returns a font pointer for the "tiny" gd font. Your code must
3670 include the header file <code>gdfontt.h</code> before
3671 calling this function. Under Windows, due to the nature of DLLs,
3672 the use of this function is strongly recommended rather than attempting
3673 to use the <code>gdFontTiny</code> pointer directly. (You may
3674 safely assign the result to a local <code>gdFontPtr</code> variable
3675 in your own code.)
3676 <p>
3677 See <a href="#gdImageString">gdImageString</a> for more information
3678 and examples, or <a href="#gdImageStringFT">gdImageStringFT</a> for a
3679 freetype-based alternative that supports truetype fonts.
3680 <DT><A NAME="gdImageChar">
3681 void gdImageChar(gdImagePtr im, gdFontPtr font, int x, int y,
3682 int c, int color)</A>
3683 <STRONG>(FUNCTION)</STRONG>
3684 <DD>
3685 gdImageChar is used to draw single characters on the image.
3686 (To draw multiple characters, use <A HREF="#gdImageString">
3687 gdImageString</A> or <A HREF="#gdImageString16">
3688 gdImageString16</A>.
3689 See also <A HREF="#gdImageStringFT">gdImageStringFT</A> for a high quality
3690 solution.)
3691 The second argument is a pointer to a font definition structure; five fonts are
3692 provided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
3693 gdFontLarge, and gdFontGiant.
3694 <p>
3695 You must include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
3696 "gdfontl.h" and "gdfontg.h" respectively
3697 and (if you are not using a library-based approach) link with the
3698 corresponding .c files to use the provided fonts.
3699 <p>
3700 <blockquote>
3701 <b>Windows DLL users:</b> although you can use
3702 these DLL-exported pointers directly, you cannot easily assign them to other
3703 pointers. This will cause hard-to-debug problems. To avoid such troubles, you
3704 should call the functions gdFontGetTiny(), gdFontGetSmall(),
3705 gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
3706 obtain pointers to the fonts under Windows.
3707 </blockquote>
3708 <p>
3709 The character specified by the fifth
3710 argument is drawn from left to right in the specified
3711 color. (See <A HREF="#gdImageCharUp">gdImageCharUp</A> for a way
3712 of drawing vertical text.) Pixels not
3713 set by a particular character retain their previous color.
3714 <PRE>
3715 #include "gd.h"
3716 #include "gdfontl.h"
3717 ... inside a function ...
3718 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3719 int black;
3720 int white;
3721 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3722 /* Background color (first allocated) */
3723 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3724 /* Allocate the color white (red, green and blue all maximum). */
3725 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3726 /* Draw a character. */
3727 gdImageChar(im, gdFontGetLarge(), 0, 0, 'Q', white);
3728 /* ... Do something with the image, such as
3729 saving it to a file... */
3730 /* Destroy it */
3731 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3732 </PRE>
3733 <DT><A NAME="gdImageCharUp">
3734 void gdImageCharUp(gdImagePtr im, gdFontPtr font, int x, int y,
3735 int c, int color)</A>
3736 <STRONG>(FUNCTION)</STRONG>
3737 <DD>
3738 gdImageCharUp is used to draw single characters on the image,
3739 rotated 90 degrees.
3740 (To draw multiple characters, use <A HREF="#gdImageStringUp">
3741 gdImageStringUp</A> or <A HREF="#gdImageStringUp16">
3742 gdImageStringUp16</A>.) The second argument is a
3743 pointer to a font definition structure; five fonts are
3744 provided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
3745 gdFontLarge, and gdFontGiant. You must
3746 include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
3747 "gdfontl.h" and "gdfontg.h" respectively
3748 and (if you are not using a library-based approach) link with the
3749 corresponding .c files to use the provided fonts.
3750 <p>
3751 <blockquote>
3752 <b>Windows DLL users:</b> although you can use
3753 these DLL-exported pointers directly, you cannot easily assign them to other
3754 pointers. This will cause hard-to-debug problems. To avoid such troubles, you
3755 should call the functions gdFontGetTiny(), gdFontGetSmall(),
3756 gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
3757 obtain pointers to the fonts under Windows.
3758 </blockquote>
3759 <p>
3760 The character specified by
3761 the fifth argument is drawn
3762 from bottom to top, rotated at a 90-degree angle, in the specified
3763 color. (See <A HREF="#gdImageChar">gdImageChar</A> for a way
3764 of drawing horizontal text.) Pixels not
3765 set by a particular character retain their previous color.
3766 <PRE>
3767 #include "gd.h"
3768 #include "gdfontl.h"
3769 ... inside a function ...
3770 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3771 int black;
3772 int white;
3773 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3774 /* Background color (first allocated) */
3775 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3776 /* Allocate the color white (red, green and blue all maximum). */
3777 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3778 /* Draw a character upwards so it rests against the top of the image. */
3779 gdImageCharUp(im, gdFontGetLarge(),
3780 0, gdFontGetLarge()->h, 'Q', white);
3781 /* ... Do something with the image, such as
3782 saving it to a file... */
3783 /* Destroy it */
3784 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3785 </PRE>
3786 <DT><A NAME="gdImageString">
3787 void gdImageString(gdImagePtr im, gdFontPtr font, int x, int y,
3788 unsigned char *s, int color)</A>
3789 <STRONG>(FUNCTION)</STRONG>
3790 <DD>
3791 gdImageString is used to draw multiple characters on the image.
3792 (To draw single characters, use <A HREF="#gdImageChar">
3793 gdImageChar</A>.) The second argument is a
3794 pointer to a font definition structure; five fonts are
3795 provided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
3796 gdFontLarge, and gdFontGiant. You must
3797 include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
3798 "gdfontl.h" and "gdfontg.h" respectively
3799 and (if you are not using a library-based approach) link with the
3800 corresponding .c files to use the provided fonts.
3801 <p>
3802 <blockquote>
3803 <b>Windows DLL users:</b> although you can use
3804 these DLL-exported pointers directly, you cannot easily assign them to other
3805 pointers. This will cause hard-to-debug problems. To avoid such troubles, you
3806 should call the functions gdFontGetTiny(), gdFontGetSmall(),
3807 gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
3808 obtain pointers to the fonts under Windows.
3809 </blockquote>
3810 The null-terminated C string specified
3811 by the fifth argument is drawn from left to right in the specified
3812 color. (See <A HREF="#gdImageStringUp">gdImageStringUp</A> for a way
3813 of drawing vertical text.
3814 See also <A HREF="#gdImageStringFT">gdImageStringFT</A> for a high
3815 quality solution.)
3816 Pixels not set by a particular character retain their previous color.
3817 <PRE>
3818 #include "gd.h"
3819 #include "gdfontl.h"
3820 #include &lt;string.h&gt;
3821 ... inside a function ...
3822 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3823 int black;
3824 int white;
3825 /* String to draw. */
3826 char *s = "Hello.";
3827 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3828 /* Background color (first allocated) */
3829 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3830 /* Allocate the color white (red, green and blue all maximum). */
3831 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3832 /* Draw a centered string. */
3833 gdImageString(im, gdFontGetLarge(),
3834 im->sx / 2 - (strlen(s) * gdFontGetLarge()->w / 2),
3835 im->sy / 2 - gdFontGetLarge()->h / 2,
3836 s, white);
3837 /* ... Do something with the image, such as
3838 saving it to a file... */
3839 /* Destroy it */
3840 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3841 </PRE>
3842 <DT><A NAME="gdImageString16">
3843 void gdImageString16(gdImagePtr im, gdFontPtr font, int x, int y,
3844 unsigned short *s, int color)</A>
3845 <STRONG>(FUNCTION)</STRONG>
3846 <DD>
3847 gdImageString16 is used to draw multiple 16-bit characters on the image.
3848 (To draw single characters, use <A HREF="#gdImageChar">
3849 gdImageChar16</A>.) The second argument is a
3850 pointer to a font definition structure; no 16-bit fonts are
3851 provided with gd as standard equipment and there does not seem to be
3852 much momentum to create them although the bdftogd script can do so. The
3853 preferred solution is <a href="#gdImageStringFT">gdImageStringFT</a>, which
3854 uses freetype to provide truetype font support.
3855 <p>
3856 <blockquote>
3857 <b>Windows DLL users:</b> although you can use
3858 these DLL-exported pointers directly, you cannot easily assign them to other
3859 pointers. This will cause hard-to-debug problems. To avoid such troubles, you
3860 should call the functions gdFontGetTiny(), gdFontGetSmall(),
3861 gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
3862 obtain pointers to the fonts under Windows.
3863 </blockquote>
3864 The null-terminated string of characters represented as 16-bit unsigned
3865 short integers specified by the fifth argument is drawn from left to right
3866 in the specified
3867 color. (See <A HREF="#gdImageStringUp16">gdImageStringUp16</A> for a way
3868 of drawing vertical text.) Pixels not
3869 set by a particular character retain their previous color.
3870 <p>
3871 This function was added in gd1.3 to provide a means of rendering
3872 fonts with more than 256 characters for those who have them. A
3873 more frequently used routine is <a href="#gdImageString">gdImageString</a>.
3874 <DT><A NAME="gdImageStringUp">
3875 void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y,
3876 unsigned char *s, int color)</A>
3877 <STRONG>(FUNCTION)</STRONG>
3878 <DD>
3879 gdImageStringUp is used to draw multiple characters on the image,
3880 rotated 90 degrees.
3881 (To draw single characters, use <A HREF="#gdImageCharUp">
3882 gdImageCharUp</A>.) The second argument is a
3883 pointer to a font definition structure; five fonts are
3884 provided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
3885 gdFontLarge, and gdFontGiant. You must
3886 include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
3887 "gdfontl.h" and "gdfontg.h" respectively
3888 and (if you are not using a library-based approach) link with the
3889 corresponding .c files to use the provided fonts.
3890 <blockquote>
3891 <b>Windows DLL users:</b> although you can use
3892 these DLL-exported pointers directly, you cannot easily assign them to other
3893 pointers. This will cause hard-to-debug problems. To avoid such troubles, you
3894 should call the functions gdFontGetTiny(), gdFontGetSmall(),
3895 gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
3896 obtain pointers to the fonts under Windows.
3897 </blockquote>
3898
3899 The null-terminated C string specified
3900 by the fifth argument is drawn from bottom to top (rotated
3901 90 degrees) in the specified color. (See
3902 <A HREF="#gdImageString">gdImageString</A> for a way
3903 of drawing horizontal text.) Pixels not
3904 set by a particular character retain their previous color.
3905 <PRE>
3906 #include "gd.h"
3907 #include "gdfontl.h"
3908 #include &lt;string.h&gt;
3909 ... inside a function ...
3910 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3911 int black;
3912 int white;
3913 /* String to draw. */
3914 char *s = "Hello.";
3915 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
3916 /* Background color (first allocated) */
3917 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
3918 /* Allocate the color white (red, green and blue all maximum). */
3919 white = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 255, 255);
3920 /* Draw a centered string going upwards. Axes are reversed,
3921 and Y axis is decreasing as the string is drawn. */
3922 gdImageStringUp(im, gdFontGetLarge(),
3923 im->w / 2 - gdFontGetLarge()->h / 2,
3924 im->h / 2 + (strlen(s) * gdFontGetLarge()->w / 2),
3925 s, white);
3926 /* ... Do something with the image, such as
3927 saving it to a file... */
3928 /* Destroy it */
3929 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
3930 </PRE>
3931 <DT><A NAME="gdImageStringUp16">
3932 void gdImageStringUp16(gdImagePtr im, gdFontPtr font, int x, int y,
3933 unsigned short *s, int color)</A>
3934 <STRONG>(FUNCTION)</STRONG>
3935 <DD>
3936 gdImageString is used to draw multiple 16-bit characters vertically on
3937 the image. (To draw single characters, use <A HREF="#gdImageChar">
3938 gdImageChar</A>.) The second argument is a
3939 pointer to a font definition structure; five fonts are
3940 provided with gd, gdFontTiny, gdFontSmall, gdFontMediumBold,
3941 gdFontLarge, and gdFontGiant. You must
3942 include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
3943 "gdfontl.h" and "gdfontg.h" respectively
3944 and (if you are not using a library-based approach) link with the
3945 corresponding .c files to use the provided fonts.
3946 <blockquote>
3947 <b>Windows DLL users:</b> although you can use
3948 these DLL-exported pointers directly, you cannot easily assign them to other
3949 pointers. This will cause hard-to-debug problems. To avoid such troubles, you
3950 should call the functions gdFontGetTiny(), gdFontGetSmall(),
3951 gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
3952 obtain pointers to the fonts under Windows.
3953 </blockquote>
3954 The null-terminated string of characters represented as 16-bit unsigned
3955 short integers specified by the fifth argument is drawn from bottom to top
3956 in the specified color.
3957 (See <A HREF="#gdImageStringUp16">gdImageStringUp16</A> for a way
3958 of drawing horizontal text.) Pixels not
3959 set by a particular character retain their previous color.
3960 <p>
3961 This function was added in gd1.3 to provide a means of rendering
3962 fonts with more than 256 characters for those who have them. A
3963 more frequently used routine is <a href="#gdImageStringUp">gdImageStringUp</a>.
3964 <DT><A NAME="gdFTUseFontConfig">int gdFTUseFontConfig(int flag)</a>
3965 <STRONG>(FUNCTION)</STRONG>
3966 <DD>
3967 GD 2.0.29 introduced the ability to use
3968 <a href="http://freedesktop.org/software/fontconfig">fontconfig patterns</a>
3969 rather than font file names as parameters to
3970 <a href="#gdImageStringFT">gdImageStringFT</a>,
3971 <a href="#gdImageStringFTEx">gdImageStringFTEx</a> and
3972 <a href="#gdImageStringFTEx">gdImageStringFTCircle</a>.
3973 For backwards compatibility reasons, the fontlist parameter to those
3974 functions is still expected to be a full or partial font file path name
3975 or list thereof by default. However, as a convenience, a single call
3976 to gdFTUseFontConfig with a nonzero parameter configures gd to expect
3977 the fontlist parameter to be a fontconfig pattern. Regardless of whether
3978 the flag argument is nonzero, this function returns true when the
3979 fontconfig library is available and false when it is not. When fontconfig
3980 is not available, the fontlist parameter always behaves as in previous
3981 versions of GD.
3982 <pre>
3983 #include "gd.h"
3984 #include &lt;string.h&gt;
3985 ... inside a function ...
3986 <A HREF="#gdImagePtr">gdImagePtr</A> im;
3987 int black;
3988 int white;
3989 int brect[8];
3990 int x, y;
3991 char *err;
3992
3993 char *s = "Hello."; /* String to draw. */
3994 double sz = 40.;
3995 char *fc = "times:bold:italic"; /* fontconfig pattern */
3996
3997 /* Signal that all freetype font calls in this program will receive
3998 fontconfig patterns rather than filenames of font files */
3999 gdUseFontConfig(1);
4000
4001 /* obtain brect so that we can size the image */
4002 err = <A HREF="#gdImageStringFT">gdImageStringFT</A>(NULL,&brect[0],0,fc,sz,0.,0,0,s);
4003 if (err) {fprintf(stderr,err); return 1;}
4004
4005 /* create an image big enough for the string plus a little whitespace */
4006 x = brect[2]-brect[6] + 6;
4007 y = brect[3]-brect[7] + 6;
4008 im = <A HREF="#gdImageCreate">gdImageCreate</A>(x,y);
4009
4010 /* Background color (first allocated) */
4011 white = <A HREF="#gdImageColorResolve">gdImageColorResolve</A>(im, 255, 255, 255);
4012 black = <A HREF="#gdImageColorResolve">gdImageColorResolve</A>(im, 0, 0, 0);
4013
4014 /* render the string, offset origin to center string*/
4015 /* note that we use top-left coordinate for adjustment
4016 * since gd origin is in top-left with y increasing downwards. */
4017 x = 3 - brect[6];
4018 y = 3 - brect[7];
4019 err = <A HREF="#gdImageStringFT">gdImageStringFT</A>(im,&brect[0],black,fc,sz,0.0,x,y,s);
4020 if (err) {fprintf(stderr,err); return 1;}
4021 </pre>
4022 <DT><A NAME="gdImageStringFT">
4023 char *gdImageStringFT(gdImagePtr im, int *brect,
4024 int fg, char *fontname, double ptsize, double angle,
4025 int x, int y, char *string)</A>
4026 <STRONG>(FUNCTION)</STRONG>
4027 <DD>
4028 <strong>RECOMMENDED. New in 1.8.4.</strong> gdImageStringFT draws text using the
4029 FreeType 2.x library.
4030 <p>
4031 gdImageStringFT draws a string of anti-aliased characters on the image using
4032 the <A HREF=http://www.freetype.org/>FreeType</A>
4033 library to render user-supplied TrueType fonts. <strong>We do not provide
4034 TrueType fonts (.ttf and .ttc files). Obtaining them is entirely up to
4035 you.</strong> The string is anti-aliased, meaning that there should be
4036 fewer "jaggies" visible. The fontname is the full pathname to a TrueType
4037 font file, or a font face name if the GDFONTPATH environment variable
4038 or the compiled-in DEFAULT_FONTPATH macro of gdft.c have been set intelligently. In the absence of a full path, the font face name may be presented with or without extension (2.0.26).
4039 <p>
4040 The null-terminated <b>string</b> argument is considered to be encoded via the UTF_8
4041 standard; also, HTML entities are supported, including decimal,
4042 hexadecimal, and named entities (2.0.26). Those who are passing
4043 ordinary ASCII strings may have difficulty with the &amp;
4044 character unless encoded correctly as &amp; but should have no
4045 other difficulties.
4046 <p>
4047 The string may be arbitrarily scaled (ptsize) and rotated (angle in radians).
4048 The direction of rotation is counter-clockwise, with 0 radians (0 degrees)
4049 at 3 o'clock and PI/2 radians (90 degrees) at 12 o'clock.
4050
4051 <p>
4052 The user-supplied int brect[8] array is filled on return from gdImageStringFT
4053 with the 8 elements representing the 4 corner coordinates of the
4054 bounding rectangle (the smallest rectangle that completely surrounds the
4055 rendered string and does not intersect any pixel of the rendered string).
4056
4057 <TABLE BORDER="1">
4058 <TR><TD ALIGN="LEFT" VALIGN="TOP">0</TD><TD ALIGN="LEFT" VALIGN="TOP">
4059 lower left corner, X position</TD></TR>
4060 <TR><TD ALIGN="LEFT" VALIGN="TOP">1</TD><TD ALIGN="LEFT" VALIGN="TOP">
4061 lower left corner, Y position</TD></TR>
4062 <TR><TD ALIGN="LEFT" VALIGN="TOP">2</TD><TD ALIGN="LEFT" VALIGN="TOP">
4063 lower right corner, X position</TD></TR>
4064 <TR><TD ALIGN="LEFT" VALIGN="TOP">3</TD><TD ALIGN="LEFT" VALIGN="TOP">
4065 lower right corner, Y position</TD></TR>
4066 <TR><TD ALIGN="LEFT" VALIGN="TOP">4</TD><TD ALIGN="LEFT" VALIGN="TOP">
4067 upper right corner, X position</TD></TR>
4068 <TR><TD ALIGN="LEFT" VALIGN="TOP">5</TD><TD ALIGN="LEFT" VALIGN="TOP">
4069 upper right corner, Y position</TD></TR>
4070 <TR><TD ALIGN="LEFT" VALIGN="TOP">6</TD><TD ALIGN="LEFT" VALIGN="TOP">
4071 upper left corner, X position</TD></TR>
4072 <TR><TD ALIGN="LEFT" VALIGN="TOP">7</TD><TD ALIGN="LEFT" VALIGN="TOP">
4073 upper left corner, Y position</TD></TR>
4074 </TABLE>
4075 <p>
4076 The points are relative to the text regardless of the angle, so "upper left"
4077 means in the top left-hand corner seeing the text horizontally.
4078 <p>
4079 Use a NULL gdImagePtr to get the bounding rectangle without rendering.
4080 This is a relatively cheap operation if followed by a rendering of the same
4081 string, because of the caching of the partial rendering during bounding
4082 rectangle calculation.
4083 <p>
4084 The string is rendered in the color indicated by the gf color index.
4085 <strong>Use the negative of the desired color index to
4086 disable anti-aliasing.</strong>
4087 <p>
4088 The string may contain UTF-8 sequences like: "&amp;#192;"
4089 <p>
4090 gdImageStringFT will return a null char* on success, or an error
4091 string on failure.
4092 <PRE>
4093 #include "gd.h"
4094 #include &lt;string.h&gt;
4095 ... inside a function ...
4096 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4097 int black;
4098 int white;
4099 int brect[8];
4100 int x, y;
4101 char *err;
4102
4103 char *s = "Hello."; /* String to draw. */
4104 double sz = 40.;
4105 char *f = "/usr/local/share/ttf/Times.ttf"; /* User supplied font */
4106
4107 /* obtain brect so that we can size the image */
4108 err = <A HREF="#gdImageStringFT">gdImageStringFT</A>(NULL,&brect[0],0,f,sz,0.,0,0,s);
4109 if (err) {fprintf(stderr,err); return 1;}
4110
4111 /* create an image big enough for the string plus a little whitespace */
4112 x = brect[2]-brect[6] + 6;
4113 y = brect[3]-brect[7] + 6;
4114 im = <A HREF="#gdImageCreate">gdImageCreate</A>(x,y);
4115
4116 /* Background color (first allocated) */
4117 white = <A HREF="#gdImageColorResolve">gdImageColorResolve</A>(im, 255, 255, 255);
4118 black = <A HREF="#gdImageColorResolve">gdImageColorResolve</A>(im, 0, 0, 0);
4119
4120 /* render the string, offset origin to center string*/
4121 /* note that we use top-left coordinate for adjustment
4122 * since gd origin is in top-left with y increasing downwards. */
4123 x = 3 - brect[6];
4124 y = 3 - brect[7];
4125 err = <A HREF="#gdImageStringFT">gdImageStringFT</A>(im,&brect[0],black,f,sz,0.0,x,y,s);
4126 if (err) {fprintf(stderr,err); return 1;}
4127
4128 /* Write img to stdout */
4129 <A HREF="#gdImagePng">gdImagePng</A>(im, stdout);
4130
4131 /* Destroy it */
4132 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4133 </PRE>
4134 See also <a href="#gdImageStringFTEx">gdImageStringFTEx</a>.
4135 <DT><A NAME="gdImageStringFTEx">
4136 char *gdImageStringFTEx(gdImagePtr im, int *brect,
4137 int fg, char *fontname, double ptsize, double angle,
4138 int x, int y, char *string, gdFTStringExtraPtr strex)</A>
4139 <STRONG>(FUNCTION)</STRONG>
4140 <DD>
4141 <strong>New in 2.0.5,</strong> also found in common third-party versions
4142 of gd. gdImageStringFTEx extends the capabilities of
4143 <a href="#gdImageStringFT">gdImageStringFT</a> by providing a
4144 way to pass additional parameters.
4145 <p>
4146 If the <code>strex</code> parameter is not null, it must point to a
4147 <code>gdFTStringExtra</code> structure. As of gd 2.0.5, this structure
4148 is defined as follows:
4149 <pre>
4150 typedef struct {
4151 /* logical OR of gdFTEX_ values */
4152 int flags;
4153 /* fine tune line spacing for '\n' */
4154 double linespacing;
4155 /* Preferred character mapping */
4156 int charmap;
4157 /* Rendering resolution */
4158 int hdpi;
4159 int vdpi;
4160 char *xshow;
4161 char *fontpath;
4162 } gdFTStringExtra, *gdFTStringExtraPtr;
4163 </pre>
4164 To output multiline text with a specific line spacing,
4165 include <code>gdFTEX_LINESPACE</code> in the setting of
4166 <code>flags</code>:
4167 <pre>
4168 flags |= gdFTEX_LINESPACE;
4169 </pre>
4170 And also set <code>linespacing</code> to the desired spacing, expressed as a
4171 multiple of the font height. Thus a line spacing of 1.0 is the
4172 minimum to guarantee that lines of text do not collide.
4173 <p>
4174 If <code>gdFTEX_LINESPACE</code> is not present, or
4175 <code>strex</code> is null, or <a href="#gdImageStringFT">gdImageStringFT</a>
4176 is called, <code>linespacing</code> defaults to 1.05.
4177 <p>
4178 To specify a preference for Unicode, Shift_JIS Big5 character encoding,
4179 set or To output multiline text with a specific line spacing,
4180 include <code>gdFTEX_CHARMAP</code> in the setting of
4181 <code>flags</code>:
4182 <pre>
4183 flags |= gdFTEX_CHARMAP;
4184 </pre>
4185 And set <code>charmap</code> to the desired value, which can be
4186 any of gdFTEX_Unicode, gdFTEX_Shift_JIS, gdFTEX_Big5, or gdFTEX_Adobe_Custom.
4187 If you do not specify a preference, Unicode will be tried first. If the preferred
4188 character mapping is not found in the font, other character mappings
4189 are attempted.
4190 <p>
4191 GD operates on the assumption that the output image will be
4192 rendered to a computer screen. By default, gd passes a
4193 resolution of 96 dpi to the freetype text rendering engine.
4194 This influences the "hinting" decisions made by the renderer. To
4195 specify a different resolution, set hdpi and vdpi accordingly
4196 (in dots per inch) and add <code>gdFTEX_RESOLUTION</code> to <code>flags</code>:
4197 <pre>
4198 flags | gdFTEX_RESOLUTION;
4199 </pre>
4200 GD 2.0.29 and later will normally attempt to apply kerning tables, if
4201 fontconfig is available, to adjust the relative positions of consecutive
4202 characters more ideally for that pair of characters. This can be turn off by
4203 specifying the gdFTEX_DISABLE_KERNING flag:
4204 <pre>
4205 flags | gdFTEX_DISABLE_KERNING;
4206 </pre>
4207 GD 2.0.29 and later can return a vector of individual character
4208 position advances, occasionally useful in applications that must know
4209 exactly where each character begins. This is returned in the xshow
4210 element of the gdFTStringExtra structure if the gdFTEX_XSHOW
4211 flag is set:
4212 <pre>
4213 flags | gdFTEX_XSHOW;
4214 </pre>
4215 <b>The caller is responsible for calling gdFree() on the xshow
4216 element after the call</b> if gdFTEX_XSHOW is set.
4217 <p>
4218 GD 2.0.29 and later can also return the path to the actual font file
4219 used if the gdFTEX_RETURNFONTPATHNAME flag is set. This is useful because
4220 GD 2.0.29 and above are capable of
4221 selecting a font automatically based on a fontconfig font pattern
4222 when fontconfig is available. This information is returned in the
4223 fontpath element of the gdFTStringExtra structure.
4224 <pre>
4225 flags | gdFTEX_RETURNFONTPATHNAME;
4226 </pre>
4227 <b>The caller is responsible for calling gdFree() on the fontpath
4228 element after the call</b> if gdFTEX_RETURNFONTPATHNAME is set.
4229 <p>
4230 GD 2.0.29 and later can use fontconfig to resolve
4231 font names, including fontconfig patterns, if the gdFTEX_FONTCONFIG
4232 flag is set. As a convenience, this behavior can be made the default
4233 by calling <a href="#gdFTUseFontConfig">gdFTUseFontConfig</a> with
4234 a nonzero value. In that situation it is not necessary to set the
4235 gdFTEX_FONTCONFIG flag on every call; however explicit font path names
4236 can still be used if the gdFTEX_FONTPATHNAME flag is set:
4237 <pre>
4238 flags | gdFTEX_FONTPATHNAME;
4239 </pre>
4240 <p>
4241 Unless <a href="#gdFTUseFontConfig">gdFTUseFontConfig</a> has been
4242 called with a nonzero value, GD 2.0.29 and later will still expect
4243 the fontlist argument to the freetype text output functions to be
4244 a font file name or list thereof as in previous versions. If you do
4245 not wish to make fontconfig the default, it is
4246 still possible to force the use of fontconfig for a single call to
4247 the freetype text output functions by setting the gdFTEX_FONTCONFIG
4248 flag:
4249 <pre>
4250 flags | gdFTEX_FONTCONFIG;
4251 </pre>
4252 GD 2.0.29 and above can use fontconfig to resolve
4253 font names, including fontconfig patterns, if the gdFTEX_FONTCONFIG
4254 flag is set. As a convenience, this behavior can be made the default
4255 by calling <a href="#gdFTUseFontConfig">gdFTUseFontConfig</a> with
4256 a nonzero value. In that situation it is not necessary to set the
4257 gdFTEX_FONTCONFIG flag on every call; however explicit font path names
4258 can still be used if the gdFTEX_FONTPATHNAME flag is set:
4259 <pre>
4260 flags | gdFTEX_FONTPATHNAME;
4261 </pre>
4262 For more information, see <a href="#gdImageStringFT">gdImageStringFT</a>.
4263 <DT><A NAME="gdImageStringFTCircle">
4264 char *gdImageStringFTCircle(gdImagePtr im,
4265 int cx,
4266 int cy,
4267 double radius,
4268 double textRadius,
4269 double fillPortion,
4270 char *font,
4271 double points,
4272 char *top,
4273 char *bottom,
4274 int fgcolor)</A>
4275 <STRONG>(FUNCTION)</STRONG>
4276 <DD>
4277 Draws the text strings specified by <code>top</code> and <code>bottom</code>
4278 on <code>im</code>, curved along the edge of a circle of radius
4279 <code>radius</code>, with its center at <code>cx</code> and <code>cy</code>.
4280 <code>top</code> is written clockwise
4281 along the top; <code>bottom</code> is written counterclockwise
4282 along the bottom. <code>textRadius</code> determines the "height"
4283 of each character; if <code>textRadius</code> is 1/2 of
4284 <code>radius</code>,
4285 characters extend halfway from the edge to the center.
4286 <code>fillPortion</code> varies from 0 to 1.0, with useful values
4287 from about 0.4 to 0.9, and determines how much of the
4288 180 degrees of arc assigned to each section of text
4289 is actually occupied by text; 0.9 looks better than
4290 1.0 which is rather crowded. <code>font</code> is a freetype
4291 font; see gdImageStringFT. <code>points</code> is passed to the
4292 freetype engine and has an effect on hinting; although
4293 the size of the text is determined by <code>radius</code>,
4294 <code>textRadius</code>, and <code>fillPortion</code>, you should
4295 pass a point size that
4296 "hints" appropriately -- if you know the text will be
4297 large, pass a large point size such as 24.0 to get the
4298 best results. <code>fgcolor</code> can be any color, and may have
4299 an alpha component, do blending, etc.
4300 <p>
4301 Returns 0 on success, or an error string otherwise.
4302 <pre>
4303 #include &lt;stdio.h&gt;
4304 #include &lt;gd.h&gt;
4305
4306 int main (int argc, char *argv[])
4307 {
4308 FILE *in;
4309 FILE *out;
4310 gdImagePtr im;
4311 int radius;
4312 /* Create an image of text on a circle, with an
4313 alpha channel so that we can copy it onto a
4314 background */
4315 in = fopen("mypicture.jpg", "rb");
4316 if (!in) {
4317 im = gdImageCreateTrueColor(300, 300);
4318 } else {
4319 im = gdImageCreateFromJpeg(in);
4320 fclose(in);
4321 }
4322 if (gdImageSX(im) &lt; gdImageSY(im)) {
4323 radius = gdImageSX(im) / 2;
4324 } else {
4325 radius = gdImageSY(im) / 2;
4326 }
4327 gdStringFTCircle(
4328 im,
4329 gdImageSX(im) / 2,
4330 gdImageSY(im) / 2,
4331 radius,
4332 radius / 2,
4333 0.8,
4334 "arial",
4335 24,
4336 "top text",
4337 "bottom text",
4338 gdTrueColorAlpha(240, 240, 255, 32));
4339 out = fopen("gdfx.png", "wb");
4340 if (!out) {
4341 fprintf(stderr, "Can't create gdfx.png\n");
4342 return 1;
4343 }
4344 gdImagePng(im, out);
4345 fclose(out);
4346 gdImageDestroy(im);
4347 return 0;
4348 }
4349 </pre>
4350
4351 <p>
4352 For more information, see <a href="#gdImageStringFTEx">gdImageStringFTEx</a>
4353 and <a href="#gdImageSquareToCircle">gdImageSquareToCircle</a>.
4354 <DT><A NAME="gdImageStringTTF">
4355 char *gdImageStringTTF(gdImagePtr im, int *brect,
4356 int fg, char *fontname, double ptsize, double angle,
4357 int x, int y, char *string)</A>
4358 <STRONG>(FUNCTION)</STRONG>
4359 <DD>
4360 <strong>DEPRECATED.</strong> This function simply invokes
4361 <a href="#gdImageStringFT">gdImageStringFT</a> for backwards
4362 compatibility with old code that was written with FreeType 1.x.
4363 <DT><A NAME="gdFontCacheSetup">
4364 int gdFontCacheSetup(void)</A>
4365 <STRONG>(FUNCTION)</STRONG>
4366 <DD>
4367 This function initializes the font cache for freetype text output
4368 functions such as <a href="#gdImageStringFTEx">gdImageStringFTEx</a>.
4369 If this function is not called by the programmer, it is invoked
4370 automatically on the first truetype text output call, which is
4371 perfectly safe <b>unless</b> the application is multithreaded.
4372 Multithreaded applications should directly invoke this function before
4373 allowing any thread to use freetype text output. Returns 0 on success,
4374 nonzero if the freetype library fails to initialize.
4375 <DT><A NAME="gdFontCacheShutdown">
4376 void gdFontCacheShutdown(void)</A>
4377 <STRONG>(FUNCTION)</STRONG>
4378 <DD>
4379 This function releases the memory used by the freetype font cache
4380 and the text output mutex. Applications that use gd for their
4381 entire lifetime, then exit, need not call this function.
4382 </DL>
4383 <H3><A NAME="colors">Color-handling functions</A></H3>
4384 <DL>
4385 <DT><A NAME="gdImageColorAllocate">
4386 int gdImageColorAllocate(gdImagePtr im, int r, int g, int b)</A>
4387 <STRONG>(FUNCTION)</STRONG>
4388 <DD>
4389 gdImageColorAllocate finds the first available color index in
4390 the image specified, sets its RGB values to those requested
4391 (255 is the maximum for each),
4392 and returns the index of the new color table entry, or an RGBA
4393 value in the case of a truecolor image; in either case you can
4394 then use the returned value as a parameter to drawing functions. When
4395 creating a new palette-based image, the first time you invoke this function,
4396 you are setting the background color for that image.
4397 <P>
4398 In the event that all <A HREF="#gdMaxColors">gdMaxColors</A> colors
4399 (256) have already been allocated, gdImageColorAllocate will
4400 return -1 to indicate failure. (This is not uncommon when
4401 working with existing PNG files that already use 256 colors.)
4402 Note that gdImageColorAllocate
4403 does not check for existing colors that match your request;
4404 see <A HREF="#gdImageColorExact">gdImageColorExact</A>,
4405 <A HREF="#gdImageColorClosest">gdImageColorClosest</A> and
4406 <A HREF="#gdImageColorClosestHWB">gdImageColorClosestHWB</A>
4407 for ways to locate existing colors that approximate the
4408 color desired in situations where a new color is not available.
4409 Also see <A HREF="#gdImageColorResolve">gdImageColorResolve</A>,
4410 new in gd-1.6.2.
4411 <PRE>
4412 ... inside a function ...
4413 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4414 int black;
4415 int red;
4416 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
4417 /* Background color (first allocated) */
4418 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
4419 /* Allocate the color red. */
4420 red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);
4421 /* Draw a dashed line from the upper left corner
4422 to the lower right corner. */
4423 gdImageDashedLine(im, 0, 0, 99, 99, red);
4424 /* ... Do something with the image, such as saving
4425 it to a file... */
4426 /* Destroy it */
4427 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4428 </PRE>
4429 <DT><A NAME="gdImageColorAllocateAlpha">
4430 int gdImageColorAllocateAlpha(gdImagePtr im, int r, int g, int b, int a)</A>
4431 <STRONG>(FUNCTION)</STRONG>
4432 <DD>
4433 gdImageColorAllocateAlpha finds the first available color index in
4434 the image specified, sets its RGBA values to those requested
4435 (255 is the maximum for red, green and blue, and 127 represents
4436 full transparency for alpha),
4437 and returns the index of the new color table entry, or an RGBA
4438 value in the case of a truecolor image; in either case you can
4439 then use the returned value as a parameter to drawing functions. When
4440 creating a new palette-based image, the first time you invoke this function,
4441 you are setting the background color for that image.
4442 <P>
4443 In the event that all <A HREF="#gdMaxColors">gdMaxColors</A> colors
4444 (256) have already been allocated, gdImageColorAllocate will
4445 return -1 to indicate failure. (This is not uncommon when
4446 working with existing palette-based PNG files that already use 256 colors.)
4447 Note that gdImageColorAllocateAlpha
4448 does not check for existing colors that match your request;
4449 see <A HREF="#gdImageColorExactAlpha">gdImageColorExactAlpha</A> and
4450 <A HREF="#gdImageColorClosestAlpha">gdImageColorClosestAlpha</A>
4451 for ways to locate existing colors that approximate the
4452 color desired in situations where a new color is not available.
4453 Also see <A HREF="#gdImageColorResolveAlpha">gdImageColorResolveAlpha</A>.
4454 <PRE>
4455 ... inside a function ...
4456 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4457 int black;
4458 int red;
4459 im = <A HREF="#gdImageCreate">gdImageCreate</A>(100, 100);
4460 /* Background color (first allocated) */
4461 black = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 0, 0, 0);
4462 /* Allocate the color red, 50% transparent. */
4463 red = <A HREF="#gdImageColorAllocateAlpha">gdImageColorAllocateAlpha</A>(im, 255, 0, 0, 64);
4464 /* Draw a dashed line from the upper left corner to the lower right corner. */
4465 gdImageDashedLine(im, 0, 0, 99, 99, red);
4466 /* ... Do something with the image, such as
4467 saving it to a file... */
4468 /* Destroy it */
4469 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4470 </PRE>
4471 <DT><A NAME="gdImageColorClosest">
4472 int gdImageColorClosest(gdImagePtr im, int r, int g, int b)</A>
4473 <STRONG>(FUNCTION)</STRONG>
4474 <DD>
4475 gdImageColorClosest searches the colors which have been
4476 defined thus far in the image specified and returns the
4477 index of the color with RGB values closest to those of the
4478 request. (Closeness is determined by Euclidian distance,
4479 which is used to determine the distance in three-dimensional color
4480 space between colors.)
4481 <P>
4482 If no colors have yet been allocated in the image,
4483 gdImageColorClosest returns -1.
4484 <p>
4485 When applied to a truecolor image, this function always
4486 succeeds in returning the desired color.
4487 <P>
4488 This function is most useful as a backup method for choosing
4489 a drawing color when an image already contains
4490 <A HREF="#gdMaxColors">gdMaxColors</A> (256) colors and
4491 no more can be allocated. (This is not uncommon when
4492 working with existing PNG files that already use many colors.)
4493 See <A HREF="#gdImageColorExact">gdImageColorExact</A>
4494 for a method of locating exact matches only.
4495 <PRE>
4496 ... inside a function ...
4497 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4498 FILE *in;
4499 int red;
4500 /* Let's suppose that photo.png is a scanned photograph with
4501 many colors. */
4502 in = fopen("photo.png", "rb");
4503 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4504 fclose(in);
4505 /* Try to allocate red directly */
4506 red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);
4507 /* If we fail to allocate red... */
4508 if (red == (-1)) {
4509 /* Find the <em>closest</em> color instead. */
4510 red = gdImageColorClosest(im, 255, 0, 0);
4511 }
4512 /* Draw a dashed line from the upper left corner to the lower right corner */
4513 gdImageDashedLine(im, 0, 0, 99, 99, red);
4514 /* ... Do something with the image, such as
4515 saving it to a file... */
4516 /* Destroy it */
4517 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4518 </PRE>
4519 <DT><A NAME="gdImageColorClosestAlpha">
4520 int gdImageColorClosestAlpha(gdImagePtr im, int r, int g, int b, int a)</A>
4521 <STRONG>(FUNCTION)</STRONG>
4522 <DD>
4523 gdImageColorClosest searches the colors which have been
4524 defined thus far in the image specified and returns the
4525 index of the color with RGBA values closest to those of the
4526 request. (Closeness is determined by Euclidian distance,
4527 which is used to determine the distance in four-dimensional color/alpha
4528 space between colors.)
4529 <P>
4530 If no colors have yet been allocated in the image,
4531 gdImageColorClosestAlpha returns -1.
4532 <p>
4533 When applied to a truecolor image, this function always
4534 succeeds in returning the desired color.
4535 <P>
4536 This function is most useful as a backup method for choosing
4537 a drawing color when a palette-based image already contains
4538 <A HREF="#gdMaxColors">gdMaxColors</A> (256) colors and
4539 no more can be allocated. (This is not uncommon when
4540 working with existing palette-based PNG files that already use many colors.)
4541 See <A HREF="#gdImageColorExactAlpha">gdImageColorExactAlpha</A>
4542 for a method of locating exact matches only.
4543 <PRE>
4544 ... inside a function ...
4545 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4546 FILE *in;
4547 int red;
4548 /* Let's suppose that photo.png is a scanned photograph with
4549 many colors. */
4550 in = fopen("photo.png", "rb");
4551 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4552 fclose(in);
4553 /* Try to allocate red, 50% transparent, directly */
4554 red = <A HREF="#gdImageColorAllocateAlpha">gdImageColorAllocateAlpha</A>(im, 255, 0, 0, 64);
4555 /* If we fail to allocate red... */
4556 if (red == (-1)) {
4557 /* Find the <em>closest</em> color instead. */
4558 red = gdImageColorClosestAlpha(im, 255, 0, 0, 64);
4559 }
4560 /* Draw a dashed line from the upper left corner to the lower right corner */
4561 gdImageDashedLine(im, 0, 0, 99, 99, red);
4562 /* ... Do something with the image, such as
4563 saving it to a file... */
4564 /* Destroy it */
4565 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4566 </PRE>
4567 <DT><A NAME="gdImageColorClosestHWB">
4568 int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b)</A>
4569 <STRONG>(FUNCTION)</STRONG>
4570 <DD>
4571 gdImageColorClosestHWB searches the colors which have been
4572 defined thus far in the image specified and returns the
4573 index of the color with hue, whiteness and blackness closest to the
4574 requested color. This scheme is typically superior to the
4575 Euclidian distance scheme used by
4576 <a href="#gdImageColorClosest">gdImageColorClosest</a>.
4577 <P>
4578 If no colors have yet been allocated in the image,
4579 gdImageColorClosestHWB returns -1.
4580 <p>
4581 When applied to a truecolor image, this function always
4582 succeeds in returning the desired color.
4583 <P>
4584 This function is most useful as a backup method for choosing
4585 a drawing color when an image already contains
4586 <A HREF="#gdMaxColors">gdMaxColors</A> (256) colors and
4587 no more can be allocated. (This is not uncommon when
4588 working with existing PNG files that already use many colors.)
4589 See <A HREF="#gdImageColorExact">gdImageColorExact</A>
4590 for a method of locating exact matches only.
4591 <PRE>
4592 ... inside a function ...
4593 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4594 FILE *in;
4595 int red;
4596 /* Let's suppose that photo.png is a scanned photograph with
4597 many colors. */
4598 in = fopen("photo.png", "rb");
4599 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4600 fclose(in);
4601 /* Try to allocate red directly */
4602 red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);
4603 /* If we fail to allocate red... */
4604 if (red == (-1)) {
4605 /* Find the <em>closest</em> color instead. */
4606 red = gdImageColorClosestHWB(im, 255, 0, 0);
4607 }
4608 /* Draw a dashed line from the upper left corner to the lower right corner */
4609 gdImageDashedLine(im, 0, 0, 99, 99, red);
4610 /* ... Do something with the image, such as
4611 saving it to a file... */
4612 /* Destroy it */
4613 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4614 </PRE>
4615 <DT><A NAME="gdImageColorExact">
4616 int gdImageColorExact(gdImagePtr im, int r, int g, int b)</A>
4617 <STRONG>(FUNCTION)</STRONG>
4618 <DD>
4619 gdImageColorExact searches the colors which have been
4620 defined thus far in the image specified and returns the
4621 index of the first color with RGB values which exactly
4622 match those of the request. If no allocated color matches the
4623 request precisely, gdImageColorExact returns -1.
4624 See <A HREF="#gdImageColorClosest">gdImageColorClosest</A>
4625 for a way to find the color closest to the color requested.
4626 <p>
4627 When applied to a truecolor image, this function always
4628 succeeds in returning the desired color.
4629 <PRE>
4630 ... inside a function ...
4631 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4632 int red;
4633 in = fopen("photo.png", "rb");
4634 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4635 fclose(in);
4636 /* The image may already contain red; if it does, we'll save a slot
4637 in the color table by using that color. */
4638 /* Try to allocate red directly */
4639 red = gdImageColorExact(im, 255, 0, 0);
4640 /* If red isn't already present... */
4641 if (red == (-1)) {
4642 /* Second best: try to allocate it directly. */
4643 red = <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>(im, 255, 0, 0);
4644 /* Out of colors, so find the <em>closest</em> color instead. */
4645 red = gdImageColorClosest(im, 255, 0, 0);
4646 }
4647 /* Draw a dashed line from the upper left corner to the lower right corner */
4648 gdImageDashedLine(im, 0, 0, 99, 99, red);
4649 /* ... Do something with the image, such as
4650 saving it to a file... */
4651 /* Destroy it */
4652 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4653 </PRE>
4654 <DT><A NAME="gdImageColorResolve">
4655 int gdImageColorResolve(gdImagePtr im, int r, int g, int b)</A>
4656 <STRONG>(FUNCTION)</STRONG>
4657 <DD>
4658 gdImageColorResolve searches the colors which have been
4659 defined thus far in the image specified and returns the
4660 index of the first color with RGB values which exactly
4661 match those of the request. If no allocated color matches the
4662 request precisely, then gdImageColorResolve tries to allocate the
4663 exact color. If there is no space left in the color table then
4664 gdImageColorResolve returns the closest color (as in gdImageColorClosest).
4665 This function always returns an index of a color.
4666 <p>
4667 When applied to a truecolor image, this function always
4668 succeeds in returning the desired color.
4669 <PRE>
4670 ... inside a function ...
4671 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4672 int red;
4673 in = fopen("photo.png", "rb");
4674 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4675 fclose(in);
4676 /* The image may already contain red; if it does, we'll save a slot
4677 in the color table by using that color. */
4678 /* Get index of red, or color closest to red */
4679 red = gdImageColorResolve(im, 255, 0, 0);
4680 /* Draw a dashed line from the upper left corner to the lower right corner */
4681 gdImageDashedLine(im, 0, 0, 99, 99, red);
4682 /* ... Do something with the image, such as
4683 saving it to a file... */
4684 /* Destroy it */
4685 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4686 </PRE>
4687 <DT><A NAME="gdImageColorResolveAlpha">
4688 int gdImageColorResolveAlpha(gdImagePtr im, int r, int g, int b, int a)</A>
4689 <STRONG>(FUNCTION)</STRONG>
4690 <DD>
4691 gdImageColorResolveAlpha searches the colors which have been
4692 defined thus far in the image specified and returns the
4693 index of the first color with RGBA values which exactly
4694 match those of the request. If no allocated color matches the
4695 request precisely, then gdImageColorResolveAlpha tries to allocate the
4696 exact color. If there is no space left in the color table then
4697 gdImageColorResolveAlpha returns the closest color (as in gdImageColorClosestAlpha).
4698 This function always returns an index of a color.
4699 <p>
4700 When applied to a truecolor image, this function always
4701 succeeds in returning the desired color.
4702 <PRE>
4703 ... inside a function ...
4704 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4705 int red;
4706 in = fopen("photo.png", "rb");
4707 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4708 fclose(in);
4709 /* The image may already contain red; if it does,
4710 we'll save a slot in the color table by using that color. */
4711 /* Get index of red, 50% transparent, or the next best thing */
4712 red = gdImageColorResolveAlpha(im, 255, 0, 0, 64);
4713 /* Draw a dashed line from the upper left corner to the lower right corner */
4714 gdImageDashedLine(im, 0, 0, 99, 99, red);
4715 /* ... Do something with the image, such as saving
4716 it to a file... */
4717 /* Destroy it */
4718 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4719 </PRE>
4720 <DT><A NAME="gdImageColorsTotal">
4721 int gdImageColorsTotal(gdImagePtr im)</A>
4722 <STRONG>(MACRO)</STRONG>
4723 <DD>
4724 gdImageColorsTotal is a macro which returns the number of
4725 colors currently allocated in a palette image. For truecolor
4726 images, the result of this call is undefined and should not
4727 be used.
4728 <DT><A NAME="gdImageRed">
4729 int gdImageRed(gdImagePtr im, int c)</A>
4730 <STRONG>(MACRO)</STRONG>
4731 <DD>
4732 gdImageRed is a macro which returns the red portion
4733 of the specified color in the image. This macro works
4734 for both palette and truecolor images.
4735 <DT><A NAME="gdImageGreen">
4736 int gdImageGreen(gdImagePtr im, int c)</A>
4737 <STRONG>(MACRO)</STRONG>
4738 <DD>
4739 gdImageGreen is a macro which returns the green portion
4740 of the specified color in the image. This macro works
4741 for both palette and truecolor images.
4742 <DT><A NAME="gdImageBlue">
4743 int gdImageBlue(gdImagePtr im, int c)</A>
4744 <STRONG>(MACRO)</STRONG>
4745 <DD>
4746 gdImageBlue is a macro which returns the blue portion
4747 of the specified color in the image. This macro works
4748 for both palette and truecolor images.
4749 <DT><A NAME="gdImageGetInterlaced">
4750 int gdImageGetInterlaced(gdImagePtr im)</A>
4751 <STRONG>(MACRO)</STRONG>
4752 <DD>
4753 gdImageGetInterlaced is a macro which returns true (1)
4754 if the image is interlaced, false (0) if not.
4755 Use this macro to obtain this information; do not
4756 access the structure directly.
4757 See <A HREF="#gdImageInterlace">gdImageInterlace</A> for
4758 a means of interlacing images.
4759 <DT><A NAME="gdImageGetTransparent">
4760 int gdImageGetTransparent(gdImagePtr im)</A>
4761 <STRONG>(MACRO)</STRONG>
4762 <DD>
4763 gdImageGetTransparent is a macro which returns the
4764 current transparent color index in the image.
4765 If there is no transparent color, gdImageGetTransparent
4766 returns -1. Use this macro to obtain this information; do not
4767 access the structure directly.
4768 <DT><A NAME="gdImageColorDeallocate">
4769 void gdImageColorDeallocate(gdImagePtr im, int color)</A>
4770 <STRONG>(FUNCTION)</STRONG>
4771 <DD>
4772 gdImageColorDeallocate marks the specified color as being
4773 available for reuse. It does not attempt to determine whether
4774 the color index is still in use in the image. After a call
4775 to this function, the next call to
4776 <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>
4777 for the same image will set new RGB values for that
4778 color index, changing the color of any pixels which
4779 have that index as a result. If multiple calls to
4780 gdImageColorDeallocate are made consecutively, the lowest-numbered
4781 index among them will be reused by the next
4782 <A HREF="#gdImageColorAllocate"> gdImageColorAllocate</A> call.
4783 <PRE>
4784 ... inside a function ...
4785 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4786 int red, blue;
4787 in = fopen("photo.png", "rb");
4788 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4789 fclose(in);
4790 /* Look for red in the color table. */
4791 red = gdImageColorExact(im, 255, 0, 0);
4792 /* If red is present... */
4793 if (red != (-1)) {
4794 /* Deallocate it. */
4795 gdImageColorDeallocate(im, red);
4796 /* Allocate blue, reusing slot in table.
4797 Existing red pixels will change color. */
4798 blue = gdImageColorAllocate(im, 0, 0, 255);
4799 }
4800 /* ... Do something with the image, such as
4801 saving it to a file... */
4802 /* Destroy it */
4803 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4804 </PRE>
4805 <DT><A NAME="gdImageColorTransparent">
4806 void gdImageColorTransparent(gdImagePtr im, int color)</A>
4807 <STRONG>(FUNCTION)</STRONG>
4808 <DD>
4809 gdImageColorTransparent sets the transparent color index
4810 for the specified image to the specified index. To indicate
4811 that there should be <em>no</em> transparent color, invoke
4812 gdImageColorTransparent with a color index of -1. Note that
4813 JPEG images do not support transparency, so this setting has no effect
4814 when writing JPEG images.
4815 <P>
4816 The color index used should be an index
4817 allocated by <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A>,
4818 whether explicitly invoked by your code or implicitly
4819 invoked by loading an image.
4820 In order to ensure that your image has a reasonable appearance
4821 when viewed by users who do not have transparent background
4822 capabilities (or when you are writing a JPEG-format file, which does
4823 not support transparency), be sure to give reasonable RGB values to the
4824 color you allocate for use as a transparent color,
4825 <em>even though it will be transparent on systems
4826 that support PNG transparency</em>.
4827 <PRE>
4828 ... inside a function ...
4829 <A HREF="#gdImagePtr">gdImagePtr</A> im;
4830 int black;
4831 FILE *in, *out;
4832 in = fopen("photo.png", "rb");
4833 im = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4834 fclose(in);
4835 /* Look for black in the color table and make it transparent. */
4836 black = <A HREF="#gdImageColorExact">gdImageColorExact</A>(im, 0, 0, 0);
4837 /* If black is present... */
4838 if (black != (-1)) {
4839 /* Make it transparent */
4840 gdImageColorTransparent(im, black);
4841 }
4842 /* Save the newly-transparent image back to the file */
4843 out = fopen("photo.png", "wb");
4844 <A HREF="#gdImagePng">gdImagePng</A>(im, out);
4845 fclose(out);
4846 /* Destroy it */
4847 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
4848 </PRE>
4849 <DT><A NAME="gdImageTrueColor">
4850 void gdImageTrueColor(int red, int green, int blue)</A>
4851 <STRONG>(MACRO)</STRONG>
4852 <DD>
4853 gdImageTrueColor returns an RGBA color value for use when
4854 drawing on a truecolor image. Red, green, and blue are all
4855 in the range between 0 (off) and 255 (maximum). This macro should
4856 not be used with palette-based images. If you need to write
4857 code which is compatible with both palette-based and
4858 truecolor images, use <a href="#gdImageColorResolve">gdImageColorResolve</a>.
4859 <DT><A NAME="gdTrueColorAlpha">
4860 void gdTrueColorAlpha(int red, int green, int blue, int alpha)</A>
4861 <STRONG>(MACRO)</STRONG>
4862 <DD>
4863 gdTrueColorAlpha returns an RGBA color value for use when
4864 drawing on a truecolor image with alpha channel transparency. Red,
4865 green, and blue are all
4866 in the range between 0 (off) and 255 (maximum). Alpha is in the
4867 range between 0 (opaque) and 127 (fully transparent). This macro should
4868 not be used with palette-based images. If you need to write
4869 code which is compatible with both palette-based and
4870 truecolor images, use <a href="#gdImageColorResolveAlpha">gdImageColorResolveAlpha</a>.</DL>
4871 <H3><A NAME="copying">Copying and resizing functions</A></H3>
4872 <DL>
4873
4874 <DT><A NAME="gdImageCopy">void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
4875 <STRONG> (FUNCTION)</STRONG>
4876 <DD>
4877 gdImageCopy is used to copy a rectangular portion of one image to
4878 another image. (For a way of stretching or shrinking the image
4879 in the process, see <A HREF="#gdImageCopyResized">
4880 gdImageCopyResized</A>.)
4881 <P>
4882 The <code>dst</code> argument is the destination image to which the
4883 region will be copied. The <code>src</code> argument is the source
4884 image from which the region is copied. The <code>dstX</code>
4885 and <code>dstY</code> arguments specify the point in the destination
4886 image to which the region will be copied. The <code>srcX</code>
4887 and <code>srcY</code> arguments specify the upper left corner
4888 of the region in the source image. The <code>w</code>
4889 and <code>h</code> arguments specify the width and height
4890 of the region.
4891 <P>
4892 When you copy a region from one location in an image to another
4893 location in the same image, gdImageCopy will perform as expected
4894 unless the regions overlap, in which case the result is
4895 unpredictable.
4896 <P>
4897 <strong>Important note on copying between images:</strong> since
4898 different images do
4899 not necessarily have the same color tables, pixels are not simply set to the
4900 same color index values to copy them. gdImageCopy will attempt
4901 to find an identical RGB value in the destination image for
4902 each pixel in the copied portion of the source image by
4903 invoking <A HREF="#gdImageColorExact">gdImageColorExact</A>. If
4904 such a value is not found, gdImageCopy will attempt to
4905 allocate colors as needed using <A HREF="#gdImageColorAllocate">
4906 gdImageColorAllocate</A>. If both of these methods fail,
4907 gdImageCopy will invoke <A HREF="#gdImageColorClosest">
4908 gdImageColorClosest</A> to find the color in the destination
4909 image which most closely approximates the color of the
4910 pixel being copied.
4911 <PRE>
4912 ... Inside a function ...
4913 <A HREF="#gdImagePtr">gdImagePtr</A> im_in;
4914 <A HREF="#gdImagePtr">gdImagePtr</A> im_out;
4915 int x, y;
4916 FILE *in;
4917 FILE *out;
4918 /* Load a small png to tile the larger one with */
4919 in = fopen("small.png", "rb");
4920 im_in = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4921 fclose(in);
4922 /* Make the output image four times as large on both axes */
4923 im_out = <A HREF="#gdImageCreate">gdImageCreate</A>(im_in->sx * 4, im_in->sy * 4);
4924 /* Now tile the larger image using the smaller one */
4925 for (y = 0; (y < 4); y++) {
4926 for (x = 0; (x < 4); x++) {
4927 gdImageCopy(im_out, im_in,
4928 x * im_in->sx, y * im_in->sy,
4929 0, 0,
4930 im_in->sx, im_in->sy);
4931 }
4932 }
4933 out = fopen("tiled.png", "wb");
4934 <A HREF="#gdImagePng">gdImagePng</A>(im_out, out);
4935 fclose(out);
4936 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im_in);
4937 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im_out);
4938 </PRE>
4939 <DT><A NAME="gdImageCopyResized">void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int destW, int destH, int srcW, int srcH)
4940 <STRONG> (FUNCTION)</STRONG>
4941 <DD>
4942 gdImageCopyResized is used to copy a rectangular portion of one image to
4943 another image. The X and Y dimensions of the original region and the
4944 destination region can vary, resulting in stretching or shrinking of
4945 the region as appropriate. (For a simpler version of this function
4946 which does not deal with resizing, see <A HREF="#gdImageCopy">
4947 gdImageCopy</A>.)
4948 <P>
4949 The <code>dst</code> argument is the destination image to which the
4950 region will be copied. The <code>src</code> argument is the source
4951 image from which the region is copied. The <code>dstX</code>
4952 and <code>dstY</code> arguments specify the point in the destination
4953 image to which the region will be copied. The <code>srcX</code>
4954 and <code>srcY</code> arguments specify the upper left corner
4955 of the region in the source image. The <code>dstW</code>
4956 and <code>dstH</code> arguments specify the width and height
4957 of the destination region. The <code>srcW</code>
4958 and <code>srcH</code> arguments specify the width and height
4959 of the source region and can differ from the destination size,
4960 allowing a region to be scaled during the copying process.
4961 <P>
4962 When you copy a region from one location in an image to another
4963 location in the same image, gdImageCopy will perform as expected
4964 unless the regions overlap, in which case the result is
4965 unpredictable. If this presents a problem, create a scratch image
4966 in which to keep intermediate results.
4967 <P>
4968 <strong>Important note on copying between images:</strong> since images
4969 do not necessarily have the same color tables, pixels are not simply set
4970 to the same color index values to copy them. gdImageCopy will attempt
4971 to find an identical RGB value in the destination image for
4972 each pixel in the copied portion of the source image by
4973 invoking <A HREF="#gdImageColorExact">gdImageColorExact</A>. If
4974 such a value is not found, gdImageCopy will attempt to
4975 allocate colors as needed using <A HREF="#gdImageColorAllocate">
4976 gdImageColorAllocate</A>. If both of these methods fail,
4977 gdImageCopy will invoke <A HREF="#gdImageColorClosest">
4978 gdImageColorClosest</A> to find the color in the destination
4979 image which most closely approximates the color of the
4980 pixel being copied.
4981 <PRE>
4982 ... Inside a function ...
4983 <A HREF="#gdImagePtr">gdImagePtr</A> im_in;
4984 <A HREF="#gdImagePtr">gdImagePtr</A> im_out;
4985 int x, y;
4986 FILE *in;
4987 FILE *out;
4988 /* Load a small png to expand in the larger one */
4989 in = fopen("small.png", "rb");
4990 im_in = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
4991 fclose(in);
4992 /* Make the output image four times as large on both axes */
4993 im_out = <A HREF="#gdImageCreate">gdImageCreate</A>(im_in->sx * 4, im_in->sy * 4);
4994 /* Now copy the smaller image, but four times larger */
4995 gdImageCopyResized(im_out, im_in, 0, 0, 0, 0,
4996 im_out->sx, im_out->sy,
4997 im_in->sx, im_in->sy);
4998 out = fopen("large.png", "wb");
4999 <A HREF="#gdImagePng">gdImagePng</A>(im_out, out);
5000 fclose(out);
5001 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im_in);
5002 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im_out);
5003 </PRE>
5004 <DT><A NAME="gdImageCopyResampled">void gdImageCopyResampled(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int destW, int destH, int srcW, int srcH)
5005 <STRONG> (FUNCTION)</STRONG>
5006 <DD>
5007 gdImageCopyResampled is used to copy a rectangular portion of one image to
5008 another image, smoothly interpolating pixel values so that, in particular,
5009 reducing the size of an image still retains a great deal of clarity. The
5010 X and Y dimensions of the original region and the
5011 destination region can vary, resulting in stretching or shrinking of
5012 the region as appropriate. (For a simpler version of this function
5013 which does not deal with resizing, see <A HREF="#gdImageCopy">
5014 gdImageCopy</A>. For a version which does not interpolate pixel values,
5015 see <A HREF="#gdImageCopyResized">gdImageCopyResized</A>.
5016 <p>
5017 Pixel values are only interpolated if the destination image is a
5018 truecolor image. Otherwise,
5019 <a href="#gdImageCopyResized">gdImageCopyResized</a> is
5020 automatically invoked.
5021 <P>
5022 The <code>dst</code> argument is the destination image to which the
5023 region will be copied. The <code>src</code> argument is the source
5024 image from which the region is copied. The <code>dstX</code>
5025 and <code>dstY</code> arguments specify the point in the destination
5026 image to which the region will be copied. The <code>srcX</code>
5027 and <code>srcY</code> arguments specify the upper left corner
5028 of the region in the source image. The <code>dstW</code>
5029 and <code>dstH</code> arguments specify the width and height
5030 of the destination region. The <code>srcW</code>
5031 and <code>srcH</code> arguments specify the width and height
5032 of the source region and can differ from the destination size,
5033 allowing a region to be scaled during the copying process.
5034 <P>
5035 When you copy a region from one location in an image to another
5036 location in the same image, gdImageCopy will perform as expected
5037 unless the regions overlap, in which case the result is
5038 unpredictable. If this presents a problem, create a scratch image
5039 in which to keep intermediate results.
5040 <P>
5041 <strong>Important note on copying between images:</strong> since images
5042 do not necessarily have the same color tables, pixels are not simply set
5043 to the same color index values to copy them. If the destination image
5044 is a palette image, gd will use the
5045 <a href="#gdImageColorResolve">gdImageColorResolve</a> function to
5046 determine the best color available.
5047 <PRE>
5048 ... Inside a function ...
5049 <A HREF="#gdImagePtr">gdImagePtr</A> im_in;
5050 <A HREF="#gdImagePtr">gdImagePtr</A> im_out;
5051 int x, y;
5052 FILE *in;
5053 FILE *out;
5054 /* Load a large png to shrink in the smaller one */
5055 in = fopen("large.png", "rb");
5056 im_in = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
5057 fclose(in);
5058 /* Make the output image four times as small on both axes. Use
5059 a true color image so that we can interpolate colors. */
5060 im_out = <A HREF="#gdImageCreate">gdImageCreateTrueColor</A>(im_in->sx / 4, im_in->sy / 4);
5061 /* Now copy the large image, but four times smaller */
5062 gdImageCopyResampled(im_out, im_in, 0, 0, 0, 0,
5063 im_out->sx, im_out->sy,
5064 im_in->sx, im_in->sy);
5065 out = fopen("large.png", "wb");
5066 <A HREF="#gdImagePng">gdImagePng</A>(im_out, out);
5067 fclose(out);
5068 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im_in);
5069 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im_out);
5070 </PRE>
5071 <DT><A NAME="gdImageCopyRotated">void gdImageCopyRotated(gdImagePtr dst, gdImagePtr src, double dstX, double dstY, int srcX, int srcY, int srcW, int srcH, int angle)
5072 <STRONG> (FUNCTION)</STRONG>
5073 <DD>
5074 gdImageCopyRotated is used to copy a rectangular portion of one image to
5075 another image, or to another region of the same image. <strong>The srcX and
5076 srcY coordinates specify the upper left corner of the source area; however,
5077 the dstX and dstY coordinates specify the CENTER of the destination area.
5078 </strong> This important distinction is made because the rotated rectangle may
5079 may or may not be parallel to the X and Y axes. The destination coordinates
5080 may be floating point, as the center of the desired destination area may lie
5081 at the center of a pixel (0.5 pixels) rather than its upper left corner.
5082 The angle specified is an integer number of degrees, between 0 and 360,
5083 with 0 degrees causing no change, and counterclockwise rotation as
5084 the angle increases.
5085 <P>
5086 When you copy a region from one location in an image to another
5087 location in the same image, gdImageCopyRotated will perform as expected
5088 unless the regions overlap, in which case the result is
5089 unpredictable. If this presents a problem, create a scratch image
5090 in which to keep intermediate results.
5091 <P>
5092 <strong>Important note on copying between images:</strong> since
5093 palette-based images do not necessarily have the same color tables, pixels
5094 are not simply set to the same color index values to copy them.
5095 If the destination image is not a truecolor image,
5096 <a href="#gdImageColorResolveAlpha">gdImageColorResolveAlpha</a> is
5097 used to choose the destination pixel.
5098 <PRE>
5099 ... Inside a function ...
5100 <A HREF="#gdImagePtr">gdImagePtr</A> im_in;
5101 <A HREF="#gdImagePtr">gdImagePtr</A> im_out;
5102 int x, y;
5103 int a;
5104 FILE *in;
5105 FILE *out;
5106 /* Load a small png to rotate in the larger one */
5107 in = fopen("small.png", "rb");
5108 im_in = <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A>(in);
5109 fclose(in);
5110 /* Make the output image four times as large on both axes */
5111 im_out = <A HREF="#gdImageCreate">gdImageCreate</A>(im_in->sx * 4, im_in->sy * 4);
5112 /* Now rotate the smaller image */
5113 for (a = 0; (a < 360); a += 45) {
5114 double x = cos(a * .0174532925) * gdImageSX(im_out) / 2;
5115 double y = -sin(a * .0174532925) * gdImageSY(im_out) / 2;
5116 gdImageCopyRotated(im_out, im_in,
5117 gdImageSX(im_out) / 2 + x,
5118 gdImageSY(im_out) / 2 + y,
5119 0, 0,
5120 gdImageSX(im_in),
5121 gdImageSY(im_in),
5122 a);
5123 }
5124 out = fopen("large.png", "wb");
5125 <A HREF="#gdImagePng">gdImagePng</A>(im_out, out);
5126 fclose(out);
5127 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im_in);
5128 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im_out);
5129 </PRE>
5130
5131 <DT><A NAME="gdImageCopyMerge">void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h, int pct)
5132 <STRONG> (FUNCTION)</STRONG>
5133 <DD>
5134 gdImageCopyMerge is almost identical to <a href=#gdImageCopy>gdImageCopy</a>, except that
5135 it 'merges' the two images by an amount specified in the last parameter. If the last
5136 parameter is 100, then it will function identically to gdImageCopy - the source image replaces
5137 the pixels in the destination.
5138 <p>
5139 If, however, the <strong>pct</strong> parameter is less than 100, then the two images are merged.
5140 With pct = 0, no action is taken.
5141 <p>This feature is most useful to 'highlight' sections of an image by merging a solid color with
5142 pct = 50:
5143 <PRE>
5144 ... Inside a function ...
5145 gdImageCopyMerge(im_out, im_in, 100, 200, 0, 0, 30, 50, 50);
5146 </PRE>
5147
5148 <DT><A NAME="gdImageCopyMergeGray">void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int
5149 w, int h, int pct)
5150 <STRONG> (FUNCTION)</STRONG>
5151 <DD>
5152 gdImageCopyMergeGray is almost identical to <a href=#gdImageCopyMerge>gdImageCopyMerge</a>,
5153 except that when merging images it preserves the hue of the source by converting the destination
5154 pixels to grey scale before the copy operation.
5155 <PRE>
5156 ... Inside a function ...
5157 gdImageCopyMergeGray(im_out, im_in, 100, 200, 0, 0, 30, 50, 50);
5158 </PRE>
5159
5160 <DT><A NAME="gdImagePaletteCopy">void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src)
5161 <STRONG> (FUNCTION)</STRONG>
5162 <DD>
5163 Copies a palette from one image to another, attempting to match the colors in the target image
5164 to the colors
5165 in the source palette.
5166 <DT><A NAME="gdImageSquareToCircle">void gdImageSquareToCircle(gdImagePtr im, int radius)</a>
5167 <STRONG> (FUNCTION)</STRONG>
5168 <DD>
5169 <b>im MUST be square, but can have any size.</b> Returns a new image
5170 of width and height radius * 2, in which the X axis of
5171 the original has been remapped to theta (angle) and the Y axis
5172 of the original has been remapped to rho (distance from center).
5173 This is known as a "polar coordinate transform."
5174 See also <a href="#gdImageStringFTCircle">gdImageStringFTCircle</a>, which
5175 uses this function internally.
5176 <DT><A NAME="gdImageSharpen">void gdImageSharpen(gdImagePtr im, int pct)</a>
5177 <STRONG> (FUNCTION)</STRONG>
5178 <DD>
5179 Sharpens the specified image. pct is a sharpening percentage, and
5180 can be greater than 100. Silently does nothing to non-truecolor images.
5181 Silently does nothing for pct<0. Transparency/alpha channel are not
5182 altered.
5183 </DL>
5184 <H3><A NAME="misc">Miscellaneous Functions</A></H3>
5185 <DL>
5186
5187 <DT><A NAME="gdImageCompare">int gdImageCompare(gdImagePtr im1, gdImagePtr im2)
5188 <STRONG> (FUNCTION)</STRONG>
5189 <DD>
5190 gdImageCompare returns a bitmap indicating if the two images are different. The members of the
5191 bitmap are defined in gd.h, but the most important is GD_CMP_IMAGE, which indicated that the images
5192 will actually appear different when displayed. Other, less important, differences relate to pallette
5193 entries. Any difference in the transparent colour is assumed to make images display differently,
5194 even if the transparent colour is not used.
5195 <PRE>
5196 ... Inside a function ...
5197 cmpMask = gdImageCompare(im1, im2);
5198 </PRE>
5199
5200 <DT><A NAME="gdImageInterlace">gdImageInterlace(gdImagePtr im, int interlace)</A> <strong>(FUNCTION)</strong>
5201 <DD>
5202 gdImageInterlace is used to determine whether an image should be stored
5203 in a linear fashion, in which lines will appear on the display from
5204 first to last, or in an interlaced fashion, in which the image
5205 will "fade in" over several passes. By default, images are not
5206 interlaced. (When writing JPEG images, interlacing implies generating
5207 progressive JPEG files, which are represented as a series of scans of
5208 increasing quality. Noninterlaced gd images result in regular
5209 [sequential] JPEG data streams.)
5210 <P>
5211 A nonzero value for the interlace argument turns on interlace;
5212 a zero value turns it off. Note that interlace has no effect
5213 on other functions, and has no meaning unless you save the
5214 image in PNG or JPEG format; the gd and xbm formats do not support
5215 interlace.
5216 <P>
5217 When a PNG is loaded with
5218 <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A> or a JPEG is
5219 loaded with
5220 <A HREF="#gdImageCreateFromJpeg">gdImageCreateFromJpeg</A>, interlace
5221 will be set according to the setting in the PNG or JPEG file.
5222 <P>
5223 Note that many PNG and JPEG viewers and web browsers do <em>not</em>
5224 support interlace or the incremental display of progressive
5225 JPEGs. However, the interlaced PNG or progressive JPEG should still
5226 display; it will simply appear all at once, just as other images do.
5227 <PRE>
5228 gdImagePtr im;
5229 FILE *out;
5230 /* ... Create or load the image... */
5231
5232 /* Now turn on interlace */
5233 gdImageInterlace(im, 1);
5234 /* And open an output file */
5235 out = fopen("test.png", "wb");
5236 /* And save the image -- could also use <A HREF="#gdImageJpeg">gdImageJpeg</A> */
5237 <A HREF="#gdImagePng">gdImagePng</A>(im, out);
5238 fclose(out);
5239 <A HREF="#gdImageDestroy">gdImageDestroy</A>(im);
5240 </PRE>
5241 <DT><A NAME="gdFree">gdFree(void *ptr)</A> <strong>(FUNCTION)</strong>
5242 <DD>
5243 gdFree provides a reliable way to free memory allocated by functions
5244 such as <a href="#gdImagePngPtr">gdImagePngPtr</a> which return
5245 blocks of memory. Use of this function guarantees that the
5246 version of <code>free()</code> that is ultimately called will
5247 be intended for use with the version of <code>malloc()</code> that
5248 originally allocated the block.
5249 </DL>
5250 <H3><A NAME="constants">Constants</A></H3>
5251 <DL>
5252 <DT><A NAME="gdAntiAliased">gdAntiAliased</A> <strong>(CONSTANT)</strong>
5253 <DD>
5254 Used in place of a color when invoking a line-drawing
5255 function such as <A HREF="#gdImageLine">gdImageLine</A>
5256 or <A HREF="#gdImageRectangle">gdImageRectangle</A>.
5257 When gdAntiAliased is used as the color, the foreground color
5258 set with <a href="#gdImageSetAntiAliased">gdImageSetAntiAliased</a>
5259 is used, with antialiasing mechanisms to minimize any
5260 "jagged" appearance.
5261 For more information, see
5262 <a href="#gdImageSetAntiAliased">gdImageSetAntiAliased</a>.
5263 <DT><A NAME="gdBrushed">gdBrushed</A> <strong>(CONSTANT)</strong>
5264 <DD>
5265 Used in place of a color when invoking a line-drawing
5266 function such as <A HREF="#gdImageLine">gdImageLine</A>
5267 or <A HREF="#gdImageRectangle">gdImageRectangle</A>.
5268 When gdBrushed is used as the color, the brush
5269 image set with <A HREF="#gdImageSetBrush">gdImageSetBrush</A>
5270 is drawn in place of each pixel of the line (the brush is
5271 usually larger than one pixel, creating the effect
5272 of a wide paintbrush). See also
5273 <A HREF="#gdStyledBrushed">gdStyledBrushed</A> for a way
5274 to draw broken lines with a series of distinct copies of an image.
5275 <DT><A NAME="gdMaxColors"><code>gdMaxColors</code><strong>(CONSTANT)</strong>
5276 <DD>
5277 The constant 256. This is the maximum number of colors in a palette-based
5278 PNG file according to the PNG standard, and is also the maximum number of
5279 colors in a palette-based gd image. This of course does not apply to
5280 truecolor images.
5281 <DT><A NAME="gdStyled">gdStyled</A> <strong>(CONSTANT)</strong>
5282 <DD>
5283 Used in place of a color when invoking a line-drawing
5284 function such as <A HREF="#gdImageLine">gdImageLine</A>
5285 or <A HREF="#gdImageRectangle">gdImageRectangle</A>.
5286 When gdStyled is used as the color, the colors of the pixels are
5287 drawn successively from the style that has been
5288 set with <A HREF="#gdImageSetStyle">gdImageSetStyle</A>.
5289 If the color of a pixel is equal to
5290 <A HREF="#gdTransparent">gdTransparent</A>, that pixel
5291 is not altered. (This mechanism is completely unrelated
5292 to the "transparent color" of the image itself; see
5293 <A HREF="#gdImageColorTransparent">gdImageColorTransparent</A>
5294 gdImageColorTransparent for that mechanism.) See also
5295 <A NAME="#gdStyledBrushed"> gdStyledBrushed</A>.
5296 <DT><A NAME="gdStyledBrushed">gdStyledBrushed</A> <strong>(CONSTANT)</strong>
5297 <DD>
5298 Used in place of a color when invoking a line-drawing
5299 function such as <A HREF="#gdImageLine">gdImageLine</A>
5300 or <A HREF="#gdImageRectangle">gdImageRectangle</A>.
5301 When gdStyledBrushed is used as the color, the brush
5302 image set with <A HREF="#gdImageSetBrush">gdImageSetBrush</A>
5303 is drawn at each pixel of the line, providing that the
5304 style set with <A HREF="#gdImageSetStyle">gdImageSetStyle</A>
5305 contains a nonzero value (OR gdTransparent, which
5306 does not equal zero but is supported for consistency)
5307 for the current pixel. (Pixels are drawn successively from the style as the
5308 line is drawn, returning to the beginning when the
5309 available pixels in the style are exhausted.) Note that
5310 this differs from the behavior of <A HREF="#gdStyled">gdStyled</A>,
5311 in which the values in the style are used as actual
5312 pixel colors, except for gdTransparent.
5313 <DT><A NAME="gdDashSize">gdDashSize</A> <strong>(CONSTANT)</strong>
5314 <DD>
5315 The length of a dash in a dashed line. Defined to be 4 for
5316 backwards compatibility with programs that use
5317 <A NAME="gdImageDashedLine">gdImageDashedLine</A>. New
5318 programs should use <A NAME="gdImageSetStyle">
5319 gdImageSetStyle</A> and call the standard
5320 <A NAME="gdImageLine">gdImageLine</A> function
5321 with the special "color" <A NAME="gdStyled">
5322 gdStyled</A> or <A NAME="gdStyledBrushed">gdStyledBrushed</A>.
5323 <DT><A NAME="gdTiled">gdTiled</A> <strong>(CONSTANT)</strong>
5324 <DD>
5325 Used in place of a normal color in <A HREF="#gdImageFilledRectangle">
5326 gdImageFilledRectangle</A>, <A HREF="#gdImageFilledPolygon">
5327 gdImageFilledPolygon</A>,
5328 <A HREF="#gdImageFill">gdImageFill</A>, and <A HREF="#gdImageFillToBorder">
5329 gdImageFillToBorder</A>. gdTiled selects a pixel from the
5330 tile image set with <A HREF="#gdImageSetTile">gdImageSetTile</A>
5331 in such a way as to ensure that the filled area will be
5332 tiled with copies of the tile image. See the discussions of
5333 <A HREF="#gdImageFill">gdImageFill</A> and
5334 <A HREF="#gdImageFillToBorder">gdImageFillToBorder</A> for special
5335 restrictions regarding those functions.
5336 <DT><A NAME="gdTransparent">gdTransparent</A> <strong>(CONSTANT)</strong>
5337 <DD>
5338 Used in place of a normal color in a style to be set with
5339 <A HREF="#gdImageSetStyle">gdImageSetStyle</A>.
5340 gdTransparent is <strong>not</strong> the transparent
5341 color index of the image; for that functionality please
5342 see <A HREF="#gdImageColorTransparent">gdImageColorTransparent</A>.
5343 </DL>
5344
5345 <A NAME="gdformat"><H3>About the additional .gd image file format</H3></A>
5346 In addition to reading and writing the PNG and JPEG formats and reading the
5347 X Bitmap format, gd has the capability to read and write its
5348 own ".gd" format. This format is <em>not</em> intended for
5349 general purpose use and should never be used to distribute
5350 images. It is not a compressed format. Its purpose is solely to
5351 allow very fast loading of images your program needs often in
5352 order to build other images for output. If you are experiencing
5353 performance problems when loading large, fixed PNG images your
5354 program needs to produce its output images, you may wish
5355 to examine the functions <A HREF="#gdImageCreateFromGd">
5356 gdImageCreateFromGd</A> and <A HREF="#gdImageGd">gdImageGd</A>,
5357 which read and write .gd format images.
5358
5359 <P>
5360 The program "pngtogd.c" is provided as a simple way of converting
5361 .png files to .gd format. I emphasize again that you will not
5362 need to use this format unless you have a need for high-speed loading
5363 of a few frequently-used images in your program.
5364
5365 <A NAME="gd2format"><H3>About the .gd2 image file format</H3></A>
5366 In addition to reading and writing the PNG format and reading the
5367 X Bitmap format, gd has the capability to read and write its
5368 own ".gd2" format. This format is <em>not</em> intended for
5369 general purpose use and should never be used to distribute
5370 images. It is a compressed format allowing pseudo-random access
5371 to large image files. Its purpose is solely to
5372 allow very fast loading of <strong>parts</strong> of images
5373 If you are experiencing
5374 performance problems when loading large, fixed PNG or JPEG images your
5375 program needs to produce its output images, you may wish
5376 to examine the functions <A HREF="#gdImageCreateFromGd2">
5377 gdImageCreateFromGd2</A>, <A HREF="#gdImageCreateFromGd2Part">
5378 gdImageCreateFromGd2Part</A> and <A HREF="#gdImageGd2">gdImageGd2</A>,
5379 which read and write .gd2 format images.
5380
5381 <P>
5382 The program "pngtogd2.c" is provided as a simple way of converting
5383 .png files to .gd2 format.
5384
5385 <A NAME="gdioctx"><H3>About the gdIOCtx structure</H3></A>
5386 Version 1.5 of GD added a new style of I/O based on an IOCtx
5387 structure (the most up-to-date version can be found in gd_io.h):
5388 <PRE>
5389 typedef struct gdIOCtx {
5390 int (*getC)(struct gdIOCtx*);
5391 int (*getBuf)(struct gdIOCtx*, void*, int);
5392
5393 void (*putC)(struct gdIOCtx*, int);
5394 int (*putBuf)(struct gdIOCtx*, const void*, int);
5395
5396 int (*seek)(struct gdIOCtx*, const int); /* Returns 1 on SUCCESS */
5397 long (*tell)(struct gdIOCtx*);
5398
5399 void (*free)(struct gdIOCtx*);
5400
5401 } gdIOCtx;
5402 </PRE>
5403
5404 Most functions that accepted files in previous versions now also have a
5405 counterpart that accepts an I/O context. These functions have a 'Ctx'
5406 suffix.
5407 <p>
5408 The <xxx>Ctx routines use the function pointers in the I/O context pointed to
5409 by gdIOCtx to perform all I/O. Examples of how to implement an I/O context
5410 can be found in io_file.c (which provides a wrapper for file routines), and
5411 io_dp.c (which implements in-memory storage).
5412 <p>
5413 It is not necessary to implement all functions in an I/O context if you know
5414 that it will only be used in limited cirsumstances. At the time of writing
5415 (Version 1.6.1, July 1999), the known requirements are:
5416 <p>
5417 <Table>
5418 <TR><TD>All</TD><td width=20>&nbsp;</td><TD>Must have 'free',</td></tr>
5419 <TR><TD>Anything that reads from the context</TD><td></td><TD>Must have 'getC' and 'getBuf',</td></tr>
5420 <TR><TD>Anything that writes to the context</TD><td></td><TD>Must have 'putC' and 'putBuf'.</td></tr>
5421 <TR><TD>If gdCreateFromGd2Part is called</td><td></td><TD>Must also have 'seek' and 'tell'. Note: seek must return 1 on SUCCESS and 0 on FAILURE.</td></tr>
5422 <TR><TD>If gdImageGd2 is called</td><td></td><TD>Must also have 'seek' and 'tell'.</td></tr>
5423 </Table>
5424
5425
5426
5427 <A NAME="informing"><H3>Please tell us you're using gd!</H3>
5428 When you contact us and let us know you are using gd,
5429 you help us justify the time spent in maintaining and improving
5430 it. So please let us know. If the results are publicly
5431 visible on the web, a URL is a wonderful thing to receive, but
5432 if it's not a publicly visible project, a simple note is just
5433 as welcome.
5434
5435 <A NAME="support"><H3>How do I get support?</H3></A>
5436 <h4>Free Support</h4>
5437
5438 Anyone can mail questions about the gd library using the
5439 <a href="http://www.libgd.org/Wiki/Support">LibGD support</a>. However,
5440 we receive a very large volume of email on many subjects, and while we do
5441 our best to respond to all queries this can take some time. Sometimes
5442 the response must take the form of an eventual new release or
5443 an addition to a FAQ or other document, as opposed to an detailed individual response.
5444
5445 <h4>Hourly Support</h4>
5446 Those requiring support in detail may arrange for direct support
5447 from the maintaines, at the rate of $50/hr, billed
5448 directly by credit card. Purchase orders are also accepted from
5449 Fortune 500 corporations and institutions in good standing.
5450 To make arrangements, contact <A HREF="http://www.libgd.org/Contact">Pierre-A. Joye</A>. To avoid delay
5451 and/or confusion, be sure to specifically mention that you wish to purchase gd support at the
5452 hourly rate above.
5453
5454 <A NAME="issues"><H3>How do I report issues, bugs or features request?</H3></A>
5455 Bugs, feature requests or other issues can be reported using the
5456 <A HREF="http://bugs.libgd.org">libGD.org issues tracker.</A> as well as using
5457 one of our support channels: <a href="http://www.libgd.org/Wiki/Support">LibGD support</a>
5458
5459 <H3><A NAME="index">Alphabetical quick index</A></H3>
5460 <A HREF="#gdAntiAliased">gdAntiAliased</A> |
5461 <A HREF="#gdBrushed">gdBrushed</A> |
5462 <A HREF="#gdDashSize">gdDashSize</A> |
5463 <A HREF="#gdFont">gdFont</A> |
5464 <A HREF="#gdFontGetHuge">gdFontGetHuge</A> |
5465 <A HREF="#gdFontGetLarge">gdFontGetLarge</A> |
5466 <A HREF="#gdFontGetMediumBold">gdFontGetMediumBold</A> |
5467 <A HREF="#gdFontGetSmall">gdFontGetSmall</A> |
5468 <A HREF="#gdFontGetTiny">gdFontGetTiny</A> |
5469 <A HREF="#gdFontCacheSetup">gdFontCacheSetup</A> |
5470 <A HREF="#gdFontCacheShutdown">gdFontCacheShutdown</A> |
5471 <A HREF="#gdFontPtr">gdFontPtr</A> |
5472 <A HREF="#gdFree">gdFree</A> |
5473 <A HREF="#gdImage">gdImage</A> |
5474 <A HREF="#gdImageAlphaBlending">gdImageAlphaBlending</A> |
5475 <A HREF="#gdImageArc">gdImageArc</A> |
5476 <A HREF="#gdImageBlue">gdImageBlue</A> |
5477 <A HREF="#gdImageBoundsSafe">gdImageBoundsSafe</A> |
5478 <A HREF="#gdImageChar">gdImageChar</A> |
5479 <A HREF="#gdImageCharUp">gdImageCharUp</A> |
5480 <A HREF="#gdImageColorAllocate">gdImageColorAllocate</A> |
5481 <A HREF="#gdImageColorAllocateAlpha">gdImageColorAllocateAlpha</A> |
5482 <A HREF="#gdImageColorClosest">gdImageColorClosest</A> |
5483 <A HREF="#gdImageColorClosestAlpha">gdImageColorClosestAlpha</A> |
5484 <A HREF="#gdImageColorClosestHWB">gdImageColorClosestHWB</A> |
5485 <A HREF="#gdImageColorDeallocate">gdImageColorDeallocate</A> |
5486 <A HREF="#gdImageColorExact">gdImageColorExact</A> |
5487 <A HREF="#gdImageColorExactAlpha">gdImageColorExactAlpha</A> |
5488 <A HREF="#gdImageColorResolve">gdImageColorResolve</A> |
5489 <A HREF="#gdImageColorResolveAlpha">gdImageColorResolveAlpha</A> |
5490 <A HREF="#gdImageColorTransparent">gdImageColorTransparent</A> |
5491 <A HREF="#gdImageCopy">gdImageCopy</A> |
5492 <A HREF="#gdImageCopyMerge">gdImageCopyMerge</A> |
5493 <A HREF="#gdImageCopyMergeGray">gdImageMergeGray</A> |
5494 <A HREF="#gdImageCopyResized">gdImageCopyResized</A> |
5495 <A HREF="#gdImageCopyResampled">gdImageCopyResampled</A> |
5496 <A HREF="#gdImageCopyRotated">gdImageCopyRotated</A> |
5497 <A HREF="#gdImageCreate">gdImageCreate</A> |
5498 <A HREF="#gdImageCreate">gdImageCreatePalette</A> |
5499 <A HREF="#gdImageCreate">gdImageCreateTrueColor</A> |
5500 <A HREF="#gdImageCreateFromGd">gdImageCreateFromGd</A> |
5501 <A HREF="#gdImageCreateFromGdCtx">gdImageCreateFromGdCtx</A> |
5502 <A HREF="#gdImageCreateFromGdPtr">gdImageCreateFromGdPtr</A> |
5503 <A HREF="#gdImageCreateFromGd2">gdImageCreateFromGd2</A> |
5504 <A HREF="#gdImageCreateFromGd2Ctx">gdImageCreateFromGd2Ctx</A> |
5505 <A HREF="#gdImageCreateFromGd2Ptr">gdImageCreateFromGd2Ptr</A> |
5506 <A HREF="#gdImageCreateFromGd2Part">gdImageCreateFromGd2Part</A> |
5507 <A HREF="#gdImageCreateFromGd2PartCtx">gdImageCreateFromGd2PartCtx</A> |
5508 <A HREF="#gdImageCreateFromGd2PartPtr">gdImageCreateFromGd2PartPtr</A> |
5509 <A HREF="#gdImageCreateFromJpeg">gdImageCreateFromJpeg</A> |
5510 <A HREF="#gdImageCreateFromJpegCtx">gdImageCreateFromJpegCtx</A> |
5511 <A HREF="#gdImageCreateFromJpegPtr">gdImageCreateFromJpegPtr</A> |
5512 <A HREF="#gdImageCreateFromPng">gdImageCreateFromPng</A> |
5513 <A HREF="#gdImageCreateFromPngCtx">gdImageCreateFromPngCtx</A> |
5514 <A HREF="#gdImageCreateFromPngPtr">gdImageCreateFromPngPtr</A> |
5515 <A HREF="#gdImageCreateFromPngSource">gdImageCreateFromPngSource</A> |
5516 <A HREF="#gdImageCreateFromWBMP">gdImageCreateFromWBMP</A> |
5517 <A HREF="#gdImageCreateFromWBMPCtx">gdImageCreateFromWBMPCtx</A> |
5518 <A HREF="#gdImageCreateFromWBMPPtr">gdImageCreateFromWBMPPtr</A> |
5519 <A HREF="#gdImageCreateFromXbm">gdImageCreateFromXbm</A> |
5520 <A HREF="#gdImageCreateFromXpm">gdImageCreateFromXpm</A> |
5521 <A HREF="#gdImageDashedLine">gdImageDashedLine</A> |
5522 <A HREF="#gdImageDestroy">gdImageDestroy</A> |
5523 <A HREF="#gdImageFill">gdImageFill</A> |
5524 <A HREF="#gdImageFilledArc">gdImageFilledArc</A> |
5525 <A HREF="#gdImageFilledEllipse">gdImageFilledEllipse</A> |
5526 <A HREF="#gdImageFillToBorder">gdImageFillToBorder</A> |
5527 <A HREF="#gdImageFilledRectangle">gdImageFilledRectangle</A> |
5528 <A HREF="#gdImageGd">gdImageGd</A> |
5529 <A HREF="#gdImageGd2">gdImageGd2</A> |
5530 <A HREF="#gdImageGetInterlaced">gdImageGetInterlaced</A> |
5531 <A HREF="#gdImageGetPixel">gdImageGetPixel</A> |
5532 <A HREF="#gdImageGetTransparent">gdImageGetTransparent</A> |
5533 <A HREF="#gdImageGifAnimAdd">gdImageGifAnimAdd</A> |
5534 <A HREF="#gdImageGifAnimAddCtx">gdImageGifAnimAddCtx</A> |
5535 <A HREF="#gdImageGifAnimAddPtr">gdImageGifAnimAddPtr</A> |
5536 <A HREF="#gdImageGifAnimBegin">gdImageGifAnimBegin</A> |
5537 <A HREF="#gdImageGifAnimBeginCtx">gdImageGifAnimBeginCtx</A> |
5538 <A HREF="#gdImageGifAnimBeginPtr">gdImageGifAnimBeginPtr</A> |
5539 <A HREF="#gdImageGifAnimEnd">gdImageGifAnimEnd</A> |
5540 <A HREF="#gdImageGifAnimEndCtx">gdImageGifAnimEndCtx</A> |
5541 <A HREF="#gdImageGifAnimEndPtr">gdImageGifAnimEndPtr</A> |
5542 <A HREF="#gdImageGreen">gdImageGreen</A> |
5543 <A HREF="#gdImageInterlace">gdImageInterlace</A> |
5544 <A HREF="#gdImageJpeg">gdImageJpeg</A> |
5545 <A HREF="#gdImageJpegCtx">gdImageJpegCtx</A> |
5546 <A HREF="#gdImageLine">gdImageLine</A> |
5547 <A HREF="#gdImageFilledPolygon">gdImageFilledPolygon</A> |
5548 <A HREF="#gdImageOpenPolygon">gdImageOpenPolygon</A> |
5549 <A HREF="#gdImagePaletteCopy">gdImagePaletteCopy</A> |
5550 <A HREF="#gdImagePng">gdImagePng</A> |
5551 <A HREF="#gdImagePngEx">gdImagePngEx</A> |
5552 <A HREF="#gdImagePngCtx">gdImagePngCtx</A> |
5553 <A HREF="#gdImagePngCtxEx">gdImagePngCtxEx</A> |
5554 <A HREF="#gdImagePngPtr">gdImagePngPtr</A> |
5555 <A HREF="#gdImagePngPtrEx">gdImagePngPtrEx</A> |
5556 <A HREF="#gdImagePngToSink">gdImagePngToSink</A> |
5557 <A HREF="#gdImagePolygon">gdImagePolygon</A> |
5558 <A HREF="#gdImagePtr">gdImagePtr</A> |
5559 <A HREF="#gdImageWBMP">gdImageWBMP</A> |
5560 <A HREF="#gdImageWBMPCtx">gdImageWBMPCtx</A> |
5561 <A HREF="#gdImageRectangle">gdImageRectangle</A> |
5562 <A HREF="#gdImageRed">gdImageRed</A> |
5563 <A HREF="#gdImageSaveAlpha">gdImageSaveAlpha</A> |
5564 <A HREF="#gdImageSetAntiAliased">gdImageSetAntiAliased</A> |
5565 <A HREF="#gdImageSetAntiAliasedDontBlend">gdImageSetAntiAliasedDontBlend</A> |
5566 <A HREF="#gdImageSetBrush">gdImageSetBrush</A> |
5567 <A HREF="#gdImageSetPixel">gdImageSetPixel</A> |
5568 <A HREF="#gdImageSetStyle">gdImageSetStyle</A> |
5569 <A HREF="#gdImageSetThickness">gdImageSetThickness</A> |
5570 <A HREF="#gdImageSetTile">gdImageSetTile</A> |
5571 <A HREF="#gdImageSharpen">gdImageSharpen</A> |
5572 <A HREF="#gdImageSquareToCircle">gdImageSquareToCircle</A> |
5573 <A HREF="#gdImageString">gdImageString</A> |
5574 <A HREF="#gdImageString16">gdImageString16</A> |
5575 <A HREF="#gdImageStringFT">gdImageStringFT</A> |
5576 <A HREF="#gdImageStringFTCircle">gdImageStringFTCircle</A> |
5577 <A HREF="#gdImageStringFTEx">gdImageStringFTEx</A> |
5578 <A HREF="#gdImageStringTTF">gdImageStringTTF</A> |
5579 <A HREF="#gdImageStringUp">gdImageStringUp</A> |
5580 <A HREF="#gdImageStringUp">gdImageStringUp16</A> |
5581 <A HREF="#gdImageToPalette">gdImageToPalette</A> |
5582 <A HREF="#gdImageWBMP">gdImageWBMP</A> |
5583 <A HREF="#gdMaxColors">gdMaxColors</A> |
5584 <A HREF="#gdPoint">gdPoint</A> |
5585 <A HREF="#gdStyled">gdStyled</A> |
5586 <A HREF="#gdStyledBrushed">gdStyledBrushed</A> |
5587 <A HREF="#gdTiled">gdTiled</A> |
5588 <A HREF="#gdTransparent">gdTransparent</A>
5589 <P>
5590 <em><A HREF="http://www.libgd.org/">
5591 www.libgd.org</A></em>
5592 </body>
5593