wolffd@0: wolffd@0:
wolffd@0:wolffd@0: UPGRADING UNIX USERS: READ THIS FIRST! wolffd@0: Modern versions of gd install by default to /usr/local/lib and wolffd@0: /usr/local/include. If you already have an older version of gd wolffd@0: in /usr/lib and /usr/include, you may wish to use: wolffd@0:wolffd@0:wolffd@0: ./configure --prefix=/usrwolffd@0: To ensure that your wolffd@0: new installation overwrites the old. wolffd@0:wolffd@0: GIF support has been restored in gd 2.0.28 and above. wolffd@0: The well-known patents on LZW compression held by Unisys wolffd@0: have expired in all countries. British Telecom and IBM may hold related wolffd@0: patents but have never chosen to require royalties for GIF applications, wolffd@0: to the best of my knowledge. I am not a lawyer and cannot give wolffd@0: legal advice regarding this issue. PNG remains a superior format especially wolffd@0: if lossless truecolor images are needed. wolffd@0:
wolffd@0: When building from soruce, gd 2.0.33 requires that the wolffd@0: following libraries also be installed, in order to produce the related wolffd@0: image formats. The win32 binary release (bgd) already contains the wolffd@0: appropriate libraries. wolffd@0: You may skip libraries associated with formats you do not use: wolffd@0:
wolffd@0: libpng (see the libpng home page), if you want PNG wolffd@0:
wolffd@0: zlib (see the info-zip home page), if you want PNG wolffd@0:
wolffd@0: jpeg-6b or later, if desired (see the Independent JPEG Group home page), if you want JPEG wolffd@0:
wolffd@0: If you want to use the TrueType font support, you must also wolffd@0: install the FreeType 2.x library, including wolffd@0: the header files. See the Freetype wolffd@0: Home Page, or SourceForge. wolffd@0: No, I cannot explain why that site is down on a particular day, and no, I wolffd@0: can't send you a copy. wolffd@0:
wolffd@0: If you want to use the Xpm color bitmap loading support, you must also wolffd@0: have the X Window System and the Xpm library installed (Xpm is often wolffd@0: included in modern X distributions). Most of the time you won't wolffd@0: need Xpm. wolffd@0:
wolffd@0: Please read the documentation and install the required libraries. wolffd@0: Do not send email asking why
png.h
is not found. wolffd@0: Do not send email asking whylibgd.so
is not found, either. wolffd@0: See the requirements section for more wolffd@0: information. Thank you! wolffd@0:
wolffd@0: Up to the LibGD Homepage
wolffd@0: Credits and license terms
wolffd@0:
wolffd@0: In order to resolve any possible confusion regarding the authorship wolffd@0: of gd, the following copyright statement covers all of the authors wolffd@0: who have required such a statement. If you are aware of any oversights wolffd@0: in this copyright notice, please contact Pierre-A. Joye who will be wolffd@0: pleased to correct them. wolffd@0:
wolffd@0: COPYRIGHT STATEMENT FOLLOWS THIS LINE wolffd@0:wolffd@0:
wolffd@0: wolffd@0: Portions copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 by Cold Spring wolffd@0: Harbor Laboratory. Funded under Grant P41-RR02188 by the National wolffd@0: Institutes of Health. wolffd@0:wolffd@0:wolffd@0: Portions copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 by Boutell.Com, Inc. wolffd@0:
wolffd@0: Portions relating to GD2 format copyright 1999, 2000, 2001, 2002, 2003, 2004 Philip Warner. wolffd@0:
wolffd@0: Portions relating to PNG copyright 1999, 2000, 2001, 2002, 2003, 2004 Greg Roelofs. wolffd@0:
wolffd@0: Portions relating to gdttf.c copyright 1999, 2000, 2001, 2002, 2003, 2004 John Ellson (ellson@graphviz.org). wolffd@0:
wolffd@0: Portions relating to gdft.c copyright 2001, 2002, 2003, 2004 John Ellson (ellson@graphviz.org). wolffd@0:
wolffd@0: Portions copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Pierre-Alain Joye (pierre@libgd.org). wolffd@0: wolffd@0:
wolffd@0: 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 wolffd@0: in part on the work of the Independent JPEG Group. See the file wolffd@0: README-JPEG.TXT for more information. wolffd@0:
wolffd@0: Portions relating to GIF compression copyright 1989 by Jef wolffd@0: Poskanzer and David Rowley, with modifications for thread safety wolffd@0: by Thomas Boutell. wolffd@0:
wolffd@0: Portions relating to GIF decompression copyright 1990, 1991, 1993 wolffd@0: by David Koblas, with modifications for thread safety by wolffd@0: Thomas Boutell. wolffd@0:
wolffd@0: Portions relating to WBMP copyright 2000, 2001, 2002, 2003, 2004 Maurice Szmurlo and Johan Van wolffd@0: den Brande. wolffd@0:
wolffd@0: Portions relating to GIF animations copyright 2004 Jaakko Hyvätti (jaakko.hyvatti@iki.fi) wolffd@0:
wolffd@0: Permission has been granted to copy, distribute and modify gd in any wolffd@0: context without fee, including a commercial application, provided that this notice wolffd@0: is present in user-accessible supporting documentation. wolffd@0:
wolffd@0: This does not affect your ownership of the derived work itself, and the intent wolffd@0: is to assure proper credit for the authors of gd, not to interfere wolffd@0: with your productive use of gd. If you have questions, ask. wolffd@0: "Derived works" includes all programs that utilize the library. wolffd@0: Credit must be given in user-accessible documentation. wolffd@0:
wolffd@0: This software is provided "AS IS." wolffd@0: The copyright holders disclaim all warranties, either express or implied, wolffd@0: including but not limited to implied warranties of merchantability and wolffd@0: fitness for a particular purpose, with respect to this code and accompanying wolffd@0: documentation. wolffd@0:
wolffd@0: Although their code does not appear in the current release, the authors wolffd@0: also wish to thank Hutchison Avenue Software Corporation for their wolffd@0: prior contributions. wolffd@0:
wolffd@0: END OF COPYRIGHT STATEMENT wolffd@0:wolffd@0:
wolffd@0: gd is a graphics library. It allows your code to quickly wolffd@0: draw images complete with lines, arcs, text, multiple wolffd@0: colors, cut and paste from other images, and flood fills, and wolffd@0: write out the result as a PNG or JPEG file. This is particularly wolffd@0: useful in World Wide Web applications, where PNG and JPEG are two wolffd@0: of the formats accepted for inline images by most browsers. wolffd@0:
wolffd@0: gd is not a paint program. wolffd@0: If you are looking for a paint program, you are looking in wolffd@0: the wrong place. If you are not a programmer, you are looking wolffd@0: in the wrong place, unless you are installing a required wolffd@0: library in order to run an application. wolffd@0:
wolffd@0: gd does not provide for every possible desirable graphics wolffd@0: operation. It is not necessary or desirable for gd to become wolffd@0: a kitchen-sink graphics package, but version 2.0 does include wolffd@0: most frequently requested features, including both truecolor and wolffd@0: palette images, resampling (smooth resizing of truecolor images) wolffd@0: and so forth. wolffd@0:
wolffd@0: What if I want to use another programming
wolffd@0: language?
wolffd@0: Not all of these tools are necessarily up to date and fully compatible
wolffd@0: with 2.0.33.
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.34?
wolffd@0:
wolffd@0: From 2.0.34 and later, please check the ISSUES and ChangeLog as well as wolffd@0: the releases announcements. wolffd@0:
wolffd@0: What's new in version 2.0.33?
wolffd@0:
wolffd@0: Version 2.0.33 restores compatibility with older releases wolffd@0: of Freetype 2.x in addition to the latest release. Thanks to wolffd@0: John Ellson and the graphviz project. wolffd@0:
wolffd@0: What's new in version 2.0.32?
wolffd@0:
wolffd@0: Version 2.0.32 restores correct detection of Unicode character sets wolffd@0: for freetype fonts, which repairs a bug that prevented umlauts from wolffd@0: displaying properly. Thanks to John Ellson and the graphviz project. wolffd@0: Also, version 2.0.32 builds all test programs wolffd@0: smoothly in the absence of libpng. wolffd@0:
wolffd@0: What's new in version 2.0.31?
wolffd@0:
wolffd@0: A minor type naming conflict prevented bgd.dll from compiling, and it wolffd@0: was left out of the distribution as a result. This has been corrected. wolffd@0:
wolffd@0: What's new in version 2.0.30?
wolffd@0:
wolffd@0: 2.0.29 did not compile correctly when freetype was not available. wolffd@0: This has been corrected. Thanks to Alessandro Ranellucci. wolffd@0:
wolffd@0: What's new in version 2.0.29?
wolffd@0:
wolffd@0:
wolffd@0: The actual resolved font filename can be returned in the gdFTStringExtra wolffd@0: structure as the fontpath element if the gdFTEX_RETURNFONTPATHNAME flag wolffd@0: is set. Also, a wolffd@0: vector of character position advances can be retrieved if gdFTEX_XSHOW is set wolffd@0: in the flags element. .afm files (font metrics) are now used to adjust size wolffd@0: calculations wolffd@0: when available. When fontconfig is not available, gd falls back to its wolffd@0: usual behavior and requires a specific font file name. One can wolffd@0: still fetch fonts by filename when gdFTUseFontConfig(1) is in effect, by wolffd@0: setting the gdFTEX_FONTPATHNAME flag wolffd@0: in the flag element of the gdFTStringExtra structure. Thanks to wolffd@0: Dag Lem and John Ellson. wolffd@0:
wolffd@0: What's new in version 2.0.28?
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.27?
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.26?
wolffd@0:
wolffd@0: The following enhancements and fixes: wolffd@0:
gdlib-config
, which has been installed by
wolffd@0: make install
for some time now, has gained
wolffd@0: a --features
option. This option produces a space-separated
wolffd@0: list of optional features with which the gd library was compiled.
wolffd@0: Typical usage looks like this:
wolffd@0: wolffd@0: % gdlib-config --features wolffd@0: GD_XPM GD_JPEG GD_FREETYPE GD_PNG GD_GIF wolffd@0:wolffd@0: Other
configure
scripts can conveniently define
wolffd@0: preprocessor symbols based on this list in order to conditionally
wolffd@0: compile code. For instance, if
wolffd@0: GD_PNG is not reported by --features, then gdImagePng is not
wolffd@0: included in the library.
wolffd@0: wolffd@0: Thanks to Lars Hecking and Lincoln Stein for their advice on wolffd@0: implementing this feature. Any blame for the actual implementation wolffd@0: is entirely due to me (TBB). wolffd@0:
wolffd@0: What's new in version 2.0.25?
wolffd@0:
wolffd@0: Owing to an oversight while making changes to better accommodate the use wolffd@0: of gd as a DLL, the extern qualifier was dropped from the wolffd@0: declarations of font pointers in 2.0.24. This has been corrected. wolffd@0: Thanks to Richard ("OpenMacNews"). wolffd@0:
wolffd@0: What's new in version 2.0.24?
wolffd@0:
wolffd@0: Windows DLL now uses __stdcall calling convention. Existing wolffd@0: applications will require a recompile, using the new version of gd.h, wolffd@0: in order to use this version of the DLL. However, Visual BASIC and other wolffd@0: non-C programmers will now be able to use the DLL, which is an enormous wolffd@0: benefit and justifies the one-time inconvenience to existing DLL users. wolffd@0:
wolffd@0: The elaborate #ifdef test for older versions of Freetype without wolffd@0: FT_ENCODING_MS_SYMBOL was needed in a second place also. Thanks to wolffd@0: David R. Morrison. wolffd@0:
wolffd@0: An off-by-one error in gdImageToPalette caused transparency to be applied wolffd@0: to the wrong pixels. Thanks to "Super Pikeman." wolffd@0:
wolffd@0: What's new in version 2.0.23?
wolffd@0:
wolffd@0: Output dpi specification option added to the
wolffd@0: gdFTStringExtra
structure, thanks to
wolffd@0: Mark Shackelford. See gdImageStringFTEx.
wolffd@0:
wolffd@0: What's new in version 2.0.22?
wolffd@0:
wolffd@0:
gdFontPtr
.
wolffd@0: Direct use of gdFontLarge
, etc. is strongly deprecated
wolffd@0: for users of bgd.dll
; use these new functions instead.
wolffd@0: circletexttest
if
wolffd@0: PNG support is missing.
wolffd@0:
wolffd@0: What's new in version 2.0.21?
wolffd@0:
wolffd@0:
gdImageCreateFrom*Ptr
family
wolffd@0: of functions which make it convenient to load an image in any
wolffd@0: GD-supported format directly from memory.
wolffd@0: gdNewDynamicCtxEx
function was added to
wolffd@0: support the easy implementation of the above functions and to
wolffd@0: correct a design problem which made life unpleasant for those passing
wolffd@0: in memory not originally allocated by gd to the
wolffd@0: gdNewDynamicCtx
function by provoding a way to specify
wolffd@0: that gd should never free or reallocate a particular block of memory.
wolffd@0: The gdNewDynamicCtx
function and its relatives, although
wolffd@0: still exported for ABI compatibility, are now deprecated except
wolffd@0: for internal use, in favor of gdImageCreateFromPngPtr
wolffd@0: and its relatives.
wolffd@0: gdFreeFontCache
function,
wolffd@0: an undocumented function added in an earlier release which now simply
wolffd@0: calls gdFontCacheShutdown
for backwards compatibility.
wolffd@0: This repairs build problems when compiling PHP against the latest gd.
wolffd@0:
wolffd@0: What's new in version 2.0.20?
wolffd@0:
wolffd@0:
gdFreeFontCache
function,
wolffd@0: an undocumented function added in an earlier release which now simply
wolffd@0: calls gdFontCacheShutdown
for backwards compatibility.
wolffd@0: This repairs build problems when compiling PHP against the latest gd.
wolffd@0:
wolffd@0: What's new in version 2.0.19?
wolffd@0:
wolffd@0:
extern
declarations for the
wolffd@0: gd font pointers inadvertently removed in 2.0.18.
wolffd@0:
wolffd@0: What's new in version 2.0.18?
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.17?
wolffd@0:
wolffd@0: Minor compilation and packaging problems with 2.0.16 were corrected. wolffd@0: If 2.0.16 compiled without errors for you, then you don't need wolffd@0: to upgrade to 2.0.17. wolffd@0:
wolffd@0: What's new in version 2.0.16?
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.15?
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.14?
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.13?
wolffd@0:
wolffd@0:
main()
function of one of the test programs
wolffd@0: was accidentally included in the gd shared library, causing problems
wolffd@0: on some platforms. This has been corrected. Thanks to many people
wolffd@0: who pointed this out.
wolffd@0:
wolffd@0: What's new in version 2.0.12?
wolffd@0:
wolffd@0:
gd2
file format routines
wolffd@0: were fixed by Steven Brown. These problems were due to the
wolffd@0: incorrect use of a signed integer.
wolffd@0: gd
file format correctly
wolffd@0: for truecolor images. Truecolor gd
files created with
wolffd@0: earlier releases in the 2.0 series must be written again. The gd
wolffd@0: file format is used to quickly load an entire uncompressed image, typically
wolffd@0: an existing background to which additional material will be added; it is not a
wolffd@0: general purpose file format. More advanced capabilities are also available
wolffd@0: via the gd2
format. Thanks to Andreas Pfaller for reporting
wolffd@0: the problem.
wolffd@0:
wolffd@0: What's new in version 2.0.11?
wolffd@0:
wolffd@0:
configure
improvements by Lars Hecking.
wolffd@0:
wolffd@0: What's new in version 2.0.10?
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.9?
wolffd@0:
wolffd@0:
configure
fixes from Lars Hecking. Thanks, Lars.
wolffd@0:
wolffd@0: What's new in version 2.0.8?
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 2.0.7?
wolffd@0:
wolffd@0: Version 2.0.7 corrects a problem which caused 'configure' to complain wolffd@0: that the directory NONE was not found, in various places, causing wolffd@0: the configuration process to stop. There are no code changes. wolffd@0:
wolffd@0: What's new in version 2.0.6?
wolffd@0:
wolffd@0:
-Wall
, -ansi
wolffd@0: and -pedantic
options enabled.
wolffd@0:
wolffd@0: What's new in version 2.0.5?
wolffd@0:
configure
time using this syntax:
wolffd@0:
wolffd@0: ./configure --prefix=/usr
wolffd@0:
configure
script should be compatible with all standard
wolffd@0: GNU configure options and will figure out the correct settings for a
wolffd@0: much wider range of operating systems. Many, many thanks to
wolffd@0: Lars Hecking for taking care of this.
wolffd@0:
wolffd@0: What's new in version 2.0.4?
wolffd@0: The following contributions from John Ellson:
wolffd@0:
configure
now correctly detects and provides
wolffd@0: support for the Xpm library and its dependencies (Len Makin)
wolffd@0: configure
script has been extensively modified
wolffd@0: to work properly in tests with both Solaris and Linux. Other platforms
wolffd@0: should also work based on feedback received and integrated to date.
wolffd@0: --prefix
option to configure
wolffd@0: works properly.
wolffd@0: annotate
utility has been added. This is a
wolffd@0: very handy tool for adding freetype text to existing JPEGs. After
wolffd@0: make install
, type annotate -h
for more
wolffd@0: information. Thanks to Joel Dubiner.
wolffd@0:
wolffd@0: What's new in version 2.0.2?
wolffd@0:
What's new in version 2.0.1?
wolffd@0:
readme.jpn
file.
wolffd@0: What's new in version 2.0?
wolffd@0:
pixels
array
wolffd@0: will fail only if it encounters an existing truecolor image, which may
wolffd@0: happen if the code attempts to open and modify an existing JPEG or
wolffd@0: truecolor PNG. Such code should be modified to check the
wolffd@0: trueColor
flag of the gdImage
structure, and
wolffd@0: refer to the tpixels
array instead when it is set.
wolffd@0: What's new in version 1.8.4?
wolffd@0:
What's new in version 1.8.3?
wolffd@0:
#include <gd.h>
corrected to #include "gd.h"
in gd_wbmp.c
wolffd@0:
wolffd@0: What's new in version 1.8.2?
wolffd@0:
What's new in version 1.8.1?
wolffd@0:
What's new in version 1.8?
wolffd@0:
What's new in version 1.7.3?
wolffd@0: Another attempt at Makefile fixes to permit
wolffd@0: linking with all libraries required on platforms with order-
wolffd@0: dependent linkers. Perhaps it will work this time.
wolffd@0:
What's new in version 1.7.2?
wolffd@0: An uninitialized-pointer bug in gdtestttf.c
was corrected.
wolffd@0: This bug caused crashes at the end of each call to gdImageStringTTF on
wolffd@0: some platforms. Thanks to Wolfgang Haefelinger.
wolffd@0:
wolffd@0: Documentation fixes. Thanks to Dohn Arms. wolffd@0:
wolffd@0: Makefile fixes to permit wolffd@0: linking with all libraries required on platforms with order- wolffd@0: dependent linkers. wolffd@0:
What's new in version 1.7.1?
wolffd@0: A minor buglet in the Makefile was corrected, as well as an inaccurate
wolffd@0: error message in gdtestttf.c
. Thanks to Masahito Yamaga.
wolffd@0:
What's new in version 1.7?
wolffd@0: Version 1.7 contains the following changes:
wolffd@0:
autoconf
and configure
have been removed, in favor of a
wolffd@0: carefully designed Makefile which produces and properly installs
wolffd@0: the library and the binaries. System-dependent variables are
wolffd@0: at the top of the Makefile for easy modification. I'm sorry,
wolffd@0: folks, but autoconf generated many, many confused email
wolffd@0: messages from people who didn't have things where autoconf
wolffd@0: expected to find them. I am not an autoconf/automake wizard, and
wolffd@0: gd is a simple, very compact library which does not need to
wolffd@0: be a shared library. I did make many improvements
wolffd@0: over the old gd 1.3 Makefile, which were directly inspired by the
wolffd@0: autoconf version found in the 1.6 series (thanks to John Ellson).
wolffd@0: -pedantic-errors
wolffd@0: flag of gcc. Several pieces of not-quite-ANSI-C code were causing problems
wolffd@0: for those with non-gcc compilers.
wolffd@0: gdttf.c
patched to allow the use of Windows symbol
wolffd@0: fonts, when present (thanks to Joseph Peppin).
wolffd@0: extern "C"
wrappers added to gd.h
and the
wolffd@0: font header files for the convenience of C++ programmers.
wolffd@0: bdftogd
was also modified to automatically insert these
wolffd@0: wrappers into future font header files. Thanks to John Lindal.
wolffd@0: SEEK_SET
.
wolffd@0: Thanks to Robert Bonomi.
wolffd@0: gdImageCreateFromXpm
wolffd@0: function, if the Xpm library is available. Thanks to Caolan McNamara.
wolffd@0: What's new in version 1.6.3?
wolffd@0: Version 1.6.3 corrects a memory leak in gd_png.c. This leak caused
wolffd@0: a significant amount of memory to be allocated and not freed when
wolffd@0: writing a PNG image.
wolffd@0:
wolffd@0: Also in this release the build process has been converted to
wolffd@0: GNU autoconf/automake/libtool conventions so that both (or either)
wolffd@0: static and shared libraries can be built.
wolffd@0:
wolffd@0: Unlike gd 1.6, users should have no trouble linking with
wolffd@0: gd 1.6.1 if they follow the instructions and install all of
wolffd@0: the pieces. However, If you get undefined symbol errors,
wolffd@0: be sure to check for older versions of libpng in your
wolffd@0: library directories!
wolffd@0:
wolffd@0: Support for 8-bit palette PNG images has been added.
wolffd@0: Support for GIF has been removed. This step was taken
wolffd@0: to completely avoid the legal controversy regarding the LZW
wolffd@0: compression algorithm used in GIF. Unisys holds a patent which
wolffd@0: is relevant to LZW compression. PNG is a superior image format
wolffd@0: in any case. Now that PNG is supported by both Microsoft
wolffd@0: Internet Explorer and Netscape (in their recent releases),
wolffd@0: we highly recommend that GD users upgrade in order to get
wolffd@0: well-compressed images in a format which is legally unemcumbered.
wolffd@0:
wolffd@0:
wolffd@0: This format also supports version numbers and rudimentary validity
wolffd@0: checks, so it should be more 'supportable' than the previous GD format.
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: To use gd, you will need an ANSI C compiler. All popular
wolffd@0: Windows 95 and NT C compilers are ANSI C compliant. Any
wolffd@0: full-ANSI-standard C compiler should be adequate. The cc
wolffd@0: compiler released with SunOS 4.1.3 is not an ANSI C compiler.
wolffd@0: Most Unix users who do not already have gcc should get it.
wolffd@0: gcc is free, ANSI compliant and a de facto industry standard.
wolffd@0: Ask your ISP why it is missing.
wolffd@0:
wolffd@0: As of version 1.6, you also need the zlib compression library,
wolffd@0: and the libpng library. As of version 1.6.2, you can draw text
wolffd@0: using antialiased TrueType fonts if you also have the libttf
wolffd@0: library installed, but this is not mandatory.
wolffd@0: zlib is available for a variety of platforms from
wolffd@0: the zlib web site.
wolffd@0: libpng is available for a variety of platforms from
wolffd@0: the PNG web site.
wolffd@0:
wolffd@0:
wolffd@0: You will also want a PNG viewer, if you do not already have
wolffd@0: one for your system, since you will need a good way to check the
wolffd@0: results of your work. Netscape 4.04 and higher, and Microsoft
wolffd@0: Internet Explorer 4.0 or higher, both support PNG.
wolffd@0: Not every PNG-compatible viewer supports alpha channel
wolffd@0: transparency, which is why gd 2.0.2 and above do alpha
wolffd@0: blending in the library by default; it is possible to turn on the
wolffd@0: saving of alpha channel information to the file instead.
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: In order to build gd, you must first unpack the archive you have
wolffd@0: downloaded. If you are not familiar with
wolffd@0: Unpacking the archive will produce a directory called "gd-2.0.33".
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: If all goes well, this will create a Makefile. If all does not go well --
wolffd@0: for instance, if neither the the JPEG nor the PNG and ZLIB libraries
wolffd@0: are found -- you will need to install those libraries, then come back
wolffd@0: and run
wolffd@0: If necessary, make changes to the resulting Makefile. Then,
wolffd@0: type "make". If there are no errors, follow this with "make install".
wolffd@0: Because gd 2.0 and above installs as a shared library, it is necessary to
wolffd@0: install the library properly before running gd-based programs.
wolffd@0:
wolffd@0: If you get errors, type
wolffd@0: Create a project using your favorite programming environment.
wolffd@0: Copy all of the gd files to the project directory. Add
wolffd@0: If you wish to test the library, type "make test" AFTER you have
wolffd@0: successfully executed "make install". This will build
wolffd@0: several test programs, including "gddemo". (Not all of these
wolffd@0: programs are expected to print completely successful messages,
wolffd@0: depending on the nature of the image formats with which some of
wolffd@0: the tests are tried; for instance, WBMP is a black and white
wolffd@0: format, so loss of color information is expected there.)
wolffd@0: Run gddemo to see some of the capabilities of gd. Run
wolffd@0: gdtestft to play with the freetype support, if you have built
wolffd@0: gd with it and have access to truetype fonts.
wolffd@0:
wolffd@0: gddemo should execute without incident, creating the file
wolffd@0: demoout.png. (Note there is also a file named demoin.png,
wolffd@0: which is provided in the package as part of the demonstration.)
wolffd@0:
wolffd@0: Display demoout.png in your PNG viewer. The image should
wolffd@0: be 128x128 pixels and should contain an image of the
wolffd@0: space shuttle with quite a lot of graphical elements drawn
wolffd@0: on top of it.
wolffd@0:
wolffd@0: (If you are missing the demoin.png file, the other items
wolffd@0: should appear anyway.)
wolffd@0:
wolffd@0: Look at demoin.png to see the original space shuttle
wolffd@0: image which was scaled and copied into the output image.
wolffd@0:
wolffd@0:
wolffd@0: If you want to use the provided simple fonts, include
wolffd@0: gdfontt.h, gdfonts.h, gdfontmb.h, gdfontl.h and/or gdfontg.h. For
wolffd@0: more impressive results, install FreeType 2.x and use the
wolffd@0: gdImageStringFT
wolffd@0: function. If you are not using the provided Makefile and/or a
wolffd@0: library-based approach, be sure to include the source modules as well in your
wolffd@0: project. (They may be too large for 16-bit memory models,
wolffd@0: that is, 16-bit DOS and Windows.)
wolffd@0:
wolffd@0: Here is a short example program. (For a more advanced example,
wolffd@0: see gddemo.c, included in the distribution. gddemo.c is NOT the same program;
wolffd@0: it demonstrates additional features!)
wolffd@0:
wolffd@0:
wolffd@0: The above example program should
wolffd@0: give you an idea of how the package works.
wolffd@0: gd provides many additional functions, which are listed
wolffd@0: in the following reference chapters, complete with code
wolffd@0: snippets demonstrating each. There is also an
wolffd@0: alphabetical index.
wolffd@0:
wolffd@0: webpng.c is provided in the distribution. Unix users can
wolffd@0: simply type "make webpng" to compile the program. Type
wolffd@0: "webpng" with no arguments to see the available options.
wolffd@0:
wolffd@0: The
wolffd@0: The order of the structure members may appear confusing, but was chosen
wolffd@0: deliberately to increase backwards compatibility with existing gd 1.x-based
wolffd@0: binary code that references particular structure members.
wolffd@0:
wolffd@0: Truecolor images are always filled with black at creation time.
wolffd@0: There is no concept of a "background" color index.
wolffd@0:
wolffd@0:
wolffd@0: If you already have the
wolffd@0: image file in memory, pass the size of the file and a pointer to the
wolffd@0: file's data to gdImageCreateFromJpegPtr, which is otherwise identical
wolffd@0: to gdImageCreateFromJpeg.
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: If you already have the
wolffd@0: image file in memory, pass the size of the file and a pointer to the
wolffd@0: file's data to gdImageCreateFromPngPtr, which is otherwise identical
wolffd@0: to gdImageCreateFromPng.
wolffd@0:
wolffd@0: If the PNG image being loaded is a truecolor image, the resulting
wolffd@0: gdImagePtr will refer to a truecolor image. If the PNG image
wolffd@0: being loaded is a palette or grayscale image, the resulting
wolffd@0: gdImagePtr will refer to a palette image. gd retains only 8 bits
wolffd@0: of resolution for each of the red, green and blue channels, and
wolffd@0: only 7 bits of resolution for the alpha channel. The former
wolffd@0: restriction affects only a handful of very rare 48-bit color
wolffd@0: and 16-bit grayscale PNG images. The second restriction affects
wolffd@0: all semitransparent PNG images, but the difference is essentially
wolffd@0: invisible to the eye. 7 bits of alpha channel resolution is,
wolffd@0: in practice, quite a lot.
wolffd@0:
wolffd@0: gdImageCreateFromPngSource is called to load a PNG from
wolffd@0: a data source other than a file. Usage is very similar to
wolffd@0: the gdImageCreateFromPng function,
wolffd@0: except that the programmer provides a custom data source.
wolffd@0:
wolffd@0: The programmer must write an input function which accepts
wolffd@0: a context pointer, a buffer, and a number of bytes to be
wolffd@0: read as arguments. This function must read the number of
wolffd@0: bytes requested, unless the end of the file has been reached,
wolffd@0: in which case the function should return zero, or an error
wolffd@0: has occurred, in which case the function should return
wolffd@0:
wolffd@0: The example below
wolffd@0: implements gdImageCreateFromPng
wolffd@0: by creating a custom data source and invoking gdImageCreateFromPngSource.
wolffd@0:
wolffd@0:
wolffd@0: If you already have the
wolffd@0: image file in memory, pass the size of the file and a pointer to the
wolffd@0: file's data to gdImageCreateFromGifPtr, which is otherwise identical
wolffd@0: to gdImageCreateFromGif.
wolffd@0:
wolffd@0:
wolffd@0: If you already have the
wolffd@0: image file in memory, pass the size of the file and a pointer to the
wolffd@0: file's data to gdImageCreateFromGdPtr, which is otherwise identical
wolffd@0: to gdImageCreateFromGd.
wolffd@0:
wolffd@0: gdImageCreateFromGd
wolffd@0: returns a gdImagePtr to the new image, or NULL
wolffd@0: if unable to load the image (most often because the file is corrupt or
wolffd@0: does not contain a gd format image). gdImageCreateFromGd does not
wolffd@0: close the file. You can inspect the sx and sy members of the
wolffd@0: image to determine its size. The image must eventually be destroyed
wolffd@0: using gdImageDestroy().
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: If you already have the
wolffd@0: image file in memory, pass the size of the file and a pointer to the
wolffd@0: file's data to gdImageCreateFromGd2Ptr, which is otherwise identical
wolffd@0: to gdImageCreateFromGd2.
wolffd@0:
wolffd@0: gdImageCreateFromGd2
wolffd@0: returns a gdImagePtr to the new image, or NULL
wolffd@0: if unable to load the image (most often because the file is corrupt or
wolffd@0: does not contain a gd format image). gdImageCreateFromGd2 does not
wolffd@0: close the file. You can inspect the sx and sy members of the
wolffd@0: image to determine its size. The image must eventually be destroyed
wolffd@0: using gdImageDestroy().
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: If you already have the image file in memory, you may use
wolffd@0: gdImageCreateFromGd2PartPtr. Pass the size of the image file,
wolffd@0: in bytes, as the first argument and the pointer to the image file data
wolffd@0: as the second argument.
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: If you already have the
wolffd@0: image file in memory, pass the size of the file and a pointer to the
wolffd@0: file's data to gdImageCreateFromWBMPPtr, which is otherwise identical
wolffd@0: to gdImageCreateFromWBMP.
wolffd@0:
wolffd@0:
wolffd@0: If quality is negative, the default IJG JPEG quality value (which
wolffd@0: should yield a good general quality / size tradeoff for most
wolffd@0: situations) is used. Otherwise, for practical purposes, quality
wolffd@0: should be a value in the range 0-95, higher quality values usually
wolffd@0: implying both higher quality and larger image sizes.
wolffd@0:
wolffd@0: If you have set image interlacing using
wolffd@0: gdImageInterlace, this function will
wolffd@0: interpret that to mean you wish to output a progressive JPEG. Some
wolffd@0: programs (e.g., Web browsers) can display progressive JPEGs
wolffd@0: incrementally; this can be useful when browsing over a relatively slow
wolffd@0: communications link, for example. Progressive JPEGs can also be
wolffd@0: slightly smaller than sequential (non-progressive) JPEGs.
wolffd@0:
wolffd@0: GIF does not support true color; GIF images can contain a maximum
wolffd@0: of 256 colors. If the image to be written is a
wolffd@0: truecolor image, such as those created with
wolffd@0: gdImageCreateTrueColor or loaded
wolffd@0: from a JPEG or a truecolor PNG image file, a palette-based
wolffd@0: temporary image will automatically be created internally using the
wolffd@0: gdImageCreatePaletteFromTrueColor function. The original image pixels are not modified. This conversion
wolffd@0: produces high quality palettes but does require some CPU time. If you are
wolffd@0: regularly converting truecolor to palette in this way, you should consider
wolffd@0: creating your image as a palette-based image in the first place.
wolffd@0:
wolffd@0:
wolffd@0: The GlobalCM flag indicates if a global color map (or palette) is used
wolffd@0: in the GIF89A header. A nonzero value specifies that a global color
wolffd@0: map should be used to reduce the size of the animation.
wolffd@0: Of course, if the color maps of
wolffd@0: individual frames differ greatly, a global color map may not be a good idea.
wolffd@0: GlobalCM=1 means write global color map, GlobalCM=0 means do not, and
wolffd@0: GlobalCM=-1 means to do the default, which currently is to use a global
wolffd@0: color map.
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: If Loops is 0 or greater, the Netscape 2.0 extension for animation
wolffd@0: loop count is written. 0 means infinite loop count. -1 means that
wolffd@0: the extension is not added which results in no looping. -1 is the
wolffd@0: default.
wolffd@0:
wolffd@0:
wolffd@0: Setting the LocalCM flag to 1 adds a local palette for this image to the
wolffd@0: animation. Otherwise the global palette is assumed and the user must make
wolffd@0: sure the palettes match. Use gdImagePaletteCopy to do that.
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: Automatic optimization is activated by giving the previous image as a
wolffd@0: parameter. This function then compares the images and only writes the changed
wolffd@0: pixels to the new frame in animation. The Disposal parameter for
wolffd@0: optimized animations must be set to 1, also for the first frame.
wolffd@0: LeftOfs and TopOfs parameters are ignored for optimized frames. To
wolffd@0: achieve good optimization, it is usually best to use a single global
wolffd@0: color map. To allow gdImageGifAnimAdd to compress unchanged pixels via
wolffd@0: the use of a transparent color, the image must include a transparent color.
wolffd@0:
wolffd@0:
wolffd@0: For more information, see gdImagePng.
wolffd@0:
wolffd@0: For more information, see gdImagePngPtr.
wolffd@0:
wolffd@0: The programmer must write an output function which accepts
wolffd@0: a context pointer, a buffer, and a number of bytes to be
wolffd@0: written as arguments. This function must write the number of
wolffd@0: bytes requested and return that number, unless an error
wolffd@0: has occurred, in which case the function should return
wolffd@0:
wolffd@0: The example below
wolffd@0: implements gdImagePng
wolffd@0: by creating a custom data source and invoking gdImagePngFromSink.
wolffd@0:
wolffd@0: WBMP file support is black and white only. The color index
wolffd@0: specified by the fg argument is the "foreground," and only pixels
wolffd@0: of this color will be set in the WBMP file. All other pixels
wolffd@0: will be considered "background."
wolffd@0:
wolffd@0: The gd image format is intended for fast reads and writes of
wolffd@0: images your program will need frequently to build other
wolffd@0: images. It is not a compressed format, and is not intended
wolffd@0: for general use.
wolffd@0:
wolffd@0: The gd2 image format is intended for fast reads and writes of
wolffd@0: parts of images.
wolffd@0: It is a compressed format, and well suited to retrieving smll sections of
wolffd@0: much larger images.
wolffd@0:
wolffd@0: The third and fourth parameters are the 'chunk size' and format resposectively.
wolffd@0:
wolffd@0: The file is stored as a series of compressed subimages, and the
wolffd@0: Chunk Size determines the sub-image size - a value of
wolffd@0: zero causes the GD library to use the default.
wolffd@0:
wolffd@0: It is also possible to store GD2 files in an uncompressed format, in which case the
wolffd@0: fourth parameter should be GD2_FMT_RAW.
wolffd@0:
wolffd@0:
wolffd@0: The function converts a truecolor image to a palette-based image,
wolffd@0: using a high-quality two-pass quantization routine.
wolffd@0: If ditherFlag is set, the image will be
wolffd@0: dithered to approximate colors better, at the expense
wolffd@0: of some obvious "speckling." colorsWanted can be
wolffd@0: anything up to 256. If the original source image
wolffd@0: includes photographic information or anything that
wolffd@0: came out of a JPEG, 256 is strongly recommended.
wolffd@0: 100% transparency of a single transparent color in the
wolffd@0: original truecolor image will be preserved. There is no other
wolffd@0: support for preservation of alpha channel or transparency in
wolffd@0: the destination image.
wolffd@0:
wolffd@0: For best results, don't use this function -- write real
wolffd@0: truecolor PNGs and JPEGs. The disk space gain of
wolffd@0: conversion to palette is not great (for small images
wolffd@0: it can be negative) and the quality loss is ugly. However,
wolffd@0: the version of this function included in version 2.0.12 and later does
wolffd@0: do a better job than the version included prior to 2.0.12.
wolffd@0:
wolffd@0: gdImageDashedLine is used to draw a dashed line between two endpoints
wolffd@0: (x1,y1 and x2, y2).
wolffd@0: The line is drawn using the color index specified. The portions of the line
wolffd@0: that are not drawn are left transparent so the background is visible.
wolffd@0:
wolffd@0: The border color cannot be a special color
wolffd@0: such as gdTiled; it must be a proper
wolffd@0: solid color. The fill color can be, however.
wolffd@0:
wolffd@0: Note that gdImageFillToBorder is recursive. It is not the most
wolffd@0: naive implementation possible, and the implementation is
wolffd@0: expected to improve, but there will always be degenerate
wolffd@0: cases in which the stack can become very deep. This can be
wolffd@0: a problem in MSDOS and MS Windows 3.1 environments. (Of course,
wolffd@0: in a Unix or Windows 95/98/NT environment with a proper stack, this is
wolffd@0: not a problem at all.)
wolffd@0:
wolffd@0: The fill color can be gdTiled, resulting
wolffd@0: in a tile fill using another image as the tile. However,
wolffd@0: the tile image cannot be transparent. If the image you wish
wolffd@0: to fill with has a transparent color index, call
wolffd@0: gdImageTransparent on the
wolffd@0: tile image and set the transparent color index to -1
wolffd@0: to turn off its transparency.
wolffd@0:
wolffd@0: Note that gdImageFill is recursive. It is not the most
wolffd@0: naive implementation possible, and the implementation is
wolffd@0: expected to improve, but there will always be degenerate
wolffd@0: cases in which the stack can become very deep. This can be
wolffd@0: a problem in MSDOS and MS Windows environments. (Of course,
wolffd@0: in a Unix or Windows 95/98/NT environment with a proper stack, this is
wolffd@0: not a problem at all.)
wolffd@0:
wolffd@0: gdImageSetAntiAliased is used to specify the actual foreground color
wolffd@0: to be used when drawing antialiased lines. You may set any color to
wolffd@0: be the foreground, however as of version 2.0.12 an alpha channel
wolffd@0: component is not supported.
wolffd@0:
wolffd@0: Antialiased lines can be drawn on both truecolor and palette-based
wolffd@0: images. However, attempts to draw antialiased lines on
wolffd@0: highly complex palette-based backgrounds may not give satisfactory
wolffd@0: results, due to the limited number of colors available in the
wolffd@0: palette. Antialiased line-drawing on simple backgrounds should
wolffd@0: work well with palette-based images; otherwise create or fetch
wolffd@0: a truecolor image instead.
wolffd@0:
wolffd@0: You need not take any special action when you are finished
wolffd@0: with antialised line drawing.
wolffd@0:
wolffd@0: gdImageSetBrush is used to specify the brush to be used in a
wolffd@0: particular image. You can set any image to be the brush.
wolffd@0: If the brush image does not have the same color map as the
wolffd@0: first image, any colors missing from the first image
wolffd@0: will be allocated. If not enough colors can be allocated,
wolffd@0: the closest colors already available will be used. This
wolffd@0: allows arbitrary PNGs to be used as brush images. It also
wolffd@0: means, however, that you should not set a brush unless you
wolffd@0: will actually use it; if you set a rapid succession of
wolffd@0: different brush images, you can quickly fill your color map,
wolffd@0: and the results will not be optimal.
wolffd@0:
wolffd@0: You need not take any special action when you are finished
wolffd@0: with a brush. As for any other image, if you will not
wolffd@0: be using the brush image for any further purpose,
wolffd@0: you should call gdImageDestroy.
wolffd@0: You must not use the color gdBrushed
wolffd@0: if the current brush has been destroyed; you can of
wolffd@0: course set a new brush to replace it.
wolffd@0:
wolffd@0: gdImageSetTile is used to specify the tile to be used in a
wolffd@0: particular image. You can set any image to be the tile.
wolffd@0: If the tile image does not have the same color map as the
wolffd@0: first image, any colors missing from the first image
wolffd@0: will be allocated. If not enough colors can be allocated,
wolffd@0: the closest colors already available will be used. This
wolffd@0: allows arbitrary PNGs to be used as tile images. It also
wolffd@0: means, however, that you should not set a tile unless you
wolffd@0: will actually use it; if you set a rapid succession of
wolffd@0: different tile images, you can quickly fill your color map,
wolffd@0: and the results will not be optimal.
wolffd@0:
wolffd@0: You need not take any special action when you are finished
wolffd@0: with a tile. As for any other image, if you will not
wolffd@0: be using the tile image for any further purpose,
wolffd@0: you should call gdImageDestroy.
wolffd@0: You must not use the color gdTiled
wolffd@0: if the current tile has been destroyed; you can of
wolffd@0: course set a new tile to replace it.
wolffd@0:
wolffd@0: To use gdImageSetStyle, create an array of integers and assign
wolffd@0: them the desired series of color values to be repeated.
wolffd@0: You can assign the special color value
wolffd@0: gdTransparent to indicate that the existing color should
wolffd@0: be left unchanged for that particular pixel (allowing a dashed
wolffd@0: line to be attractively drawn over an existing image).
wolffd@0:
wolffd@0: Then, to draw a line using the style, use the normal
wolffd@0: gdImageLine function with the
wolffd@0: special color value gdStyled.
wolffd@0:
wolffd@0: As of version 1.1.1, the style
wolffd@0: array is copied when you set the style, so you need not
wolffd@0: be concerned with keeping the array around indefinitely.
wolffd@0: This should not break existing code that assumes styles
wolffd@0: are not copied.
wolffd@0:
wolffd@0: You can also combine styles and brushes to draw the brush
wolffd@0: image at intervals instead of in a continuous stroke.
wolffd@0: When creating a style for use with a brush, the
wolffd@0: style values are interpreted differently: zero (0) indicates
wolffd@0: pixels at which the brush should not be drawn, while one (1)
wolffd@0: indicates pixels at which the brush should be drawn.
wolffd@0: To draw a styled, brushed line, you must use the
wolffd@0: special color value
wolffd@0: gdStyledBrushed. For an example of this feature
wolffd@0: in use, see gddemo.c (provided in the distribution).
wolffd@0:
wolffd@0: If gdImageSetClip is never called, the clipping area will be the
wolffd@0: entire image.
wolffd@0:
wolffd@0: The parameters passed to gdImageSetClip are checked against the dimensions
wolffd@0: of the image and limited to "safe" values.
wolffd@0:
wolffd@0: See gdImageString for more information
wolffd@0: and examples, or gdImageStringFT for a
wolffd@0: freetype-based alternative that supports truetype fonts.
wolffd@0:
wolffd@0: See gdImageString for more information
wolffd@0: and examples, or gdImageStringFT for a
wolffd@0: freetype-based alternative that supports truetype fonts.
wolffd@0:
wolffd@0: See gdImageString for more information
wolffd@0: and examples, or gdImageStringFT for a
wolffd@0: freetype-based alternative that supports truetype fonts.
wolffd@0:
wolffd@0: See gdImageString for more information
wolffd@0: and examples, or gdImageStringFT for a
wolffd@0: freetype-based alternative that supports truetype fonts.
wolffd@0:
wolffd@0: See gdImageString for more information
wolffd@0: and examples, or gdImageStringFT for a
wolffd@0: freetype-based alternative that supports truetype fonts.
wolffd@0:
wolffd@0: You must include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
wolffd@0: "gdfontl.h" and "gdfontg.h" respectively
wolffd@0: and (if you are not using a library-based approach) link with the
wolffd@0: corresponding .c files to use the provided fonts.
wolffd@0:
wolffd@0:
wolffd@0: The character specified by the fifth
wolffd@0: argument is drawn from left to right in the specified
wolffd@0: color. (See gdImageCharUp for a way
wolffd@0: of drawing vertical text.) Pixels not
wolffd@0: set by a particular character retain their previous color.
wolffd@0:
wolffd@0:
wolffd@0: The character specified by
wolffd@0: the fifth argument is drawn
wolffd@0: from bottom to top, rotated at a 90-degree angle, in the specified
wolffd@0: color. (See gdImageChar for a way
wolffd@0: of drawing horizontal text.) Pixels not
wolffd@0: set by a particular character retain their previous color.
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: This function was added in gd1.3 to provide a means of rendering
wolffd@0: fonts with more than 256 characters for those who have them. A
wolffd@0: more frequently used routine is gdImageString.
wolffd@0:
wolffd@0: This function was added in gd1.3 to provide a means of rendering
wolffd@0: fonts with more than 256 characters for those who have them. A
wolffd@0: more frequently used routine is gdImageStringUp.
wolffd@0:
wolffd@0: gdImageStringFT draws a string of anti-aliased characters on the image using
wolffd@0: the FreeType
wolffd@0: library to render user-supplied TrueType fonts. We do not provide
wolffd@0: TrueType fonts (.ttf and .ttc files). Obtaining them is entirely up to
wolffd@0: you. The string is anti-aliased, meaning that there should be
wolffd@0: fewer "jaggies" visible. The fontname is the full pathname to a TrueType
wolffd@0: font file, or a font face name if the GDFONTPATH environment variable
wolffd@0: 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).
wolffd@0:
wolffd@0: The null-terminated string argument is considered to be encoded via the UTF_8
wolffd@0: standard; also, HTML entities are supported, including decimal,
wolffd@0: hexadecimal, and named entities (2.0.26). Those who are passing
wolffd@0: ordinary ASCII strings may have difficulty with the &
wolffd@0: character unless encoded correctly as & but should have no
wolffd@0: other difficulties.
wolffd@0:
wolffd@0: The string may be arbitrarily scaled (ptsize) and rotated (angle in radians).
wolffd@0: The direction of rotation is counter-clockwise, with 0 radians (0 degrees)
wolffd@0: at 3 o'clock and PI/2 radians (90 degrees) at 12 o'clock.
wolffd@0:
wolffd@0:
wolffd@0: The user-supplied int brect[8] array is filled on return from gdImageStringFT
wolffd@0: with the 8 elements representing the 4 corner coordinates of the
wolffd@0: bounding rectangle (the smallest rectangle that completely surrounds the
wolffd@0: rendered string and does not intersect any pixel of the rendered string).
wolffd@0:
wolffd@0:
wolffd@0: The points are relative to the text regardless of the angle, so "upper left"
wolffd@0: means in the top left-hand corner seeing the text horizontally.
wolffd@0:
wolffd@0: Use a NULL gdImagePtr to get the bounding rectangle without rendering.
wolffd@0: This is a relatively cheap operation if followed by a rendering of the same
wolffd@0: string, because of the caching of the partial rendering during bounding
wolffd@0: rectangle calculation.
wolffd@0:
wolffd@0: The string is rendered in the color indicated by the gf color index.
wolffd@0: Use the negative of the desired color index to
wolffd@0: disable anti-aliasing.
wolffd@0:
wolffd@0: The string may contain UTF-8 sequences like: "À"
wolffd@0:
wolffd@0: gdImageStringFT will return a null char* on success, or an error
wolffd@0: string on failure.
wolffd@0:
wolffd@0: If the
wolffd@0: If
wolffd@0: To specify a preference for Unicode, Shift_JIS Big5 character encoding,
wolffd@0: set or To output multiline text with a specific line spacing,
wolffd@0: include
wolffd@0: GD operates on the assumption that the output image will be
wolffd@0: rendered to a computer screen. By default, gd passes a
wolffd@0: resolution of 96 dpi to the freetype text rendering engine.
wolffd@0: This influences the "hinting" decisions made by the renderer. To
wolffd@0: specify a different resolution, set hdpi and vdpi accordingly
wolffd@0: (in dots per inch) and add
wolffd@0: GD 2.0.29 and later can also return the path to the actual font file
wolffd@0: used if the gdFTEX_RETURNFONTPATHNAME flag is set. This is useful because
wolffd@0: GD 2.0.29 and above are capable of
wolffd@0: selecting a font automatically based on a fontconfig font pattern
wolffd@0: when fontconfig is available. This information is returned in the
wolffd@0: fontpath element of the gdFTStringExtra structure.
wolffd@0:
wolffd@0: GD 2.0.29 and later can use fontconfig to resolve
wolffd@0: font names, including fontconfig patterns, if the gdFTEX_FONTCONFIG
wolffd@0: flag is set. As a convenience, this behavior can be made the default
wolffd@0: by calling gdFTUseFontConfig with
wolffd@0: a nonzero value. In that situation it is not necessary to set the
wolffd@0: gdFTEX_FONTCONFIG flag on every call; however explicit font path names
wolffd@0: can still be used if the gdFTEX_FONTPATHNAME flag is set:
wolffd@0:
wolffd@0: Unless gdFTUseFontConfig has been
wolffd@0: called with a nonzero value, GD 2.0.29 and later will still expect
wolffd@0: the fontlist argument to the freetype text output functions to be
wolffd@0: a font file name or list thereof as in previous versions. If you do
wolffd@0: not wish to make fontconfig the default, it is
wolffd@0: still possible to force the use of fontconfig for a single call to
wolffd@0: the freetype text output functions by setting the gdFTEX_FONTCONFIG
wolffd@0: flag:
wolffd@0:
wolffd@0: Returns 0 on success, or an error string otherwise.
wolffd@0:
wolffd@0: For more information, see gdImageStringFTEx
wolffd@0: and gdImageSquareToCircle.
wolffd@0:
wolffd@0: In the event that all gdMaxColors colors
wolffd@0: (256) have already been allocated, gdImageColorAllocate will
wolffd@0: return -1 to indicate failure. (This is not uncommon when
wolffd@0: working with existing PNG files that already use 256 colors.)
wolffd@0: Note that gdImageColorAllocate
wolffd@0: does not check for existing colors that match your request;
wolffd@0: see gdImageColorExact,
wolffd@0: gdImageColorClosest and
wolffd@0: gdImageColorClosestHWB
wolffd@0: for ways to locate existing colors that approximate the
wolffd@0: color desired in situations where a new color is not available.
wolffd@0: Also see gdImageColorResolve,
wolffd@0: new in gd-1.6.2.
wolffd@0:
wolffd@0: In the event that all gdMaxColors colors
wolffd@0: (256) have already been allocated, gdImageColorAllocate will
wolffd@0: return -1 to indicate failure. (This is not uncommon when
wolffd@0: working with existing palette-based PNG files that already use 256 colors.)
wolffd@0: Note that gdImageColorAllocateAlpha
wolffd@0: does not check for existing colors that match your request;
wolffd@0: see gdImageColorExactAlpha and
wolffd@0: gdImageColorClosestAlpha
wolffd@0: for ways to locate existing colors that approximate the
wolffd@0: color desired in situations where a new color is not available.
wolffd@0: Also see gdImageColorResolveAlpha.
wolffd@0:
wolffd@0: If no colors have yet been allocated in the image,
wolffd@0: gdImageColorClosest returns -1.
wolffd@0:
wolffd@0: When applied to a truecolor image, this function always
wolffd@0: succeeds in returning the desired color.
wolffd@0:
wolffd@0: This function is most useful as a backup method for choosing
wolffd@0: a drawing color when an image already contains
wolffd@0: gdMaxColors (256) colors and
wolffd@0: no more can be allocated. (This is not uncommon when
wolffd@0: working with existing PNG files that already use many colors.)
wolffd@0: See gdImageColorExact
wolffd@0: for a method of locating exact matches only.
wolffd@0:
wolffd@0: If no colors have yet been allocated in the image,
wolffd@0: gdImageColorClosestAlpha returns -1.
wolffd@0:
wolffd@0: When applied to a truecolor image, this function always
wolffd@0: succeeds in returning the desired color.
wolffd@0:
wolffd@0: This function is most useful as a backup method for choosing
wolffd@0: a drawing color when a palette-based image already contains
wolffd@0: gdMaxColors (256) colors and
wolffd@0: no more can be allocated. (This is not uncommon when
wolffd@0: working with existing palette-based PNG files that already use many colors.)
wolffd@0: See gdImageColorExactAlpha
wolffd@0: for a method of locating exact matches only.
wolffd@0:
wolffd@0: If no colors have yet been allocated in the image,
wolffd@0: gdImageColorClosestHWB returns -1.
wolffd@0:
wolffd@0: When applied to a truecolor image, this function always
wolffd@0: succeeds in returning the desired color.
wolffd@0:
wolffd@0: This function is most useful as a backup method for choosing
wolffd@0: a drawing color when an image already contains
wolffd@0: gdMaxColors (256) colors and
wolffd@0: no more can be allocated. (This is not uncommon when
wolffd@0: working with existing PNG files that already use many colors.)
wolffd@0: See gdImageColorExact
wolffd@0: for a method of locating exact matches only.
wolffd@0:
wolffd@0: When applied to a truecolor image, this function always
wolffd@0: succeeds in returning the desired color.
wolffd@0:
wolffd@0: When applied to a truecolor image, this function always
wolffd@0: succeeds in returning the desired color.
wolffd@0:
wolffd@0: When applied to a truecolor image, this function always
wolffd@0: succeeds in returning the desired color.
wolffd@0:
wolffd@0: The color index used should be an index
wolffd@0: allocated by gdImageColorAllocate,
wolffd@0: whether explicitly invoked by your code or implicitly
wolffd@0: invoked by loading an image.
wolffd@0: In order to ensure that your image has a reasonable appearance
wolffd@0: when viewed by users who do not have transparent background
wolffd@0: capabilities (or when you are writing a JPEG-format file, which does
wolffd@0: not support transparency), be sure to give reasonable RGB values to the
wolffd@0: color you allocate for use as a transparent color,
wolffd@0: even though it will be transparent on systems
wolffd@0: that support PNG transparency.
wolffd@0:
wolffd@0: The
wolffd@0: When you copy a region from one location in an image to another
wolffd@0: location in the same image, gdImageCopy will perform as expected
wolffd@0: unless the regions overlap, in which case the result is
wolffd@0: unpredictable.
wolffd@0:
wolffd@0: Important note on copying between images: since
wolffd@0: different images do
wolffd@0: not necessarily have the same color tables, pixels are not simply set to the
wolffd@0: same color index values to copy them. gdImageCopy will attempt
wolffd@0: to find an identical RGB value in the destination image for
wolffd@0: each pixel in the copied portion of the source image by
wolffd@0: invoking gdImageColorExact. If
wolffd@0: such a value is not found, gdImageCopy will attempt to
wolffd@0: allocate colors as needed using
wolffd@0: gdImageColorAllocate. If both of these methods fail,
wolffd@0: gdImageCopy will invoke
wolffd@0: gdImageColorClosest to find the color in the destination
wolffd@0: image which most closely approximates the color of the
wolffd@0: pixel being copied.
wolffd@0:
wolffd@0: The
wolffd@0: When you copy a region from one location in an image to another
wolffd@0: location in the same image, gdImageCopy will perform as expected
wolffd@0: unless the regions overlap, in which case the result is
wolffd@0: unpredictable. If this presents a problem, create a scratch image
wolffd@0: in which to keep intermediate results.
wolffd@0:
wolffd@0: Important note on copying between images: since images
wolffd@0: do not necessarily have the same color tables, pixels are not simply set
wolffd@0: to the same color index values to copy them. gdImageCopy will attempt
wolffd@0: to find an identical RGB value in the destination image for
wolffd@0: each pixel in the copied portion of the source image by
wolffd@0: invoking gdImageColorExact. If
wolffd@0: such a value is not found, gdImageCopy will attempt to
wolffd@0: allocate colors as needed using
wolffd@0: gdImageColorAllocate. If both of these methods fail,
wolffd@0: gdImageCopy will invoke
wolffd@0: gdImageColorClosest to find the color in the destination
wolffd@0: image which most closely approximates the color of the
wolffd@0: pixel being copied.
wolffd@0:
wolffd@0: Pixel values are only interpolated if the destination image is a
wolffd@0: truecolor image. Otherwise,
wolffd@0: gdImageCopyResized is
wolffd@0: automatically invoked.
wolffd@0:
wolffd@0: The
wolffd@0: When you copy a region from one location in an image to another
wolffd@0: location in the same image, gdImageCopy will perform as expected
wolffd@0: unless the regions overlap, in which case the result is
wolffd@0: unpredictable. If this presents a problem, create a scratch image
wolffd@0: in which to keep intermediate results.
wolffd@0:
wolffd@0: Important note on copying between images: since images
wolffd@0: do not necessarily have the same color tables, pixels are not simply set
wolffd@0: to the same color index values to copy them. If the destination image
wolffd@0: is a palette image, gd will use the
wolffd@0: gdImageColorResolve function to
wolffd@0: determine the best color available.
wolffd@0:
wolffd@0: When you copy a region from one location in an image to another
wolffd@0: location in the same image, gdImageCopyRotated will perform as expected
wolffd@0: unless the regions overlap, in which case the result is
wolffd@0: unpredictable. If this presents a problem, create a scratch image
wolffd@0: in which to keep intermediate results.
wolffd@0:
wolffd@0: Important note on copying between images: since
wolffd@0: palette-based images do not necessarily have the same color tables, pixels
wolffd@0: are not simply set to the same color index values to copy them.
wolffd@0: If the destination image is not a truecolor image,
wolffd@0: gdImageColorResolveAlpha is
wolffd@0: used to choose the destination pixel.
wolffd@0:
wolffd@0: If, however, the pct parameter is less than 100, then the two images are merged.
wolffd@0: With pct = 0, no action is taken.
wolffd@0: This feature is most useful to 'highlight' sections of an image by merging a solid color with
wolffd@0: pct = 50:
wolffd@0:
wolffd@0: A nonzero value for the interlace argument turns on interlace;
wolffd@0: a zero value turns it off. Note that interlace has no effect
wolffd@0: on other functions, and has no meaning unless you save the
wolffd@0: image in PNG or JPEG format; the gd and xbm formats do not support
wolffd@0: interlace.
wolffd@0:
wolffd@0: When a PNG is loaded with
wolffd@0: gdImageCreateFromPng or a JPEG is
wolffd@0: loaded with
wolffd@0: gdImageCreateFromJpeg, interlace
wolffd@0: will be set according to the setting in the PNG or JPEG file.
wolffd@0:
wolffd@0: Note that many PNG and JPEG viewers and web browsers do not
wolffd@0: support interlace or the incremental display of progressive
wolffd@0: JPEGs. However, the interlaced PNG or progressive JPEG should still
wolffd@0: display; it will simply appear all at once, just as other images do.
wolffd@0:
wolffd@0: The program "pngtogd.c" is provided as a simple way of converting
wolffd@0: .png files to .gd format. I emphasize again that you will not
wolffd@0: need to use this format unless you have a need for high-speed loading
wolffd@0: of a few frequently-used images in your program.
wolffd@0:
wolffd@0:
wolffd@0: The program "pngtogd2.c" is provided as a simple way of converting
wolffd@0: .png files to .gd2 format.
wolffd@0:
wolffd@0:
wolffd@0: The
wolffd@0: It is not necessary to implement all functions in an I/O context if you know
wolffd@0: that it will only be used in limited cirsumstances. At the time of writing
wolffd@0: (Version 1.6.1, July 1999), the known requirements are:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: www.libgd.org
wolffd@0:
wolffd@0:
What's new in version 1.6.2?
wolffd@0: Version 1.6.2 from John Ellson
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: if ((color=gdImageColorExact(im,R,G,B)) < 0)
wolffd@0: if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
wolffd@0: color=gdImageColorClosest(im,R,G,B);
wolffd@0:
wolffd@0: What's new in version 1.6.1?
wolffd@0: Version 1.6.1 incorporates superior PNG reading and writing code
wolffd@0: from Greg Roelofs, with minor modifications by Tom Boutell.
wolffd@0: Specifically, I altered his code to read non-palette images
wolffd@0: (converting them to palette images badly, by dithering them),
wolffd@0: and to tolerate palette images with types of transparency that
wolffd@0: gd doesn't actually support (it just ignores the advanced
wolffd@0: transparency features). Any bugs in this area are therefore my
wolffd@0: fault, not Greg's.
wolffd@0: What's new in version 1.6?
wolffd@0: Version 1.6 features the following changes:
wolffd@0: What's new in version 1.5?
wolffd@0:
wolffd@0: Version 1.5 featured the following changes:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: NOTE: In fairness to Thomas Boutell, any bug/problems with any of the above features should
wolffd@0: probably be reported to Philip Warner.
wolffd@0:
wolffd@0:
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.
wolffd@0:
gdImageGd2, gdImageCreateFromGd2 - Support for new format
wolffd@0:
gdImageCopyMerge - Merges two images (useful to highlight part of an image)
wolffd@0:
gdImageCopyMergeGray - Similar to gdImageCopyMerge, but tries to preserve source image hue.
wolffd@0:
gdImagePngPtr, gdImageJpegPtr, gdImageWBMPPtr, gdImageGdPtr, gdImageGd2Ptr - return memory blocks for each type of image.
wolffd@0:
gdImageCreateFromPngCtx, gdImageCreateFromGdCtx, gdImageCreateFromGd2Ctx, gdImageCreateFromGd2PartCtx - Support for new I/O context.
wolffd@0:
wolffd@0: What's new in version 1.4?
wolffd@0:
wolffd@0: Version 1.4 features the following changes:
wolffd@0:
wolffd@0:
wolffd@0: What's new in version 1.3?
wolffd@0: Version 1.3 features the following changes:
wolffd@0:
wolffd@0:
wolffd@0: pixels
array will require
wolffd@0: changes.
wolffd@0: What else do I need to use gd?
wolffd@0: How do I get gd?
wolffd@0: Binaries (DLL for Windows programmers):
wolffd@0:
wolffd@0:
wolffd@0: Source Code:
wolffd@0:
wolffd@0:
wolffd@0: How do I build gd?
wolffd@0:
wolffd@0: Win32 DLL users: if you are using MSVC, use the provided batch file
wolffd@0:
wolffd@0: Building gd From the Source
wolffd@0: makemsvcimport.bat
to make a bgd.lib import library
wolffd@0: corresponding to the provided bgd.dll. Copy bgd.dll to your
wolffd@0: application directory, or to your Windows sytem directory. In the
wolffd@0: settings of your MSVC project, you MUST choose the
wolffd@0: "multithreaded DLL" library option under "code generation."
wolffd@0: mingw32 and cygwin users can simply link with the provided libbgd.a
wolffd@0: stub library in order to use the DLL.
wolffd@0: tar
and
wolffd@0: gunzip
(Unix) or ZIP
(Windows), please
wolffd@0: consult with an experienced user of your system. Sorry, we cannot
wolffd@0: answer questions about basic Internet skills.
wolffd@0: For Unix
wolffd@0: cd
to the 2.0.33 directory and type:
wolffd@0: ./configure
wolffd@0:
wolffd@0: NOTE: BY DEFAULT, THE LIBRARY IS INSTALLED IN
wolffd@0:
wolffd@0: /usr/local/lib
and the include files are
wolffd@0: installed in /usr/local/include
. IF YOU ARE
wolffd@0: UPGRADING, you may wish to use:
wolffd@0:
wolffd@0: ./configure --prefix=/usr
wolffd@0:
wolffd@0: Rather than just ./configure
, before typing
wolffd@0: make
and make install
.
wolffd@0: configure
again.
wolffd@0: ./configure --help
for more
wolffd@0: information about the available options. In the unlikely event
wolffd@0: that the GNU autoconf-produced configure script does not work well
wolffd@0: for you, you may wish to try configure.pl
, a
wolffd@0: simple Perl script with similar but less complete capabilities.
wolffd@0: If all else fails, try renaming makefile.sample
wolffd@0: to Makefile
. However, ./configure
is
wolffd@0: almost always your best bet.
wolffd@0:
wolffd@0:
wolffd@0: For Windows
wolffd@0: Use the DLL version! See the paragraph at the beginning of this sectino.
wolffd@0: If you really want to compile it yourself for some strange reason, read on.
wolffd@0: gd.c
wolffd@0: to your project. Add other source files as appropriate. Learning the
wolffd@0: basic skills of creating projects with your chosen C environment
wolffd@0: is up to you. Alternatively, use the free mingw32
wolffd@0: or cygwin
tools, which may prove to be compatible
wolffd@0: with the provided configure
script.
wolffd@0: gd basics: using gd in your program
wolffd@0: gd lets you create PNG or JPEG images on the fly. To use gd in your
wolffd@0: program, include the file gd.h, and link with the gd
wolffd@0: library and the other required libraries; the syntax for
wolffd@0: most Unix flavors is:
wolffd@0:
wolffd@0: -lgd -lpng -lz -ljpeg -lfreetype -lm
wolffd@0:
wolffd@0: Assuming that all of these libraries are available.
wolffd@0:
wolffd@0: /* Bring in gd library functions */
wolffd@0: #include "gd.h"
wolffd@0:
wolffd@0: /* Bring in standard I/O so we can output the PNG to a file */
wolffd@0: #include <stdio.h>
wolffd@0:
wolffd@0: int main() {
wolffd@0: /* Declare the image */
wolffd@0: gdImagePtr im;
wolffd@0: /* Declare output files */
wolffd@0: FILE *pngout, *jpegout;
wolffd@0: /* Declare color indexes */
wolffd@0: int black;
wolffd@0: int white;
wolffd@0:
wolffd@0: /* Allocate the image: 64 pixels across by 64 pixels tall */
wolffd@0: im = gdImageCreate(64, 64);
wolffd@0:
wolffd@0: /* Allocate the color black (red, green and blue all minimum).
wolffd@0: Since this is the first color in a new image, it will
wolffd@0: be the background color. */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0:
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0:
wolffd@0: /* Draw a line from the upper left to the lower right,
wolffd@0: using white color index. */
wolffd@0: gdImageLine(im, 0, 0, 63, 63, white);
wolffd@0:
wolffd@0: /* Open a file for writing. "wb" means "write binary", important
wolffd@0: under MSDOS, harmless under Unix. */
wolffd@0: pngout = fopen("test.png", "wb");
wolffd@0:
wolffd@0: /* Do the same for a JPEG-format file. */
wolffd@0: jpegout = fopen("test.jpg", "wb");
wolffd@0:
wolffd@0: /* Output the image to the disk file in PNG format. */
wolffd@0: gdImagePng(im, pngout);
wolffd@0:
wolffd@0: /* Output the same image in JPEG format, using the default
wolffd@0: JPEG quality setting. */
wolffd@0: gdImageJpeg(im, jpegout, -1);
wolffd@0:
wolffd@0: /* Close the files. */
wolffd@0: fclose(pngout);
wolffd@0: fclose(jpegout);
wolffd@0:
wolffd@0: /* Destroy the image in memory. */
wolffd@0: gdImageDestroy(im);
wolffd@0: }
wolffd@0:
wolffd@0: When executed, this program creates an image, allocates
wolffd@0: two colors (the first color allocated becomes the background
wolffd@0: color), draws a diagonal line (note that 0, 0 is the upper
wolffd@0: left corner), writes the image to PNG and JPEG files, and
wolffd@0: destroys the image.
wolffd@0: Webpng: a more powerful gd example
wolffd@0: Webpng is a simple utility program to manipulate PNGs from the
wolffd@0: command line. It is written for Unix and similar command-line
wolffd@0: systems, but should be easily adapted for other environments.
wolffd@0: Webpng allows you to set transparency and interlacing and
wolffd@0: output interesting information about the PNG in question.
wolffd@0: Function and type reference
wolffd@0:
wolffd@0:
wolffd@0: Types
wolffd@0:
wolffd@0:
wolffd@0: gdImage
(TYPE)
wolffd@0: pixels
wolffd@0: or tpixels
arrays. If the trueColor
flag
wolffd@0: is set, the tpixels
array is valid; otherwise the
wolffd@0: pixels
array is valid.
wolffd@0: colorsTotal
, red
, green
,
wolffd@0: blue
, alpha
and open
arrays
wolffd@0: manage the palette. They are valid only when the trueColor
wolffd@0: flag is not set.
wolffd@0: The transparent
value contains the palette index of the first
wolffd@0: transparent color as read-only information for backwards compatibility;
wolffd@0: gd 2.0 stores this information in the alpha
array so that
wolffd@0: variable transparency can be supported for each palette entry. However,
wolffd@0: for truecolor images, transparent
represents a single
wolffd@0: RGB color which is always 100% transparent, and this
wolffd@0: feature is generally supported by browsers which do not support
wolffd@0: full alpha channels.
wolffd@0:
wolffd@0: typedef struct {
wolffd@0: /* Palette-based image pixels */
wolffd@0: unsigned char ** pixels;
wolffd@0: int sx;
wolffd@0: int sy;
wolffd@0: /* These are valid in palette images only. See also
wolffd@0: /* 'alpha', which appears later in the structure to
wolffd@0: preserve binary backwards compatibility */
wolffd@0: int colorsTotal;
wolffd@0: int red[gdMaxColors];
wolffd@0: int green[gdMaxColors];
wolffd@0: int blue[gdMaxColors];
wolffd@0: int open[gdMaxColors];
wolffd@0: /* For backwards compatibility, this is set to the
wolffd@0: first palette entry with 100% transparency,
wolffd@0: and is also set and reset by the
wolffd@0: gdImageColorTransparent function. Newer
wolffd@0: applications can allocate palette entries
wolffd@0: with any desired level of transparency; however,
wolffd@0: bear in mind that many viewers, notably
wolffd@0: many web browsers, fail to implement
wolffd@0: full alpha channel for PNG and provide
wolffd@0: support for full opacity or transparency only. */
wolffd@0: int transparent;
wolffd@0: int *polyInts;
wolffd@0: int polyAllocated;
wolffd@0: struct gdImageStruct *brush;
wolffd@0: struct gdImageStruct *tile;
wolffd@0: int brushColorMap[gdMaxColors];
wolffd@0: int tileColorMap[gdMaxColors];
wolffd@0: int styleLength;
wolffd@0: int stylePos;
wolffd@0: int *style;
wolffd@0: int interlace;
wolffd@0: /* New in 2.0: alpha channel for palettes. Note that only
wolffd@0: Macintosh Internet Explorer and (possibly) Netscape 6
wolffd@0: really support multiple levels of transparency in
wolffd@0: palettes, to my knowledge, as of 2/15/01. Most
wolffd@0: common browsers will display 100% opaque and
wolffd@0: 100% transparent correctly, and do something
wolffd@0: unpredictable and/or undesirable for levels
wolffd@0: in between. TBB */
wolffd@0: int alpha[gdMaxColors];
wolffd@0: /* Truecolor flag and pixels. New 2.0 fields appear here at the
wolffd@0: end to minimize breakage of existing object code. */
wolffd@0: int trueColor;
wolffd@0: int ** tpixels;
wolffd@0: /* Should alpha channel be copied, or applied, each time a
wolffd@0: pixel is drawn? This applies to truecolor images only.
wolffd@0: No attempt is made to alpha-blend in palette images,
wolffd@0: even if semitransparent palette entries exist.
wolffd@0: To do that, build your image as a truecolor image,
wolffd@0: then quantize down to 8 bits. */
wolffd@0: int alphaBlendingFlag;
wolffd@0: /* Should the alpha channel of the image be saved? This affects
wolffd@0: PNG at the moment; other future formats may also
wolffd@0: have that capability. JPEG doesn't. */
wolffd@0: int saveAlphaFlag;
wolffd@0: } gdImage;
wolffd@0:
wolffd@0: gd2
file format, which supports quick loading of
wolffd@0: partial images. The gd_free function will not be invoked when
wolffd@0: calling the standard Ctx functions; it is an implementation
wolffd@0: convenience when adding new data types to gd. For examples,
wolffd@0: see gd_png.c, gd_gd2.c, gd_jpeg.c, etc., all of which rely
wolffd@0: on gdIOCtx to implement the standard image read and write functions.
wolffd@0:
wolffd@0:
wolffd@0: typedef struct gdIOCtx
wolffd@0: {
wolffd@0: int (*getC) (struct gdIOCtx *);
wolffd@0: int (*getBuf) (struct gdIOCtx *, void *, int wanted);
wolffd@0:
wolffd@0: void (*putC) (struct gdIOCtx *, int);
wolffd@0: int (*putBuf) (struct gdIOCtx *, const void *, int wanted);
wolffd@0:
wolffd@0: /* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
wolffd@0: int (*seek) (struct gdIOCtx *, const int);
wolffd@0:
wolffd@0: long (*tell) (struct gdIOCtx *);
wolffd@0:
wolffd@0: void (*gd_free) (struct gdIOCtx *);
wolffd@0:
wolffd@0: } gdIOCtx;
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: typedef struct {
wolffd@0: /* # of characters in font */
wolffd@0: int nchars;
wolffd@0: /* First character is numbered... (usually 32 = space) */
wolffd@0: int offset;
wolffd@0: /* Character width and height */
wolffd@0: int w;
wolffd@0: int h;
wolffd@0: /* Font data; array of characters, one row after another.
wolffd@0: Easily included in code, also easily loaded from
wolffd@0: data files. */
wolffd@0: char *data;
wolffd@0: } gdFont;
wolffd@0:
wolffd@0:
wolffd@0: typedef struct {
wolffd@0: int x, y;
wolffd@0: } gdPoint, *gdPointPtr;
wolffd@0:
wolffd@0:
wolffd@0: typedef struct {
wolffd@0: int (*source) (void *context, char *buffer, int len);
wolffd@0: void *context;
wolffd@0: } gdSource, *gdSourcePtr;
wolffd@0:
wolffd@0: Represents a source from which a PNG can be read.
wolffd@0: Programmers who do not wish to read PNGs from a file can provide
wolffd@0: their own alternate input mechanism, using the
wolffd@0: gdImageCreateFromPngSource function.
wolffd@0: See the documentation of that function for an example of the
wolffd@0: proper use of this type.
wolffd@0:
wolffd@0: typedef struct {
wolffd@0: int (*sink) (void *context, char *buffer, int len);
wolffd@0: void *context;
wolffd@0: } gdSink, *gdSinkPtr;
wolffd@0:
wolffd@0: Represents a "sink" (destination) to which a PNG can be written.
wolffd@0: Programmers who do not wish to write PNGs to a file can provide
wolffd@0: their own alternate output mechanism, using the
wolffd@0: gdImagePngToSink function.
wolffd@0: See the documentation of that function for an example of the
wolffd@0: proper use of this type.
wolffd@0: Image creation, destruction, loading and saving
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: im = gdImageCreate(64, 64);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: im = gdImageCreateTrueColor(64, 64);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: gdImageCreateFromJpegPtr(int size, void *data)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: gdImageCreateFromJpegCtx(gdIOCtx *in)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: gdImagePtr im;
wolffd@0: ... inside a function ...
wolffd@0: FILE *in;
wolffd@0: in = fopen("myjpeg.jpg", "rb");
wolffd@0: im = gdImageCreateFromJpeg(in);
wolffd@0: fclose(in);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
gdImageCreateFromPngPtr(int size, void *data)
wolffd@0: (FUNCTION)
wolffd@0:
gdImageCreateFromPngCtx(gdIOCtx *in)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: gdImagePtr im;
wolffd@0: ... inside a function ...
wolffd@0: FILE *in;
wolffd@0: in = fopen("mypng.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: -1
. The programmer then creates a
wolffd@0: gdSource structure and sets
wolffd@0: the source
pointer to the input function and
wolffd@0: the context pointer to any value which is useful to the
wolffd@0: programmer.
wolffd@0:
wolffd@0: static int freadWrapper(void *context, char *buf, int len);
wolffd@0:
wolffd@0: gdImagePtr gdImageCreateFromPng(FILE *in)
wolffd@0: {
wolffd@0: gdSource s;
wolffd@0: s.source = freadWrapper;
wolffd@0: s.context = in;
wolffd@0: return gdImageCreateFromPngSource(&s);
wolffd@0: }
wolffd@0:
wolffd@0: static int freadWrapper(void *context, char *buf, int len)
wolffd@0: {
wolffd@0: int got = fread(buf, 1, len, (FILE *) context);
wolffd@0: return got;
wolffd@0: }
wolffd@0:
wolffd@0:
gdImageCreateFromGifPtr(int size, void *data)
wolffd@0: (FUNCTION)
wolffd@0:
gdImageCreateFromGifCtx(gdIOCtx *in)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: gdImagePtr im;
wolffd@0: ... inside a function ...
wolffd@0: FILE *in;
wolffd@0: in = fopen("mygif.gif", "rb");
wolffd@0: im = gdImageCreateFromGif(in);
wolffd@0: fclose(in);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
gdImageCreateFromGdCtx(gdIOCtx *in)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: FILE *in;
wolffd@0: in = fopen("mygd.gd", "rb");
wolffd@0: im = gdImageCreateFromGd(in);
wolffd@0: fclose(in);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0:
gdImageCreateFromGd2Ptr(int size, void *data)
wolffd@0: (FUNCTION)
wolffd@0:
gdImageCreateFromGd2Ctx(gdIOCtx *in)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: FILE *in;
wolffd@0: in = fopen("mygd.gd2", "rb");
wolffd@0: im = gdImageCreateFromGd2(in);
wolffd@0: fclose(in);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0:
gdImageCreateFromGd2PartPtr(int size, void *data, int srcX, int srcY, int w, int h)
wolffd@0: (FUNCTION)
wolffd@0:
gdImageCreateFromGd2PartCtx(gdIOCtx *in)
wolffd@0: (FUNCTION)
wolffd@0:
gdImageCreateFromWBMPPtr(int size, void *data)
wolffd@0: (FUNCTION)
wolffd@0:
gdImageCreateFromWBMPCtx(gdIOCtx *in)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: gdImagePtr im;
wolffd@0: ... inside a function ...
wolffd@0: FILE *in;
wolffd@0: in = fopen("mywbmp.wbmp", "rb");
wolffd@0: im = gdImageCreateFromWBMP(in);
wolffd@0: fclose(in);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: FILE *in;
wolffd@0: in = fopen("myxbm.xbm", "rb");
wolffd@0: im = gdImageCreateFromXbm(in);
wolffd@0: fclose(in);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: FILE *in;
wolffd@0: in = fopen("myxpm.xpm", "rb");
wolffd@0: im = gdImageCreateFromXpm(in);
wolffd@0: fclose(in);
wolffd@0: /* ... Use the image ... */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: im = gdImageCreate(10, 10);
wolffd@0: /* ... Use the image ... */
wolffd@0: /* Now destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black, white;
wolffd@0: FILE *out;
wolffd@0: /* Create the image */
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Allocate background */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate drawing color */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Draw rectangle */
wolffd@0: gdImageRectangle(im, 0, 0, 99, 99, black);
wolffd@0: /* Open output file in binary mode */
wolffd@0: out = fopen("rect.jpg", "wb");
wolffd@0: /* Write JPEG using default quality */
wolffd@0: gdImageJpeg(im, out, -1);
wolffd@0: /* Close file */
wolffd@0: fclose(out);
wolffd@0: /* Destroy image */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: void gdImageGifCtx(gdImagePtr im, gdIOCtx *out)
wolffd@0:
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black, white;
wolffd@0: FILE *out;
wolffd@0: /* Create the image */
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Allocate background */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate drawing color */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Draw rectangle */
wolffd@0: gdImageRectangle(im, 0, 0, 99, 99, black);
wolffd@0: /* Open output file in binary mode */
wolffd@0: out = fopen("rect.gif", "wb");
wolffd@0: /* Write GIF */
wolffd@0: gdImageGif(im, out);
wolffd@0: /* Close file */
wolffd@0: fclose(out);
wolffd@0: /* Destroy image */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: void gdImageGifAnimBeginCtx(gdImagePtr im, gdIOCtx *out, int GlobalCM, int Loops)
wolffd@0:
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: void gdImageGifAnimAddCtx(gdImagePtr im, gdIOCtx *out, int LocalCM, int LeftOfs, int TopOfs, int Delay, int Disposal, gdImagePtr previm)
wolffd@0:
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: gdDisposalNone
, meaning that the pixels changed by this
wolffd@0: frame should remain on the display when the next frame begins to render, but
wolffd@0: can also be gdDisposalUnknown
(not recommended),
wolffd@0: gdDisposalRestoreBackground
(restores the first
wolffd@0: allocated color of the global palette), or
wolffd@0: gdDisposalRestorePrevious
(restores the appearance of the
wolffd@0: affected area before the frame was rendered). Only
wolffd@0: gdDisposalNone
is a sensible choice for the first frame.
wolffd@0: If previm
is
wolffd@0: passed, the built-in GIF optimizer will always use gdDisposalNone
wolffd@0: regardless of the Disposal parameter.
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im, im2, im3;
wolffd@0: int black, white, trans;
wolffd@0: FILE *out;
wolffd@0: /* Create the image */
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Allocate background */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate drawing color */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate transparent color for animation compression */
wolffd@0: trans = gdImageColorAllocate(im, 1, 1, 1);
wolffd@0: /* Draw rectangle */
wolffd@0: gdImageRectangle(im, 0, 0, 10, 10, black);
wolffd@0: /* Open output file in binary mode */
wolffd@0: out = fopen("anim.gif", "wb");
wolffd@0: /* Write GIF header. Use global color map. Loop a few times */
wolffd@0: gdImageGifAnimBegin(im, out, 1, 3);
wolffd@0: /* Write the first frame. No local color map. Delay = 1s */
wolffd@0: gdImageGifAnimAdd(im, out, 0, 0, 0, 100, 1, NULL);
wolffd@0: /* construct the second frame */
wolffd@0: im2 = gdImageCreate(100, 100);
wolffd@0: /* Allocate background to make it white */
wolffd@0: (void)gdImageColorAllocate(im2, 255, 255, 255);
wolffd@0: /* Make sure the palette is identical */
wolffd@0: gdImagePaletteCopy (im2, im);
wolffd@0: /* Draw something */
wolffd@0: gdImageRectangle(im2, 0, 0, 15, 15, black);
wolffd@0: /* Allow animation compression with transparent pixels */
wolffd@0: gdImageColorTransparent (im2, trans);
wolffd@0: /* Add the second frame */
wolffd@0: gdImageGifAnimAdd(im2, out, 0, 0, 0, 100, 1, im);
wolffd@0: /* construct the second frame */
wolffd@0: im3 = gdImageCreate(100, 100);
wolffd@0: /* Allocate background to make it white */
wolffd@0: (void)gdImageColorAllocate(im3, 255, 255, 255);
wolffd@0: /* Make sure the palette is identical */
wolffd@0: gdImagePaletteCopy (im3, im);
wolffd@0: /* Draw something */
wolffd@0: gdImageRectangle(im3, 0, 0, 15, 20, black);
wolffd@0: /* Allow animation compression with transparent pixels */
wolffd@0: gdImageColorTransparent (im3, trans);
wolffd@0: /* Add the third frame, compressing against the second one */
wolffd@0: gdImageGifAnimAdd(im3, out, 0, 0, 0, 100, 1, im2);
wolffd@0: /* Write the end marker */
wolffd@0: /* gdImageGifAnimEnd(out); is the same as the following: */
wolffd@0: putc (';', out);
wolffd@0: /* Close file */
wolffd@0: fclose(out);
wolffd@0: /* Destroy images */
wolffd@0: gdImageDestroy(im);
wolffd@0: gdImageDestroy(im2);
wolffd@0: gdImageDestroy(im3);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: void gdImageGifAnimEndCtx(gdIOCtx *out)
wolffd@0:
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: void gdImagePngCtx(gdImagePtr im, gdIOCtx *out)
wolffd@0:
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black, white;
wolffd@0: FILE *out;
wolffd@0: /* Create the image */
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Allocate background */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate drawing color */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Draw rectangle */
wolffd@0: gdImageRectangle(im, 0, 0, 99, 99, black);
wolffd@0: /* Open output file in binary mode */
wolffd@0: out = fopen("rect.png", "wb");
wolffd@0: /* Write PNG */
wolffd@0: gdImagePng(im, out);
wolffd@0: /* Close file */
wolffd@0: fclose(out);
wolffd@0: /* Destroy image */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: void gdImagePngCtxEx(gdImagePtr im, gdIOCtx *out, int level)
wolffd@0:
wolffd@0: (FUNCTION)
wolffd@0: -1
. The programmer then creates a
wolffd@0: gdSink structure and sets
wolffd@0: the sink
pointer to the output function and
wolffd@0: the context pointer to any value which is useful to the
wolffd@0: programmer.
wolffd@0:
wolffd@0: static int stdioSink(void *context, char *buffer, int len)
wolffd@0: {
wolffd@0: return fwrite(buffer, 1, len, (FILE *) context);
wolffd@0: }
wolffd@0:
wolffd@0: void gdImagePng(gdImagePtr im, FILE *out)
wolffd@0: {
wolffd@0: gdSink mySink;
wolffd@0: mySink.context = (void *) out;
wolffd@0: mySink.sink = stdioSink;
wolffd@0: gdImagePngToSink(im, &mySink);
wolffd@0: }
wolffd@0:
wolffd@0:
gdImageWBMPCtx(gdIOCtx *out)
wolffd@0: (FUNCTION)(FUNCTION)
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black, white;
wolffd@0: FILE *out;
wolffd@0: /* Create the image */
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Allocate background */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate drawing color */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Draw rectangle */
wolffd@0: gdImageRectangle(im, 0, 0, 99, 99, black);
wolffd@0: /* Open output file in binary mode */
wolffd@0: out = fopen("rect.wbmp", "wb");
wolffd@0: /* Write WBMP, with black as foreground */
wolffd@0: gdImageWBMP(im, black, out);
wolffd@0: /* Close file */
wolffd@0: fclose(out);
wolffd@0: /* Destroy image */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black, white;
wolffd@0: FILE *out;
wolffd@0: /* Create the image */
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Allocate background */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate drawing color */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Draw rectangle */
wolffd@0: gdImageRectangle(im, 0, 0, 99, 99, black);
wolffd@0: /* Open output file in binary mode */
wolffd@0: out = fopen("rect.gd", "wb");
wolffd@0: /* Write gd format file */
wolffd@0: gdImageGd(im, out);
wolffd@0: /* Close file */
wolffd@0: fclose(out);
wolffd@0: /* Destroy image */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: void gdImageGd2Ctx(gdImagePtr im, gdIOCtx *out, int chunkSize, int fmt)
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black, white;
wolffd@0: FILE *out;
wolffd@0: /* Create the image */
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Allocate background */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate drawing color */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Draw rectangle */
wolffd@0: gdImageRectangle(im, 0, 0, 99, 99, black);
wolffd@0: /* Open output file in binary mode */
wolffd@0: out = fopen("rect.gd", "wb");
wolffd@0: /* Write gd2 format file */
wolffd@0: gdImageGd2(im, out, 0, GD2_FMT_COMPRESSED);
wolffd@0: /* Close file */
wolffd@0: fclose(out);
wolffd@0: /* Destroy image */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: gdImagePtr gdImageCreatePaletteFromTrueColor(gdImagePtr im, int ditherFlag, int colorsWanted)
wolffd@0:
wolffd@0: (FUNCTION)
wolffd@0:
wolffd@0: gdImageCreatePaletteFromTrueColor returns a new
wolffd@0: image. gdImageTrueColorToPalette permanently converts the
wolffd@0: existing image. The two functions are otherwise identical.
wolffd@0:
wolffd@0: Drawing Functions
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Set a pixel near the center. */
wolffd@0: gdImageSetPixel(im, 50, 50, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green
wolffd@0: and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a line from the upper left corner to the
wolffd@0: lower right corner. */
wolffd@0: gdImageLine(im, 0, 0, 99, 99, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue
wolffd@0: all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a dashed line from the upper left corner
wolffd@0: to the lower right corner. */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: /* Points of polygon */
wolffd@0: gdPoint points[3];
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and
wolffd@0: blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a triangle. */
wolffd@0: points[0].x = 50;
wolffd@0: points[0].y = 0;
wolffd@0: points[1].x = 99;
wolffd@0: points[1].y = 99;
wolffd@0: points[2].x = 0;
wolffd@0: points[2].y = 99;
wolffd@0: gdImagePolygon(im, points, 3, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a rectangle occupying the central area. */
wolffd@0: gdImageRectangle(im, 25, 25, 74, 74, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: int red;
wolffd@0: /* Points of polygon */
wolffd@0: gdPoint points[3];
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate the color red. */
wolffd@0: red = gdImageColorAllocate(im, 255, 0, 0);
wolffd@0: /* Draw a triangle. */
wolffd@0: points[0].x = 50;
wolffd@0: points[0].y = 0;
wolffd@0: points[1].x = 99;
wolffd@0: points[1].y = 99;
wolffd@0: points[2].x = 0;
wolffd@0: points[2].y = 99;
wolffd@0: /* Paint it in white */
wolffd@0: gdImageFilledPolygon(im, points, 3, white);
wolffd@0: /* Outline it in red; must be done second */
wolffd@0: gdImagePolygon(im, points, 3, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = int gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a filled rectangle occupying the central area. */
wolffd@0: gdImageFilledRectangle(im, 25, 25, 74, 74, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: s
and ends at
wolffd@0: the position specified by e
. The arc is drawn in
wolffd@0: the color specified by the last argument. A circle can be drawn
wolffd@0: by beginning from 0 degrees and ending at 360 degrees, with
wolffd@0: width and height being equal. e must be greater than s. Values greater
wolffd@0: than 360 are interpreted modulo 360.
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 50);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Inscribe an ellipse in the image. */
wolffd@0: gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: s
and ends at
wolffd@0: the position specified by e
. The arc is filled in
wolffd@0: the color specified by the second to last argument. A circle can be drawn
wolffd@0: by beginning from 0 degrees and ending at 360 degrees, with
wolffd@0: width and height being equal. e must be greater than s. Values greater
wolffd@0: than 360 are interpreted modulo 360. The last argument is a bitwise
wolffd@0: OR of the following possibilities:
wolffd@0:
wolffd@0:
wolffd@0: gdArc and gdChord are mutually exclusive;
wolffd@0: gdChord just connects the starting and ending
wolffd@0: angles with a straight line, while gdArc produces
wolffd@0: a rounded edge. gdPie is a synonym for gdArc.
wolffd@0: gdNoFill indicates that the arc or chord should be
wolffd@0: outlined, not filled. gdEdged, used together with
wolffd@0: gdNoFill, indicates that the beginning and ending
wolffd@0: angles should be connected to the center; this is
wolffd@0: a good way to outline (rather than fill) a
wolffd@0: 'pie slice'.
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 50);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Inscribe a filled pie slice in the image. */
wolffd@0: gdImageFilledArc(im, 50, 25, 98, 48, 0, 45, white, gdArc);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 50);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Inscribe a filled ellipse in the image. */
wolffd@0: gdImageFilledEllipse(im, 50, 25, 98, 48, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: color
, beginning at the specified point and stopping at
wolffd@0: the specified border
color. For a way of flooding an
wolffd@0: area defined by the color of the starting point, see
wolffd@0: gdImageFill.
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: int red;
wolffd@0: im = gdImageCreate(100, 50);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate the color red. */
wolffd@0: red = gdImageColorAllocate(im, 255, 0, 0);
wolffd@0: /* Inscribe an ellipse in the image. */
wolffd@0: gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
wolffd@0: /* Flood-fill the ellipse. Fill color is red, border color is
wolffd@0: white (ellipse). */
wolffd@0: gdImageFillToBorder(im, 50, 50, white, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: color
, beginning at the specified point and flooding the
wolffd@0: surrounding region of the same color as the starting point.
wolffd@0: For a way of flooding a region defined by a specific border
wolffd@0: color rather than by its interior color, see
wolffd@0: gdImageFillToBorder.
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: int red;
wolffd@0: im = gdImageCreate(100, 50);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Allocate the color red. */
wolffd@0: red = gdImageColorAllocate(im, 255, 0, 0);
wolffd@0: /* Inscribe an ellipse in the image. */
wolffd@0: gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
wolffd@0: /* Flood-fill the ellipse. Fill color is red, and will replace the
wolffd@0: black interior of the ellipse. */
wolffd@0: gdImageFill(im, 50, 50, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im, brush;
wolffd@0: int black;
wolffd@0: int blue;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: blue = gdImageColorAllocate(im, 0, 0, 255);
wolffd@0: gdImageSetAntiAliased(im, blue);
wolffd@0: /* Draw a smooth line from the upper left corner to the
wolffd@0: lower right corner. */
wolffd@0: gdImageLine(im, 0, 0, 99, 99, gdAntiAliased);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: See also gdAntiAliased and
wolffd@0: gdSetAntiAliasedDontBlend.
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im, brush;
wolffd@0: int black;
wolffd@0: int blue;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: blue = gdImageColorAllocate(im, 0, 0, 255);
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0:
wolffd@0: gdImageSetAntiAliased(im, blue);
wolffd@0: /* The portion of the line that crosses this white rectangle will
wolffd@0: not be blended smoothly */
wolffd@0: gdImageSetAntiAliasedDontBlend(im, white);
wolffd@0: gdImageFilledRectangle(im, 25, 25, 75, 75, white);
wolffd@0: /* Draw a smooth line from the upper left corner
wolffd@0: to the lower right corner. */
wolffd@0: gdImageLine(im, 0, 0, 99, 99, gdAntiAliased);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: See also gdAntiAliased and
wolffd@0: gdSetAntiAliased.
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im, brush;
wolffd@0: FILE *in;
wolffd@0: int black;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Open the brush PNG. For best results, portions of the
wolffd@0: brush that should be transparent (ie, not part of the
wolffd@0: brush shape) should have the transparent color index. */
wolffd@0: in = fopen("star.png", "rb");
wolffd@0: brush = gdImageCreateFromPng(in);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: gdImageSetBrush(im, brush);
wolffd@0: /* Draw a line from the upper left corner to the lower right corner
wolffd@0: using the brush. */
wolffd@0: gdImageLine(im, 0, 0, 99, 99, gdBrushed);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0: /* Destroy the brush image */
wolffd@0: gdImageDestroy(brush);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im, tile;
wolffd@0: FILE *in;
wolffd@0: int black;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Open the tile PNG. For best results, portions of the
wolffd@0: tile that should be transparent (ie, allowing the
wolffd@0: background to shine through) should have the transparent
wolffd@0: color index. */
wolffd@0: in = fopen("star.png", "rb");
wolffd@0: tile = gdImageCreateFromPng(in);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: gdImageSetTile(im, tile);
wolffd@0: /* Fill an area using the tile. */
wolffd@0: gdImageFilledRectangle(im, 25, 25, 75, 75, gdTiled);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0: /* Destroy the tile image */
wolffd@0: gdImageDestroy(tile);
wolffd@0:
wolffd@0:
wolffd@0: gdImagePtr im;
wolffd@0: int styleDotted[2], styleDashed[6];
wolffd@0: FILE *in;
wolffd@0: int black;
wolffd@0: int red;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: red = gdImageColorAllocate(im, 255, 0, 0);
wolffd@0: /* Set up dotted style. Leave every other pixel alone. */
wolffd@0: styleDotted[0] = red;
wolffd@0: styleDotted[1] = gdTransparent;
wolffd@0: /* Set up dashed style. Three on, three off. */
wolffd@0: styleDashed[0] = red;
wolffd@0: styleDashed[1] = red;
wolffd@0: styleDashed[2] = red;
wolffd@0: styleDashed[3] = gdTransparent;
wolffd@0: styleDashed[4] = gdTransparent;
wolffd@0: styleDashed[5] = gdTransparent;
wolffd@0: /* Set dotted style. Note that we have to specify how many pixels are
wolffd@0: in the style! */
wolffd@0: gdImageSetStyle(im, styleDotted, 2);
wolffd@0: /* Draw a line from the upper left corner to the lower right corner. */
wolffd@0: gdImageLine(im, 0, 0, 99, 99, gdStyled);
wolffd@0: /* Now the dashed line. */
wolffd@0: gdImageSetStyle(im, styleDashed, 6);
wolffd@0: gdImageLine(im, 0, 99, 0, 99, gdStyled);
wolffd@0:
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file ... */
wolffd@0:
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Set thickness. */
wolffd@0: gdImageSetThickness(im, 4);
wolffd@0: /* Draw a fat line from the upper left corner to the lower right corner. */
wolffd@0: gdImageLine(im, 0, 0, 99, 99, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: gdImagePtr im;
wolffd@0: int red, blue;
wolffd@0: im = gdImageCreateTrueColor(100, 100);
wolffd@0: /* Background color */
wolffd@0: red = gdTrueColor(255, 0, 0);
wolffd@0: gdImageFilledRectangle(im, 0, 0, 100, 100, red);
wolffd@0: /* Drawing color. Full transparency would be an alpha channel value
wolffd@0: of 127 (gd has a 7 bit alpha chnanel). 0 is opaque,
wolffd@0: 127 is transparent. So cut gdAlphaTransparent in half to get
wolffd@0: 50% blending. */
wolffd@0: blue = gdTrueColorAlpha(0, 0, 255, gdAlphaTransparent / 2);
wolffd@0: /* Draw with blending. Result will be 50% red, 50% blue: yellow
wolffd@0: (emitted light, remember, not reflected light. What you learned
wolffd@0: in Kindergarten is wrong here). */
wolffd@0: gdImageAlphaBlending(im, 1);
wolffd@0: gdImageFilledRectangle(im, 0, 0, 25, 25, blue);
wolffd@0: /* Draw without blending. Result will be 50% blue, 50%
wolffd@0: the background color of the image viewer or web browser
wolffd@0: used; results in browsers that don't support
wolffd@0: semi-transparent pixels are unpredictable! */
wolffd@0: gdImageAlphaBlending(im, 0);
wolffd@0: gdImageFilledRectangle(im, 75, 75, 25, 25, blue);
wolffd@0: /* Write the image to disk, etc. */
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Set the clipping rectangle. */
wolffd@0: gdImageSetClip(im, 25, 25, 75, 75);
wolffd@0: /* Draw a line from the upper left corner to the lower right corner.
wolffd@0: Only the part within the clipping rectangle will appear. */
wolffd@0: gdImageLine(im, 0, 0, 99, 99, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file ... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: See also gdImageGetClip.
wolffd@0:
wolffd@0: ... Inside a function ...
wolffd@0: gdImagePtr im = gdImageCreateTrueColor(100, 100);
wolffd@0: int x1, y1, x2, y2;
wolffd@0: gdImageSetClip(im, 25, 25, 75, 75);
wolffd@0: gdImageGetClip(im, &x1, &y1, &x2, &y2);
wolffd@0: printf("%d %d %d %d\n", x1, y1, x2, y2);
wolffd@0:
wolffd@0: The above code would print:
wolffd@0:
wolffd@0: 25 25 75 75
wolffd@0:
wolffd@0: See also gdImageSetClip.
wolffd@0: Query Functions
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: FILE *in;
wolffd@0: gdImagePtr im;
wolffd@0: int c;
wolffd@0: in = fopen("mypng.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: c = gdImageGetPixel(im, gdImageSX(im) / 2, gdImageSY(im) / 2);
wolffd@0: printf("The value of the center pixel is %d; RGB values are %d,%d,%d\n",
wolffd@0: c, im->red[c], im->green[c], im->blue[c]);
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: if (gdImageBoundsSafe(im, 50, 50)) {
wolffd@0: printf("50, 50 is within the image bounds\n");
wolffd@0: } else {
wolffd@0: printf("50, 50 is outside the image bounds\n");
wolffd@0: }
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: Fonts and text-handling functions
wolffd@0:
wolffd@0:
wolffd@0: gdfonts.h
before
wolffd@0: calling this function. Under Windows, due to the nature of DLLs,
wolffd@0: the use of this function is strongly recommended rather than attempting
wolffd@0: to use the gdFontSmall
pointer directly. (You may
wolffd@0: safely assign the result to a local gdFontPtr
variable
wolffd@0: in your own code.)
wolffd@0: gdfontl.h
before
wolffd@0: calling this function. Under Windows, due to the nature of DLLs,
wolffd@0: the use of this function is strongly recommended rather than attempting
wolffd@0: to use the gdFontLarge
pointer directly. (You may
wolffd@0: safely assign the result to a local gdFontPtr
variable
wolffd@0: in your own code.)
wolffd@0: gdfontmb.h
before
wolffd@0: calling this function. Under Windows, due to the nature of DLLs,
wolffd@0: the use of this function is strongly recommended rather than attempting
wolffd@0: to use the gdFontMediumBold
pointer directly. (You may
wolffd@0: safely assign the result to a local gdFontPtr
variable
wolffd@0: in your own code.)
wolffd@0: gdfontg.h
before
wolffd@0: calling this function. Under Windows, due to the nature of DLLs,
wolffd@0: the use of this function is strongly recommended rather than attempting
wolffd@0: to use the gdFontGiant
pointer directly. (You may
wolffd@0: safely assign the result to a local gdFontPtr
variable
wolffd@0: in your own code.)
wolffd@0: gdfontt.h
before
wolffd@0: calling this function. Under Windows, due to the nature of DLLs,
wolffd@0: the use of this function is strongly recommended rather than attempting
wolffd@0: to use the gdFontTiny
pointer directly. (You may
wolffd@0: safely assign the result to a local gdFontPtr
variable
wolffd@0: in your own code.)
wolffd@0:
wolffd@0: Windows DLL users: although you can use
wolffd@0: these DLL-exported pointers directly, you cannot easily assign them to other
wolffd@0: pointers. This will cause hard-to-debug problems. To avoid such troubles, you
wolffd@0: should call the functions gdFontGetTiny(), gdFontGetSmall(),
wolffd@0: gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
wolffd@0: obtain pointers to the fonts under Windows.
wolffd@0:
wolffd@0:
wolffd@0: #include "gd.h"
wolffd@0: #include "gdfontl.h"
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a character. */
wolffd@0: gdImageChar(im, gdFontGetLarge(), 0, 0, 'Q', white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: Windows DLL users: although you can use
wolffd@0: these DLL-exported pointers directly, you cannot easily assign them to other
wolffd@0: pointers. This will cause hard-to-debug problems. To avoid such troubles, you
wolffd@0: should call the functions gdFontGetTiny(), gdFontGetSmall(),
wolffd@0: gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
wolffd@0: obtain pointers to the fonts under Windows.
wolffd@0:
wolffd@0:
wolffd@0: #include "gd.h"
wolffd@0: #include "gdfontl.h"
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a character upwards so it rests against the top of the image. */
wolffd@0: gdImageCharUp(im, gdFontGetLarge(),
wolffd@0: 0, gdFontGetLarge()->h, 'Q', white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: Windows DLL users: although you can use
wolffd@0: these DLL-exported pointers directly, you cannot easily assign them to other
wolffd@0: pointers. This will cause hard-to-debug problems. To avoid such troubles, you
wolffd@0: should call the functions gdFontGetTiny(), gdFontGetSmall(),
wolffd@0: gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
wolffd@0: obtain pointers to the fonts under Windows.
wolffd@0:
wolffd@0: The null-terminated C string specified
wolffd@0: by the fifth argument is drawn from left to right in the specified
wolffd@0: color. (See gdImageStringUp for a way
wolffd@0: of drawing vertical text.
wolffd@0: See also gdImageStringFT for a high
wolffd@0: quality solution.)
wolffd@0: Pixels not set by a particular character retain their previous color.
wolffd@0:
wolffd@0: #include "gd.h"
wolffd@0: #include "gdfontl.h"
wolffd@0: #include <string.h>
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: /* String to draw. */
wolffd@0: char *s = "Hello.";
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a centered string. */
wolffd@0: gdImageString(im, gdFontGetLarge(),
wolffd@0: im->sx / 2 - (strlen(s) * gdFontGetLarge()->w / 2),
wolffd@0: im->sy / 2 - gdFontGetLarge()->h / 2,
wolffd@0: s, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: Windows DLL users: although you can use
wolffd@0: these DLL-exported pointers directly, you cannot easily assign them to other
wolffd@0: pointers. This will cause hard-to-debug problems. To avoid such troubles, you
wolffd@0: should call the functions gdFontGetTiny(), gdFontGetSmall(),
wolffd@0: gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
wolffd@0: obtain pointers to the fonts under Windows.
wolffd@0:
wolffd@0: The null-terminated string of characters represented as 16-bit unsigned
wolffd@0: short integers specified by the fifth argument is drawn from left to right
wolffd@0: in the specified
wolffd@0: color. (See gdImageStringUp16 for a way
wolffd@0: of drawing vertical text.) Pixels not
wolffd@0: set by a particular character retain their previous color.
wolffd@0:
wolffd@0: Windows DLL users: although you can use
wolffd@0: these DLL-exported pointers directly, you cannot easily assign them to other
wolffd@0: pointers. This will cause hard-to-debug problems. To avoid such troubles, you
wolffd@0: should call the functions gdFontGetTiny(), gdFontGetSmall(),
wolffd@0: gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
wolffd@0: obtain pointers to the fonts under Windows.
wolffd@0:
wolffd@0:
wolffd@0: The null-terminated C string specified
wolffd@0: by the fifth argument is drawn from bottom to top (rotated
wolffd@0: 90 degrees) in the specified color. (See
wolffd@0: gdImageString for a way
wolffd@0: of drawing horizontal text.) Pixels not
wolffd@0: set by a particular character retain their previous color.
wolffd@0:
wolffd@0: #include "gd.h"
wolffd@0: #include "gdfontl.h"
wolffd@0: #include <string.h>
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: /* String to draw. */
wolffd@0: char *s = "Hello.";
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color white (red, green and blue all maximum). */
wolffd@0: white = gdImageColorAllocate(im, 255, 255, 255);
wolffd@0: /* Draw a centered string going upwards. Axes are reversed,
wolffd@0: and Y axis is decreasing as the string is drawn. */
wolffd@0: gdImageStringUp(im, gdFontGetLarge(),
wolffd@0: im->w / 2 - gdFontGetLarge()->h / 2,
wolffd@0: im->h / 2 + (strlen(s) * gdFontGetLarge()->w / 2),
wolffd@0: s, white);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: Windows DLL users: although you can use
wolffd@0: these DLL-exported pointers directly, you cannot easily assign them to other
wolffd@0: pointers. This will cause hard-to-debug problems. To avoid such troubles, you
wolffd@0: should call the functions gdFontGetTiny(), gdFontGetSmall(),
wolffd@0: gdFontGetMediumBold(), gdFontGetLarge(), and gdFontGetGiant() in order to
wolffd@0: obtain pointers to the fonts under Windows.
wolffd@0:
wolffd@0: The null-terminated string of characters represented as 16-bit unsigned
wolffd@0: short integers specified by the fifth argument is drawn from bottom to top
wolffd@0: in the specified color.
wolffd@0: (See gdImageStringUp16 for a way
wolffd@0: of drawing horizontal text.) Pixels not
wolffd@0: set by a particular character retain their previous color.
wolffd@0:
wolffd@0: #include "gd.h"
wolffd@0: #include <string.h>
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: int brect[8];
wolffd@0: int x, y;
wolffd@0: char *err;
wolffd@0:
wolffd@0: char *s = "Hello."; /* String to draw. */
wolffd@0: double sz = 40.;
wolffd@0: char *fc = "times:bold:italic"; /* fontconfig pattern */
wolffd@0:
wolffd@0: /* Signal that all freetype font calls in this program will receive
wolffd@0: fontconfig patterns rather than filenames of font files */
wolffd@0: gdUseFontConfig(1);
wolffd@0:
wolffd@0: /* obtain brect so that we can size the image */
wolffd@0: err = gdImageStringFT(NULL,&brect[0],0,fc,sz,0.,0,0,s);
wolffd@0: if (err) {fprintf(stderr,err); return 1;}
wolffd@0:
wolffd@0: /* create an image big enough for the string plus a little whitespace */
wolffd@0: x = brect[2]-brect[6] + 6;
wolffd@0: y = brect[3]-brect[7] + 6;
wolffd@0: im = gdImageCreate(x,y);
wolffd@0:
wolffd@0: /* Background color (first allocated) */
wolffd@0: white = gdImageColorResolve(im, 255, 255, 255);
wolffd@0: black = gdImageColorResolve(im, 0, 0, 0);
wolffd@0:
wolffd@0: /* render the string, offset origin to center string*/
wolffd@0: /* note that we use top-left coordinate for adjustment
wolffd@0: * since gd origin is in top-left with y increasing downwards. */
wolffd@0: x = 3 - brect[6];
wolffd@0: y = 3 - brect[7];
wolffd@0: err = gdImageStringFT(im,&brect[0],black,fc,sz,0.0,x,y,s);
wolffd@0: if (err) {fprintf(stderr,err); return 1;}
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: 0
wolffd@0: lower left corner, X position
wolffd@0: 1
wolffd@0: lower left corner, Y position
wolffd@0: 2
wolffd@0: lower right corner, X position
wolffd@0: 3
wolffd@0: lower right corner, Y position
wolffd@0: 4
wolffd@0: upper right corner, X position
wolffd@0: 5
wolffd@0: upper right corner, Y position
wolffd@0: 6
wolffd@0: upper left corner, X position
wolffd@0: 7
wolffd@0: upper left corner, Y position
wolffd@0: #include "gd.h"
wolffd@0: #include <string.h>
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int white;
wolffd@0: int brect[8];
wolffd@0: int x, y;
wolffd@0: char *err;
wolffd@0:
wolffd@0: char *s = "Hello."; /* String to draw. */
wolffd@0: double sz = 40.;
wolffd@0: char *f = "/usr/local/share/ttf/Times.ttf"; /* User supplied font */
wolffd@0:
wolffd@0: /* obtain brect so that we can size the image */
wolffd@0: err = gdImageStringFT(NULL,&brect[0],0,f,sz,0.,0,0,s);
wolffd@0: if (err) {fprintf(stderr,err); return 1;}
wolffd@0:
wolffd@0: /* create an image big enough for the string plus a little whitespace */
wolffd@0: x = brect[2]-brect[6] + 6;
wolffd@0: y = brect[3]-brect[7] + 6;
wolffd@0: im = gdImageCreate(x,y);
wolffd@0:
wolffd@0: /* Background color (first allocated) */
wolffd@0: white = gdImageColorResolve(im, 255, 255, 255);
wolffd@0: black = gdImageColorResolve(im, 0, 0, 0);
wolffd@0:
wolffd@0: /* render the string, offset origin to center string*/
wolffd@0: /* note that we use top-left coordinate for adjustment
wolffd@0: * since gd origin is in top-left with y increasing downwards. */
wolffd@0: x = 3 - brect[6];
wolffd@0: y = 3 - brect[7];
wolffd@0: err = gdImageStringFT(im,&brect[0],black,f,sz,0.0,x,y,s);
wolffd@0: if (err) {fprintf(stderr,err); return 1;}
wolffd@0:
wolffd@0: /* Write img to stdout */
wolffd@0: gdImagePng(im, stdout);
wolffd@0:
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: See also gdImageStringFTEx.
wolffd@0: strex
parameter is not null, it must point to a
wolffd@0: gdFTStringExtra
structure. As of gd 2.0.5, this structure
wolffd@0: is defined as follows:
wolffd@0:
wolffd@0: typedef struct {
wolffd@0: /* logical OR of gdFTEX_ values */
wolffd@0: int flags;
wolffd@0: /* fine tune line spacing for '\n' */
wolffd@0: double linespacing;
wolffd@0: /* Preferred character mapping */
wolffd@0: int charmap;
wolffd@0: /* Rendering resolution */
wolffd@0: int hdpi;
wolffd@0: int vdpi;
wolffd@0: char *xshow;
wolffd@0: char *fontpath;
wolffd@0: } gdFTStringExtra, *gdFTStringExtraPtr;
wolffd@0:
wolffd@0: To output multiline text with a specific line spacing,
wolffd@0: include gdFTEX_LINESPACE
in the setting of
wolffd@0: flags
:
wolffd@0:
wolffd@0: flags |= gdFTEX_LINESPACE;
wolffd@0:
wolffd@0: And also set linespacing
to the desired spacing, expressed as a
wolffd@0: multiple of the font height. Thus a line spacing of 1.0 is the
wolffd@0: minimum to guarantee that lines of text do not collide.
wolffd@0: gdFTEX_LINESPACE
is not present, or
wolffd@0: strex
is null, or gdImageStringFT
wolffd@0: is called, linespacing
defaults to 1.05.
wolffd@0: gdFTEX_CHARMAP
in the setting of
wolffd@0: flags
:
wolffd@0:
wolffd@0: flags |= gdFTEX_CHARMAP;
wolffd@0:
wolffd@0: And set charmap
to the desired value, which can be
wolffd@0: any of gdFTEX_Unicode, gdFTEX_Shift_JIS, gdFTEX_Big5, or gdFTEX_Adobe_Custom.
wolffd@0: If you do not specify a preference, Unicode will be tried first. If the preferred
wolffd@0: character mapping is not found in the font, other character mappings
wolffd@0: are attempted.
wolffd@0: gdFTEX_RESOLUTION
to flags
:
wolffd@0:
wolffd@0: flags | gdFTEX_RESOLUTION;
wolffd@0:
wolffd@0: GD 2.0.29 and later will normally attempt to apply kerning tables, if
wolffd@0: fontconfig is available, to adjust the relative positions of consecutive
wolffd@0: characters more ideally for that pair of characters. This can be turn off by
wolffd@0: specifying the gdFTEX_DISABLE_KERNING flag:
wolffd@0:
wolffd@0: flags | gdFTEX_DISABLE_KERNING;
wolffd@0:
wolffd@0: GD 2.0.29 and later can return a vector of individual character
wolffd@0: position advances, occasionally useful in applications that must know
wolffd@0: exactly where each character begins. This is returned in the xshow
wolffd@0: element of the gdFTStringExtra structure if the gdFTEX_XSHOW
wolffd@0: flag is set:
wolffd@0:
wolffd@0: flags | gdFTEX_XSHOW;
wolffd@0:
wolffd@0: The caller is responsible for calling gdFree() on the xshow
wolffd@0: element after the call if gdFTEX_XSHOW is set.
wolffd@0:
wolffd@0: flags | gdFTEX_RETURNFONTPATHNAME;
wolffd@0:
wolffd@0: The caller is responsible for calling gdFree() on the fontpath
wolffd@0: element after the call if gdFTEX_RETURNFONTPATHNAME is set.
wolffd@0:
wolffd@0: flags | gdFTEX_FONTPATHNAME;
wolffd@0:
wolffd@0:
wolffd@0: flags | gdFTEX_FONTCONFIG;
wolffd@0:
wolffd@0: GD 2.0.29 and above can use fontconfig to resolve
wolffd@0: font names, including fontconfig patterns, if the gdFTEX_FONTCONFIG
wolffd@0: flag is set. As a convenience, this behavior can be made the default
wolffd@0: by calling gdFTUseFontConfig with
wolffd@0: a nonzero value. In that situation it is not necessary to set the
wolffd@0: gdFTEX_FONTCONFIG flag on every call; however explicit font path names
wolffd@0: can still be used if the gdFTEX_FONTPATHNAME flag is set:
wolffd@0:
wolffd@0: flags | gdFTEX_FONTPATHNAME;
wolffd@0:
wolffd@0: For more information, see gdImageStringFT.
wolffd@0: top
and bottom
wolffd@0: on im
, curved along the edge of a circle of radius
wolffd@0: radius
, with its center at cx
and cy
.
wolffd@0: top
is written clockwise
wolffd@0: along the top; bottom
is written counterclockwise
wolffd@0: along the bottom. textRadius
determines the "height"
wolffd@0: of each character; if textRadius
is 1/2 of
wolffd@0: radius
,
wolffd@0: characters extend halfway from the edge to the center.
wolffd@0: fillPortion
varies from 0 to 1.0, with useful values
wolffd@0: from about 0.4 to 0.9, and determines how much of the
wolffd@0: 180 degrees of arc assigned to each section of text
wolffd@0: is actually occupied by text; 0.9 looks better than
wolffd@0: 1.0 which is rather crowded. font
is a freetype
wolffd@0: font; see gdImageStringFT. points
is passed to the
wolffd@0: freetype engine and has an effect on hinting; although
wolffd@0: the size of the text is determined by radius
,
wolffd@0: textRadius
, and fillPortion
, you should
wolffd@0: pass a point size that
wolffd@0: "hints" appropriately -- if you know the text will be
wolffd@0: large, pass a large point size such as 24.0 to get the
wolffd@0: best results. fgcolor
can be any color, and may have
wolffd@0: an alpha component, do blending, etc.
wolffd@0:
wolffd@0: #include <stdio.h>
wolffd@0: #include <gd.h>
wolffd@0:
wolffd@0: int main (int argc, char *argv[])
wolffd@0: {
wolffd@0: FILE *in;
wolffd@0: FILE *out;
wolffd@0: gdImagePtr im;
wolffd@0: int radius;
wolffd@0: /* Create an image of text on a circle, with an
wolffd@0: alpha channel so that we can copy it onto a
wolffd@0: background */
wolffd@0: in = fopen("mypicture.jpg", "rb");
wolffd@0: if (!in) {
wolffd@0: im = gdImageCreateTrueColor(300, 300);
wolffd@0: } else {
wolffd@0: im = gdImageCreateFromJpeg(in);
wolffd@0: fclose(in);
wolffd@0: }
wolffd@0: if (gdImageSX(im) < gdImageSY(im)) {
wolffd@0: radius = gdImageSX(im) / 2;
wolffd@0: } else {
wolffd@0: radius = gdImageSY(im) / 2;
wolffd@0: }
wolffd@0: gdStringFTCircle(
wolffd@0: im,
wolffd@0: gdImageSX(im) / 2,
wolffd@0: gdImageSY(im) / 2,
wolffd@0: radius,
wolffd@0: radius / 2,
wolffd@0: 0.8,
wolffd@0: "arial",
wolffd@0: 24,
wolffd@0: "top text",
wolffd@0: "bottom text",
wolffd@0: gdTrueColorAlpha(240, 240, 255, 32));
wolffd@0: out = fopen("gdfx.png", "wb");
wolffd@0: if (!out) {
wolffd@0: fprintf(stderr, "Can't create gdfx.png\n");
wolffd@0: return 1;
wolffd@0: }
wolffd@0: gdImagePng(im, out);
wolffd@0: fclose(out);
wolffd@0: gdImageDestroy(im);
wolffd@0: return 0;
wolffd@0: }
wolffd@0:
wolffd@0:
wolffd@0: Color-handling functions
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int red;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color red. */
wolffd@0: red = gdImageColorAllocate(im, 255, 0, 0);
wolffd@0: /* Draw a dashed line from the upper left corner
wolffd@0: to the lower right corner. */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99, red);
wolffd@0: /* ... Do something with the image, such as saving
wolffd@0: it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: int red;
wolffd@0: im = gdImageCreate(100, 100);
wolffd@0: /* Background color (first allocated) */
wolffd@0: black = gdImageColorAllocate(im, 0, 0, 0);
wolffd@0: /* Allocate the color red, 50% transparent. */
wolffd@0: red = gdImageColorAllocateAlpha(im, 255, 0, 0, 64);
wolffd@0: /* Draw a dashed line from the upper left corner to the lower right corner. */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: FILE *in;
wolffd@0: int red;
wolffd@0: /* Let's suppose that photo.png is a scanned photograph with
wolffd@0: many colors. */
wolffd@0: in = fopen("photo.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Try to allocate red directly */
wolffd@0: red = gdImageColorAllocate(im, 255, 0, 0);
wolffd@0: /* If we fail to allocate red... */
wolffd@0: if (red == (-1)) {
wolffd@0: /* Find the closest color instead. */
wolffd@0: red = gdImageColorClosest(im, 255, 0, 0);
wolffd@0: }
wolffd@0: /* Draw a dashed line from the upper left corner to the lower right corner */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: FILE *in;
wolffd@0: int red;
wolffd@0: /* Let's suppose that photo.png is a scanned photograph with
wolffd@0: many colors. */
wolffd@0: in = fopen("photo.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Try to allocate red, 50% transparent, directly */
wolffd@0: red = gdImageColorAllocateAlpha(im, 255, 0, 0, 64);
wolffd@0: /* If we fail to allocate red... */
wolffd@0: if (red == (-1)) {
wolffd@0: /* Find the closest color instead. */
wolffd@0: red = gdImageColorClosestAlpha(im, 255, 0, 0, 64);
wolffd@0: }
wolffd@0: /* Draw a dashed line from the upper left corner to the lower right corner */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: FILE *in;
wolffd@0: int red;
wolffd@0: /* Let's suppose that photo.png is a scanned photograph with
wolffd@0: many colors. */
wolffd@0: in = fopen("photo.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Try to allocate red directly */
wolffd@0: red = gdImageColorAllocate(im, 255, 0, 0);
wolffd@0: /* If we fail to allocate red... */
wolffd@0: if (red == (-1)) {
wolffd@0: /* Find the closest color instead. */
wolffd@0: red = gdImageColorClosestHWB(im, 255, 0, 0);
wolffd@0: }
wolffd@0: /* Draw a dashed line from the upper left corner to the lower right corner */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int red;
wolffd@0: in = fopen("photo.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* The image may already contain red; if it does, we'll save a slot
wolffd@0: in the color table by using that color. */
wolffd@0: /* Try to allocate red directly */
wolffd@0: red = gdImageColorExact(im, 255, 0, 0);
wolffd@0: /* If red isn't already present... */
wolffd@0: if (red == (-1)) {
wolffd@0: /* Second best: try to allocate it directly. */
wolffd@0: red = gdImageColorAllocate(im, 255, 0, 0);
wolffd@0: /* Out of colors, so find the closest color instead. */
wolffd@0: red = gdImageColorClosest(im, 255, 0, 0);
wolffd@0: }
wolffd@0: /* Draw a dashed line from the upper left corner to the lower right corner */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int red;
wolffd@0: in = fopen("photo.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* The image may already contain red; if it does, we'll save a slot
wolffd@0: in the color table by using that color. */
wolffd@0: /* Get index of red, or color closest to red */
wolffd@0: red = gdImageColorResolve(im, 255, 0, 0);
wolffd@0: /* Draw a dashed line from the upper left corner to the lower right corner */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99, red);
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int red;
wolffd@0: in = fopen("photo.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* The image may already contain red; if it does,
wolffd@0: we'll save a slot in the color table by using that color. */
wolffd@0: /* Get index of red, 50% transparent, or the next best thing */
wolffd@0: red = gdImageColorResolveAlpha(im, 255, 0, 0, 64);
wolffd@0: /* Draw a dashed line from the upper left corner to the lower right corner */
wolffd@0: gdImageDashedLine(im, 0, 0, 99, 99, red);
wolffd@0: /* ... Do something with the image, such as saving
wolffd@0: it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int red, blue;
wolffd@0: in = fopen("photo.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Look for red in the color table. */
wolffd@0: red = gdImageColorExact(im, 255, 0, 0);
wolffd@0: /* If red is present... */
wolffd@0: if (red != (-1)) {
wolffd@0: /* Deallocate it. */
wolffd@0: gdImageColorDeallocate(im, red);
wolffd@0: /* Allocate blue, reusing slot in table.
wolffd@0: Existing red pixels will change color. */
wolffd@0: blue = gdImageColorAllocate(im, 0, 0, 255);
wolffd@0: }
wolffd@0: /* ... Do something with the image, such as
wolffd@0: saving it to a file... */
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0:
wolffd@0: ... inside a function ...
wolffd@0: gdImagePtr im;
wolffd@0: int black;
wolffd@0: FILE *in, *out;
wolffd@0: in = fopen("photo.png", "rb");
wolffd@0: im = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Look for black in the color table and make it transparent. */
wolffd@0: black = gdImageColorExact(im, 0, 0, 0);
wolffd@0: /* If black is present... */
wolffd@0: if (black != (-1)) {
wolffd@0: /* Make it transparent */
wolffd@0: gdImageColorTransparent(im, black);
wolffd@0: }
wolffd@0: /* Save the newly-transparent image back to the file */
wolffd@0: out = fopen("photo.png", "wb");
wolffd@0: gdImagePng(im, out);
wolffd@0: fclose(out);
wolffd@0: /* Destroy it */
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: Copying and resizing functions
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: dst
argument is the destination image to which the
wolffd@0: region will be copied. The src
argument is the source
wolffd@0: image from which the region is copied. The dstX
wolffd@0: and dstY
arguments specify the point in the destination
wolffd@0: image to which the region will be copied. The srcX
wolffd@0: and srcY
arguments specify the upper left corner
wolffd@0: of the region in the source image. The w
wolffd@0: and h
arguments specify the width and height
wolffd@0: of the region.
wolffd@0:
wolffd@0: ... Inside a function ...
wolffd@0: gdImagePtr im_in;
wolffd@0: gdImagePtr im_out;
wolffd@0: int x, y;
wolffd@0: FILE *in;
wolffd@0: FILE *out;
wolffd@0: /* Load a small png to tile the larger one with */
wolffd@0: in = fopen("small.png", "rb");
wolffd@0: im_in = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Make the output image four times as large on both axes */
wolffd@0: im_out = gdImageCreate(im_in->sx * 4, im_in->sy * 4);
wolffd@0: /* Now tile the larger image using the smaller one */
wolffd@0: for (y = 0; (y < 4); y++) {
wolffd@0: for (x = 0; (x < 4); x++) {
wolffd@0: gdImageCopy(im_out, im_in,
wolffd@0: x * im_in->sx, y * im_in->sy,
wolffd@0: 0, 0,
wolffd@0: im_in->sx, im_in->sy);
wolffd@0: }
wolffd@0: }
wolffd@0: out = fopen("tiled.png", "wb");
wolffd@0: gdImagePng(im_out, out);
wolffd@0: fclose(out);
wolffd@0: gdImageDestroy(im_in);
wolffd@0: gdImageDestroy(im_out);
wolffd@0:
wolffd@0: dst
argument is the destination image to which the
wolffd@0: region will be copied. The src
argument is the source
wolffd@0: image from which the region is copied. The dstX
wolffd@0: and dstY
arguments specify the point in the destination
wolffd@0: image to which the region will be copied. The srcX
wolffd@0: and srcY
arguments specify the upper left corner
wolffd@0: of the region in the source image. The dstW
wolffd@0: and dstH
arguments specify the width and height
wolffd@0: of the destination region. The srcW
wolffd@0: and srcH
arguments specify the width and height
wolffd@0: of the source region and can differ from the destination size,
wolffd@0: allowing a region to be scaled during the copying process.
wolffd@0:
wolffd@0: ... Inside a function ...
wolffd@0: gdImagePtr im_in;
wolffd@0: gdImagePtr im_out;
wolffd@0: int x, y;
wolffd@0: FILE *in;
wolffd@0: FILE *out;
wolffd@0: /* Load a small png to expand in the larger one */
wolffd@0: in = fopen("small.png", "rb");
wolffd@0: im_in = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Make the output image four times as large on both axes */
wolffd@0: im_out = gdImageCreate(im_in->sx * 4, im_in->sy * 4);
wolffd@0: /* Now copy the smaller image, but four times larger */
wolffd@0: gdImageCopyResized(im_out, im_in, 0, 0, 0, 0,
wolffd@0: im_out->sx, im_out->sy,
wolffd@0: im_in->sx, im_in->sy);
wolffd@0: out = fopen("large.png", "wb");
wolffd@0: gdImagePng(im_out, out);
wolffd@0: fclose(out);
wolffd@0: gdImageDestroy(im_in);
wolffd@0: gdImageDestroy(im_out);
wolffd@0:
wolffd@0: dst
argument is the destination image to which the
wolffd@0: region will be copied. The src
argument is the source
wolffd@0: image from which the region is copied. The dstX
wolffd@0: and dstY
arguments specify the point in the destination
wolffd@0: image to which the region will be copied. The srcX
wolffd@0: and srcY
arguments specify the upper left corner
wolffd@0: of the region in the source image. The dstW
wolffd@0: and dstH
arguments specify the width and height
wolffd@0: of the destination region. The srcW
wolffd@0: and srcH
arguments specify the width and height
wolffd@0: of the source region and can differ from the destination size,
wolffd@0: allowing a region to be scaled during the copying process.
wolffd@0:
wolffd@0: ... Inside a function ...
wolffd@0: gdImagePtr im_in;
wolffd@0: gdImagePtr im_out;
wolffd@0: int x, y;
wolffd@0: FILE *in;
wolffd@0: FILE *out;
wolffd@0: /* Load a large png to shrink in the smaller one */
wolffd@0: in = fopen("large.png", "rb");
wolffd@0: im_in = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Make the output image four times as small on both axes. Use
wolffd@0: a true color image so that we can interpolate colors. */
wolffd@0: im_out = gdImageCreateTrueColor(im_in->sx / 4, im_in->sy / 4);
wolffd@0: /* Now copy the large image, but four times smaller */
wolffd@0: gdImageCopyResampled(im_out, im_in, 0, 0, 0, 0,
wolffd@0: im_out->sx, im_out->sy,
wolffd@0: im_in->sx, im_in->sy);
wolffd@0: out = fopen("large.png", "wb");
wolffd@0: gdImagePng(im_out, out);
wolffd@0: fclose(out);
wolffd@0: gdImageDestroy(im_in);
wolffd@0: gdImageDestroy(im_out);
wolffd@0:
wolffd@0:
wolffd@0: ... Inside a function ...
wolffd@0: gdImagePtr im_in;
wolffd@0: gdImagePtr im_out;
wolffd@0: int x, y;
wolffd@0: int a;
wolffd@0: FILE *in;
wolffd@0: FILE *out;
wolffd@0: /* Load a small png to rotate in the larger one */
wolffd@0: in = fopen("small.png", "rb");
wolffd@0: im_in = gdImageCreateFromPng(in);
wolffd@0: fclose(in);
wolffd@0: /* Make the output image four times as large on both axes */
wolffd@0: im_out = gdImageCreate(im_in->sx * 4, im_in->sy * 4);
wolffd@0: /* Now rotate the smaller image */
wolffd@0: for (a = 0; (a < 360); a += 45) {
wolffd@0: double x = cos(a * .0174532925) * gdImageSX(im_out) / 2;
wolffd@0: double y = -sin(a * .0174532925) * gdImageSY(im_out) / 2;
wolffd@0: gdImageCopyRotated(im_out, im_in,
wolffd@0: gdImageSX(im_out) / 2 + x,
wolffd@0: gdImageSY(im_out) / 2 + y,
wolffd@0: 0, 0,
wolffd@0: gdImageSX(im_in),
wolffd@0: gdImageSY(im_in),
wolffd@0: a);
wolffd@0: }
wolffd@0: out = fopen("large.png", "wb");
wolffd@0: gdImagePng(im_out, out);
wolffd@0: fclose(out);
wolffd@0: gdImageDestroy(im_in);
wolffd@0: gdImageDestroy(im_out);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: ... Inside a function ...
wolffd@0: gdImageCopyMerge(im_out, im_in, 100, 200, 0, 0, 30, 50, 50);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: ... Inside a function ...
wolffd@0: gdImageCopyMergeGray(im_out, im_in, 100, 200, 0, 0, 30, 50, 50);
wolffd@0:
wolffd@0:
wolffd@0: Miscellaneous Functions
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: ... Inside a function ...
wolffd@0: cmpMask = gdImageCompare(im1, im2);
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: gdImagePtr im;
wolffd@0: FILE *out;
wolffd@0: /* ... Create or load the image... */
wolffd@0:
wolffd@0: /* Now turn on interlace */
wolffd@0: gdImageInterlace(im, 1);
wolffd@0: /* And open an output file */
wolffd@0: out = fopen("test.png", "wb");
wolffd@0: /* And save the image -- could also use gdImageJpeg */
wolffd@0: gdImagePng(im, out);
wolffd@0: fclose(out);
wolffd@0: gdImageDestroy(im);
wolffd@0:
wolffd@0: free()
that is ultimately called will
wolffd@0: be intended for use with the version of malloc()
that
wolffd@0: originally allocated the block.
wolffd@0: Constants
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: gdMaxColors
(CONSTANT)
wolffd@0: About the additional .gd image file format
wolffd@0: In addition to reading and writing the PNG and JPEG formats and reading the
wolffd@0: X Bitmap format, gd has the capability to read and write its
wolffd@0: own ".gd" format. This format is not intended for
wolffd@0: general purpose use and should never be used to distribute
wolffd@0: images. It is not a compressed format. Its purpose is solely to
wolffd@0: allow very fast loading of images your program needs often in
wolffd@0: order to build other images for output. If you are experiencing
wolffd@0: performance problems when loading large, fixed PNG images your
wolffd@0: program needs to produce its output images, you may wish
wolffd@0: to examine the functions
wolffd@0: gdImageCreateFromGd and gdImageGd,
wolffd@0: which read and write .gd format images.
wolffd@0:
wolffd@0: About the .gd2 image file format
wolffd@0: In addition to reading and writing the PNG format and reading the
wolffd@0: X Bitmap format, gd has the capability to read and write its
wolffd@0: own ".gd2" format. This format is not intended for
wolffd@0: general purpose use and should never be used to distribute
wolffd@0: images. It is a compressed format allowing pseudo-random access
wolffd@0: to large image files. Its purpose is solely to
wolffd@0: allow very fast loading of parts of images
wolffd@0: If you are experiencing
wolffd@0: performance problems when loading large, fixed PNG or JPEG images your
wolffd@0: program needs to produce its output images, you may wish
wolffd@0: to examine the functions
wolffd@0: gdImageCreateFromGd2,
wolffd@0: gdImageCreateFromGd2Part and gdImageGd2,
wolffd@0: which read and write .gd2 format images.
wolffd@0:
wolffd@0: About the gdIOCtx structure
wolffd@0: Version 1.5 of GD added a new style of I/O based on an IOCtx
wolffd@0: structure (the most up-to-date version can be found in gd_io.h):
wolffd@0:
wolffd@0: typedef struct gdIOCtx {
wolffd@0: int (*getC)(struct gdIOCtx*);
wolffd@0: int (*getBuf)(struct gdIOCtx*, void*, int);
wolffd@0:
wolffd@0: void (*putC)(struct gdIOCtx*, int);
wolffd@0: int (*putBuf)(struct gdIOCtx*, const void*, int);
wolffd@0:
wolffd@0: int (*seek)(struct gdIOCtx*, const int); /* Returns 1 on SUCCESS */
wolffd@0: long (*tell)(struct gdIOCtx*);
wolffd@0:
wolffd@0: void (*free)(struct gdIOCtx*);
wolffd@0:
wolffd@0: } gdIOCtx;
wolffd@0:
wolffd@0:
wolffd@0: Most functions that accepted files in previous versions now also have a
wolffd@0: counterpart that accepts an I/O context. These functions have a 'Ctx'
wolffd@0: suffix.
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0:
wolffd@0: All Must have 'free',
wolffd@0: Anything that reads from the context Must have 'getC' and 'getBuf',
wolffd@0: Anything that writes to the context Must have 'putC' and 'putBuf'.
wolffd@0: If gdCreateFromGd2Part is called Must also have 'seek' and 'tell'. Note: seek must return 1 on SUCCESS and 0 on FAILURE.
wolffd@0: If gdImageGd2 is called Must also have 'seek' and 'tell'. Please tell us you're using gd!
wolffd@0: When you contact us and let us know you are using gd,
wolffd@0: you help us justify the time spent in maintaining and improving
wolffd@0: it. So please let us know. If the results are publicly
wolffd@0: visible on the web, a URL is a wonderful thing to receive, but
wolffd@0: if it's not a publicly visible project, a simple note is just
wolffd@0: as welcome.
wolffd@0:
wolffd@0: How do I get support?
wolffd@0: Free Support
wolffd@0:
wolffd@0: Anyone can mail questions about the gd library using the
wolffd@0: LibGD support. However,
wolffd@0: we receive a very large volume of email on many subjects, and while we do
wolffd@0: our best to respond to all queries this can take some time. Sometimes
wolffd@0: the response must take the form of an eventual new release or
wolffd@0: an addition to a FAQ or other document, as opposed to an detailed individual response.
wolffd@0:
wolffd@0: Hourly Support
wolffd@0: Those requiring support in detail may arrange for direct support
wolffd@0: from the maintaines, at the rate of $50/hr, billed
wolffd@0: directly by credit card. Purchase orders are also accepted from
wolffd@0: Fortune 500 corporations and institutions in good standing.
wolffd@0: To make arrangements, contact Pierre-A. Joye. To avoid delay
wolffd@0: and/or confusion, be sure to specifically mention that you wish to purchase gd support at the
wolffd@0: hourly rate above.
wolffd@0:
wolffd@0: How do I report issues, bugs or features request?
wolffd@0: Bugs, feature requests or other issues can be reported using the
wolffd@0: libGD.org issues tracker. as well as using
wolffd@0: one of our support channels: LibGD support
wolffd@0:
wolffd@0: Alphabetical quick index
wolffd@0: gdAntiAliased |
wolffd@0: gdBrushed |
wolffd@0: gdDashSize |
wolffd@0: gdFont |
wolffd@0: gdFontGetHuge |
wolffd@0: gdFontGetLarge |
wolffd@0: gdFontGetMediumBold |
wolffd@0: gdFontGetSmall |
wolffd@0: gdFontGetTiny |
wolffd@0: gdFontCacheSetup |
wolffd@0: gdFontCacheShutdown |
wolffd@0: gdFontPtr |
wolffd@0: gdFree |
wolffd@0: gdImage |
wolffd@0: gdImageAlphaBlending |
wolffd@0: gdImageArc |
wolffd@0: gdImageBlue |
wolffd@0: gdImageBoundsSafe |
wolffd@0: gdImageChar |
wolffd@0: gdImageCharUp |
wolffd@0: gdImageColorAllocate |
wolffd@0: gdImageColorAllocateAlpha |
wolffd@0: gdImageColorClosest |
wolffd@0: gdImageColorClosestAlpha |
wolffd@0: gdImageColorClosestHWB |
wolffd@0: gdImageColorDeallocate |
wolffd@0: gdImageColorExact |
wolffd@0: gdImageColorExactAlpha |
wolffd@0: gdImageColorResolve |
wolffd@0: gdImageColorResolveAlpha |
wolffd@0: gdImageColorTransparent |
wolffd@0: gdImageCopy |
wolffd@0: gdImageCopyMerge |
wolffd@0: gdImageMergeGray |
wolffd@0: gdImageCopyResized |
wolffd@0: gdImageCopyResampled |
wolffd@0: gdImageCopyRotated |
wolffd@0: gdImageCreate |
wolffd@0: gdImageCreatePalette |
wolffd@0: gdImageCreateTrueColor |
wolffd@0: gdImageCreateFromGd |
wolffd@0: gdImageCreateFromGdCtx |
wolffd@0: gdImageCreateFromGdPtr |
wolffd@0: gdImageCreateFromGd2 |
wolffd@0: gdImageCreateFromGd2Ctx |
wolffd@0: gdImageCreateFromGd2Ptr |
wolffd@0: gdImageCreateFromGd2Part |
wolffd@0: gdImageCreateFromGd2PartCtx |
wolffd@0: gdImageCreateFromGd2PartPtr |
wolffd@0: gdImageCreateFromJpeg |
wolffd@0: gdImageCreateFromJpegCtx |
wolffd@0: gdImageCreateFromJpegPtr |
wolffd@0: gdImageCreateFromPng |
wolffd@0: gdImageCreateFromPngCtx |
wolffd@0: gdImageCreateFromPngPtr |
wolffd@0: gdImageCreateFromPngSource |
wolffd@0: gdImageCreateFromWBMP |
wolffd@0: gdImageCreateFromWBMPCtx |
wolffd@0: gdImageCreateFromWBMPPtr |
wolffd@0: gdImageCreateFromXbm |
wolffd@0: gdImageCreateFromXpm |
wolffd@0: gdImageDashedLine |
wolffd@0: gdImageDestroy |
wolffd@0: gdImageFill |
wolffd@0: gdImageFilledArc |
wolffd@0: gdImageFilledEllipse |
wolffd@0: gdImageFillToBorder |
wolffd@0: gdImageFilledRectangle |
wolffd@0: gdImageGd |
wolffd@0: gdImageGd2 |
wolffd@0: gdImageGetInterlaced |
wolffd@0: gdImageGetPixel |
wolffd@0: gdImageGetTransparent |
wolffd@0: gdImageGifAnimAdd |
wolffd@0: gdImageGifAnimAddCtx |
wolffd@0: gdImageGifAnimAddPtr |
wolffd@0: gdImageGifAnimBegin |
wolffd@0: gdImageGifAnimBeginCtx |
wolffd@0: gdImageGifAnimBeginPtr |
wolffd@0: gdImageGifAnimEnd |
wolffd@0: gdImageGifAnimEndCtx |
wolffd@0: gdImageGifAnimEndPtr |
wolffd@0: gdImageGreen |
wolffd@0: gdImageInterlace |
wolffd@0: gdImageJpeg |
wolffd@0: gdImageJpegCtx |
wolffd@0: gdImageLine |
wolffd@0: gdImageFilledPolygon |
wolffd@0: gdImageOpenPolygon |
wolffd@0: gdImagePaletteCopy |
wolffd@0: gdImagePng |
wolffd@0: gdImagePngEx |
wolffd@0: gdImagePngCtx |
wolffd@0: gdImagePngCtxEx |
wolffd@0: gdImagePngPtr |
wolffd@0: gdImagePngPtrEx |
wolffd@0: gdImagePngToSink |
wolffd@0: gdImagePolygon |
wolffd@0: gdImagePtr |
wolffd@0: gdImageWBMP |
wolffd@0: gdImageWBMPCtx |
wolffd@0: gdImageRectangle |
wolffd@0: gdImageRed |
wolffd@0: gdImageSaveAlpha |
wolffd@0: gdImageSetAntiAliased |
wolffd@0: gdImageSetAntiAliasedDontBlend |
wolffd@0: gdImageSetBrush |
wolffd@0: gdImageSetPixel |
wolffd@0: gdImageSetStyle |
wolffd@0: gdImageSetThickness |
wolffd@0: gdImageSetTile |
wolffd@0: gdImageSharpen |
wolffd@0: gdImageSquareToCircle |
wolffd@0: gdImageString |
wolffd@0: gdImageString16 |
wolffd@0: gdImageStringFT |
wolffd@0: gdImageStringFTCircle |
wolffd@0: gdImageStringFTEx |
wolffd@0: gdImageStringTTF |
wolffd@0: gdImageStringUp |
wolffd@0: gdImageStringUp16 |
wolffd@0: gdImageToPalette |
wolffd@0: gdImageWBMP |
wolffd@0: gdMaxColors |
wolffd@0: gdPoint |
wolffd@0: gdStyled |
wolffd@0: gdStyledBrushed |
wolffd@0: gdTiled |
wolffd@0: gdTransparent
wolffd@0: