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