4
A graphics library for fast image creation
6
Follow this link to the latest version of this document.
8
_HEY! READ THIS!_ gd 1.8.3 creates PNG, JPEG and WBMP images, not
9
GIF images. This is a good thing. PNG is a more compact format, and
10
full compression is available. JPEG works well with photographic
11
images, and is still more compatible with the major Web browsers
12
than even PNG is. WBMP is intended for wireless devices (not
13
regular web browsers). Existing code will need modification to call
14
gdImagePng or gdImageJpeg instead of gdImageGif. _Please do not ask
15
us to send you the old GIF version of GD._ Unisys holds a patent on
16
the LZW compression algorithm, which is used in fully compressed
17
GIF images. The best solution is to move to legally unencumbered,
18
well-compressed, modern image formats such as PNG and JPEG as soon
21
gd 1.8.3 _requires_ that the following libraries also be installed:
29
If you want to use the TrueType font support, you must also install
30
the _Freetype library_, including the _freetype.h header file_. See
31
the Freetype Home Page. No, I cannot explain why that site is down
32
on a particular day, and no, I can't send you a copy.
34
If you want to use the Xpm color bitmap loading support, you must
35
also have the X Window System and the Xpm library installed (Xpm is
36
often included in modern X distributions).
38
Please read the documentation and install the required libraries.
39
Do not send email asking why png.h is not found. See the
40
requirements section for more information. Thank you!
44
* Credits and license terms
45
* What's new in version 1.8.3?
46
* What's new in version 1.8.2?
47
* What's new in version 1.8.1?
48
* What's new in version 1.8?
49
* What's new in version 1.7.3?
50
* What's new in version 1.7.2?
51
* What's new in version 1.7.1?
52
* What's new in version 1.7?
53
* What's new in version 1.6.3?
54
* What's new in version 1.6.2?
55
* What's new in version 1.6.1?
56
* What's new in version 1.6?
58
* What if I want to use another programming language?
59
* What else do I need to use gd?
62
* gd basics: using gd in your program
63
* webpng: a useful example
64
* Function and type reference by category
65
* About the additional .gd image file format
66
* Please tell us you're using gd!
67
* If you have problems
68
* Alphabetical quick index
70
Up to the Boutell.Com, Inc. Home Page
72
Credits and license terms
74
In order to resolve any possible confusion regarding the authorship of
75
gd, the following copyright statement covers all of the authors who
76
have required such a statement. _If you are aware of any oversights in
77
this copyright notice, please contact Thomas Boutell who will be
78
pleased to correct them._
80
COPYRIGHT STATEMENT FOLLOWS THIS LINE
82
Portions copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000 by Cold
83
Spring Harbor Laboratory. Funded under Grant P41-RR02188 by the
84
National Institutes of Health.
86
Portions copyright 1996, 1997, 1998, 1999, 2000 by Boutell.Com,
89
Portions relating to GD2 format copyright 1999, 2000 Philip Warner.
91
Portions relating to PNG copyright 1999, 2000 Greg Roelofs.
93
Portions relating to libttf copyright 1999, 2000 John Ellson
96
Portions relating to JPEG copyright 2000, Doug Becker and copyright
97
(C) 1994-1998, Thomas G. Lane. This software is based in part on
98
the work of the Independent JPEG Group.
100
Portions relating to WBMP copyright 2000 Maurice Szmurlo and Johan
103
_Permission has been granted to copy, distribute and modify gd in
104
any context without fee, including a commercial application,
105
provided that this notice is present in user-accessible supporting
108
This does not affect your ownership of the derived work itself, and
109
the intent is to assure proper credit for the authors of gd, not to
110
interfere with your productive use of gd. If you have questions,
111
ask. "Derived works" includes all programs that utilize the
112
library. Credit must be given in user-accessible documentation.
114
_This software is provided "AS IS."_ The copyright holders disclaim
115
all warranties, either express or implied, including but not
116
limited to implied warranties of merchantability and fitness for a
117
particular purpose, with respect to this code and accompanying
120
Although their code does not appear in gd 1.8.3, the authors wish
121
to thank David Koblas, David Rowley, and Hutchison Avenue Software
122
Corporation for their prior contributions.
124
END OF COPYRIGHT STATEMENT
128
gd is a graphics library. It allows your code to quickly draw images
129
complete with lines, arcs, text, multiple colors, cut and paste from
130
other images, and flood fills, and write out the result as a PNG or
131
JPEG file. This is particularly useful in World Wide Web applications,
132
where PNG and JPEG are two of the formats accepted for inline images
135
gd is not a paint program. If you are looking for a paint program, you
136
are looking in the wrong place. If you are not a programmer, you are
137
looking in the wrong place.
139
gd does not provide for every possible desirable graphics operation.
140
It is not necessary or desirable for gd to become a kitchen-sink
141
graphics package, but version 1.7.3 incorporates most of the commonly
142
requested features for an 8-bit 2D package. Support for truecolor
143
images, including truecolor JPEG and PNG, is planned for version 2.0.
145
What if I want to use another programming language?
149
gd can also be used from Perl, courtesy of Lincoln Stein's GD.pm
150
library, which uses gd as the basis for a set of Perl 5.x classes.
155
gd can be used from Tcl with John Ellson's Gdtclft dynamically loaded
156
extension package. (Gdtclft2.0 or later is needed for gd-1.6 and up
161
Pascal enthusiasts should look into Michael Bradbury's gdfp package.
165
A new gd interface is now available for Haskell programmers.
169
There are, at the moment, at least three simple interpreters that
170
perform gd operations. You can output the desired commands to a simple
171
text file from whatever scripting language you prefer to use, then
172
invoke the interpreter.
174
These packages have not been updated to gd 1.6 and up as of this
176
* tgd, by Bradley K. Sherman
177
* fly, by Martin Gleeson
179
What's new in version 1.8.3?
181
* WBMP output memory leak fixed
182
* #include <gd.h> corrected to #include "gd.h" in gd_wbmp.c
183
* Documented the fact that the source and output images shouldn't
184
match in the WBMP test except for black and white source images
186
What's new in version 1.8.2?
188
* WBMP support debugged and improved by Johann Van den Brande
189
* WBMP tests added to gdtest.c by Thomas Boutell
190
* Use of platform-dependent 'install' command removed by Thomas
192
* Comments added to Makefile warning users to juggle the order of
193
the libraries if the linker complains; is there any portable way
194
to do this automatically, short of using autoconf?
195
* Documentation of gdImageCreateFromXpm corrected
196
* Updated links to fast-moving, always dodging libpng and zlib web
199
What's new in version 1.8.1?
201
* Optional components no longer built by default (following the
203
* JPEG code no longer requires inappropriate header files
204
* Win32 patches from Joe Gregorio
205
* 16-bit font support for bdftogd, from Honza Pazdziora
207
What's new in version 1.8?
209
* Support for JPEG output, courtesy of Doug Becker
210
* A link to Michael Bradbery's Pascal wrapper
211
* Support for WBMP output, courtesy of Maurice Szmurlo
212
* gdImageColorClosestHWB function based on hue, whiteness,
213
blackness, superior to the regular gdImageColorClosest function,
214
courtesy of Philip Warner
215
* License clarification: yes, you can modify gd
217
Additional JPEG Information
219
Support for reading and writing JPEG-format images is courtesy of Doug
220
Becker and the Independent JPEG Group / Thomas G. Lane. You can get
221
the latest version of the IJG JPEG software from
222
ftp://ftp.uu.net/graphics/jpeg/ (e.g., the jpegsrc.v6b.tar.gz file).
223
You _must_ use version 6b or later of the IJG JPEG software. You might
224
also consult the JPEG FAQ at http://www.faqs.org/faqs/jpeg-faq/.
226
What's new in version 1.7.3?
228
Another attempt at Makefile fixes to permit linking with all libraries
229
required on platforms with order- dependent linkers. Perhaps it will
232
What's new in version 1.7.2?
234
An uninitialized-pointer bug in gdtestttf.c was corrected. This bug
235
caused crashes at the end of each call to gdImageStringTTF on some
236
platforms. Thanks to Wolfgang Haefelinger.
238
Documentation fixes. Thanks to Dohn Arms.
240
Makefile fixes to permit linking with all libraries required on
241
platforms with order- dependent linkers.
243
What's new in version 1.7.1?
245
A minor buglet in the Makefile was corrected, as well as an inaccurate
246
error message in gdtestttf.c. Thanks to Masahito Yamaga.
248
What's new in version 1.7?
250
Version 1.7 contains the following changes:
251
* Japanese language support for the TrueType functions. Thanks to
253
* autoconf and configure have been removed, in favor of a carefully
254
designed Makefile which produces and properly installs the library
255
and the binaries. System-dependent variables are at the top of the
256
Makefile for easy modification. I'm sorry, folks, but autoconf
257
generated _many, many confused email messages_ from people who
258
didn't have things where autoconf expected to find them. I am not
259
an autoconf/automake wizard, and gd is a simple, very compact
260
library which does not need to be a shared library. I _did_ make
261
many improvements over the old gd 1.3 Makefile, which were
262
directly inspired by the autoconf version found in the 1.6 series
263
(thanks to John Ellson).
264
* Completely ANSI C compliant, according to the -pedantic-errors
265
flag of gcc. Several pieces of not-quite-ANSI-C code were causing
266
problems for those with non-gcc compilers.
267
* gdttf.c patched to allow the use of Windows symbol fonts, when
268
present (thanks to Joseph Peppin).
269
* extern "C" wrappers added to gd.h and the font header files for
270
the convenience of C++ programmers. bdftogd was also modified to
271
automatically insert these wrappers into future font header files.
272
Thanks to John Lindal.
273
* Compiles correctly on platforms that don't define SEEK_SET. Thanks
275
* Loads Xpm images via the gdImageCreateFromXpm function, if the Xpm
276
library is available. Thanks to Caolan McNamara.
278
What's new in version 1.6.3?
280
Version 1.6.3 corrects a memory leak in gd_png.c. This leak caused a
281
significant amount of memory to be allocated and not freed when
284
What's new in version 1.6.2?
286
Version 1.6.2 from John Ellson adds two new functions:
287
* gdImageStringTTF - scalable, rotatable, anti-aliased, TrueType
288
strings using the FreeType library, but only if libttf is found by
289
configure. _We do not provide TrueType fonts. Obtaining them is
291
* gdImageColorResolve - an efficient alternative for the common code
295
if ((color=gdImageColorExact(im,R,G,B)) < 0)
296
if ((color=gdImageColorAllocate(im,R,G,B)) < 0)
297
color=gdImageColorClosest(im,R,G,B);
299
Also in this release the build process has been converted to GNU
300
autoconf/automake/libtool conventions so that both (or either) static
301
and shared libraries can be built.
303
What's new in version 1.6.1?
305
Version 1.6.1 incorporates superior PNG reading and writing code from
306
Greg Roelofs, with minor modifications by Tom Boutell. Specifically, I
307
altered his code to read non-palette images (converting them to
308
palette images badly, by dithering them), and to tolerate palette
309
images with types of transparency that gd doesn't actually support (it
310
just ignores the advanced transparency features). Any bugs in this
311
area are therefore my fault, not Greg's.
313
Unlike gd 1.6, users should have no trouble linking with gd 1.6.1 if
314
they follow the instructions and install all of the pieces. However,
315
_If you get undefined symbol errors, be sure to check for older
316
versions of libpng in your library directories!_
318
What's new in version 1.6?
320
Version 1.6 features the following changes:
322
_Support for 8-bit palette PNG images has been added. Support for GIF
323
has been removed._ This step was taken to completely avoid the legal
324
controversy regarding the LZW compression algorithm used in GIF.
325
Unisys holds a patent which is relevant to LZW compression. PNG is a
326
superior image format in any case. Now that PNG is supported by both
327
Microsoft Internet Explorer and Netscape (in their recent releases),
328
we highly recommend that GD users upgrade in order to get
329
well-compressed images in a format which is legally unemcumbered.
331
What's new in version 1.5?
333
Version 1.5 featured the following changes:
336
An improvement over the GD format, the GD2 format uses the zlib
337
compression library to compress the image in chunks. This
338
results in file sizes comparable to GIFs, with the ability to
339
access parts of large images without having to read the entire
342
This format also supports version numbers and rudimentary
343
validity checks, so it should be more 'supportable' than the
346
_Re-arranged source files_
347
gd.c has been broken into constituant parts: io, gif, gd, gd2
348
and graphics functions are now in separate files.
350
_Extended I/O capabilities._
351
The source/sink feature has been extended to support GD2 file
352
formats (which require seek/tell functions), and to allow more
353
general non-file I/O.
355
_Better support for Lincoln Stein's Perl Module_
356
The new gdImage*Ptr function returns the chosen format stored
357
in a block of memory. This can be directly used by the GD perl
361
gdImageCreateFromGd2Part - allows retrieval of part of an image
362
(good for huge images, like maps),
363
gdImagePaletteCopy - Copies a palette from one image to
364
another, doing it's best to match the colors in the target
365
image to the colors in the source palette.
366
gdImageGd2, gdImageCreateFromGd2 - Support for new format
367
gdImageCopyMerge - Merges two images (useful to highlight part
369
gdImageCopyMergeGray - Similar to gdImageCopyMerge, but tries
370
to preserve source image hue.
371
gdImagePngPtr, gdImageJpegPtr, gdImageWBMPPtr, gdImageGdPtr,
372
gdImageGd2Ptr - return memort blocks for each type of image.
373
gdImageCreateFromPngCtx, gdImageCreateFromGdCtx,
374
gdImageCreateFromGd2Ctx, gdImageCreateFromGd2PartCtx - Support
377
_NOTE:_ In fairness to Thomas Boutell, any bug/problems with any of
378
the above features should probably be reported to Philip Warner.
380
What's new in version 1.4?
382
Version 1.4 features the following changes:
384
Fixed polygon fill routine (again)
385
Thanks to Kirsten Schulz, version 1.4 is able to fill numerous
386
types of polygons that caused problems with previous releases,
387
including version 1.3.
389
Support for alternate data sources
390
Programmers who wish to load a GIF from something other than a
391
stdio FILE * stream can use the new gdImageCreateFromPngSource
394
Support for alternate data destinations
395
Programmers who wish to write a GIF to something other than a
396
stdio FILE * stream can use the new gdImagePngToSink function.
398
More tolerant when reading GIFs
399
Version 1.4 does not crash when reading certain animated GIFs,
400
although it still only reads the first frame. Version 1.4 also
401
has overflow testing code to prevent crashes when reading
404
What's new in version 1.3?
406
Version 1.3 features the following changes:
408
Non-LZW-based GIF compression code
409
Version 1.3 contained GIF compression code that uses simple Run
410
Length Encoding instead of LZW compression, while still
411
retaining compatibility with normal LZW-based GIF decoders
412
(your browser will still like your GIFs). _LZW compression is
413
patented by Unisys. We are currently reevaluating the approach
414
taken by gd 1.3. The current release of gd does not support
415
this approach. We recommend that you use the current release,
416
and generate PNG images._ Thanks to Hutchison Avenue Software
417
Corporation for contributing the RLE GIF code.
419
8-bit fonts, and 8-bit font support
420
This improves support for European languages. Thanks are due to
421
Honza Pazdziora and also to Jan Pazdziora . Also see the
422
provided bdftogd Perl script if you wish to convert fixed-width
423
X11 fonts to gd fonts.
425
16-bit font support (no fonts provided)
426
Although no such fonts are provided in the distribution, fonts
427
containing more than 256 characters should work if the
428
gdImageString16 and gdImageStringUp16 routines are used.
430
Improvements to the "webpng" example/utility
431
The "webpng" utility is now a slightly more useful application.
432
Thanks to Brian Dowling for this code.
434
Corrections to the color resolution field of GIF output
435
Thanks to Bruno Aureli.
438
A one-line patch for the infamous polygon fill bug, courtesy of
439
Jim Mason. I believe this fix is sufficient. However, if you
440
find a situation where polygon fills still fail to behave
441
properly, please send code that demonstrates the problem, _and_
442
a fix if you have one. Verifying the fix is important.
444
Row-major, not column-major
445
Internally, gd now represents the array of pixels as an array
446
of rows of pixels, rather than an array of columns of pixels.
447
This improves the performance of compression and decompression
448
routines slightly, because horizontally adjacent pixels are now
449
next to each other in memory. _This should not affect properly
450
written gd applications, but applications that directly
451
manipulate the pixels array will require changes._
453
What else do I need to use gd?
455
To use gd, you will need an ANSI C compiler. _All popular Windows 95
456
and NT C compilers are ANSI C compliant._ Any full-ANSI-standard C
457
compiler should be adequate. _The cc compiler released with SunOS
458
4.1.3 is not an ANSI C compiler. Most Unix users who do not already
459
have gcc should get it. gcc is free, ANSI compliant and a de facto
460
industry standard. Ask your ISP why it is missing._
462
As of version 1.6, you also need the zlib compression library, and the
463
libpng library. As of version 1.6.2, you can draw text using
464
antialiased TrueType fonts if you also have the libttf library
465
installed, but this is not mandatory. zlib is available for a variety
466
of platforms from the zlib web site. libpng is available for a variety
467
of platforms from the PNG web site.
469
You will also want a PNG viewer, if you do not already have one for
470
your system, since you will need a good way to check the results of
471
your work. Netscape 4.04 and higher, and Microsoft Internet Explorer
472
4.0 or higher, both support PNG. For some purposes you might be
473
happier with a package like Lview Pro for Windows or xv for X. There
474
are PNG viewers available for every graphics-capable modern operating
475
system, so consult newsgroups relevant to your particular system.
481
* Gzipped Tar File (Unix)
482
* .ZIP File (Windows)
486
* Gzipped Tar File (Unix)
487
* .ZIP File (Windows)
491
In order to build gd, you must first unpack the archive you have
492
downloaded. If you are not familiar with tar and gunzip (Unix) or ZIP
493
(Windows), please consult with an experienced user of your system.
494
Sorry, we cannot answer questions about basic Internet skills.
496
Unpacking the archive will produce a directory called "gd-1.8.3".
500
cd to the 1.8.3 directory. Edit the Makefile with your preferred text
501
editor and make any necessary changes to the settings at the top,
502
especially if you want Xpm or TrueType support. Next, type "make". If
503
you are the system administrator, and you wish to make the gd library
504
available to other programs, you may also wish to type "make install".
506
If you get errors, edit the Makefile again, paying special attention
507
to the INCLUDEDIRS and LIBDIRS settings.
509
IF YOU GET LINKER ERRORS, TRY JUGGLING THE ORDER OF THE -l DIRECTIVES
510
IN THE MAKEFILE. Some platforms may prefer that the libraries be
511
listed in the opposite order.
513
For Windows, Mac, Et Cetera
515
Create a project using your favorite programming environment. Copy all
516
of the gd files to the project directory. Add gd.c to your project.
517
Add other source files as appropriate. Learning the basic skills of
518
creating projects with your chosen C environment is up to you.
520
You have now built both the gd library and a demonstration program
521
which shows off the capabilities of gd. To see it in action, type
524
gddemo should execute without incident, creating the file demoout.png.
525
(Note there is also a file named demoin.png, which is provided in the
526
package as part of the demonstration.)
528
Display demoout.png in your PNG viewer. The image should be 128x128
529
pixels and should contain an image of the space shuttle with quite a
530
lot of graphical elements drawn on top of it.
532
(If you are missing the demoin.png file, the other items should appear
535
Look at demoin.png to see the original space shuttle image which was
536
scaled and copied into the output image.
538
gd basics: using gd in your program
540
gd lets you create PNG or JPEG images on the fly. To use gd in your
541
program, include the file gd.h, and link with the libgd.a library
542
produced by "make libgd.a", under Unix. Under other operating systems
543
you will add gd.c to your own project.
545
If you want to use the provided fonts, include gdfontt.h, gdfonts.h,
546
gdfontmb.h, gdfontl.h and/or gdfontg.h. For more impressive results,
547
install libttf and use the new gdImageStringTTF function. If you are
548
not using the provided Makefile and/or a library-based approach, be
549
sure to include the source modules as well in your project. (They may
550
be too large for 16-bit memory models, that is, 16-bit DOS and
553
Here is a short example program. _(For a more advanced example, see
554
gddemo.c, included in the distribution. gddemo.c is NOT the same
555
program; it demonstrates additional features!)_
557
/* Bring in gd library functions */
560
/* Bring in standard I/O so we can output the PNG to a file */
564
/* Declare the image */
566
/* Declare output files */
567
FILE *pngout, *jpegout;
568
/* Declare color indexes */
572
/* Allocate the image: 64 pixels across by 64 pixels tall */
573
im = gdImageCreate(64, 64);
575
/* Allocate the color black (red, green and blue all minimum).
576
Since this is the first color in a new image, it will
577
be the background color. */
578
black = gdImageColorAllocate(im, 0, 0, 0);
580
/* Allocate the color white (red, green and blue all maximum). */
581
white = gdImageColorAllocate(im, 255, 255, 255);
583
/* Draw a line from the upper left to the lower right,
584
using white color index. */
585
gdImageLine(im, 0, 0, 63, 63, white);
587
/* Open a file for writing. "wb" means "write binary", important
588
under MSDOS, harmless under Unix. */
589
pngout = fopen("test.png", "wb");
591
/* Do the same for a JPEG-format file. */
592
jpegout = fopen("test.jpg", "wb");
594
/* Output the image to the disk file in PNG format. */
595
gdImagePng(im, pngout);
597
/* Output the same image in JPEG format, using the default
598
JPEG quality setting. */
599
gdImageJpeg(im, jpegout, -1);
601
/* Close the files. */
605
/* Destroy the image in memory. */
609
When executed, this program creates an image, allocates two colors
610
(the first color allocated becomes the background color), draws a
611
diagonal line (note that 0, 0 is the upper left corner), writes the
612
image to PNG and JPEG files, and destroys the image.
614
The above example program should give you an idea of how the package
615
works. gd provides many additional functions, which are listed in the
616
following reference chapters, complete with code snippets
617
demonstrating each. There is also an alphabetical index.
619
Webpng: a more powerful gd example
621
Webpng is a simple utility program to manipulate PNGs from the command
622
line. It is written for Unix and similar command-line systems, but
623
should be easily adapted for other environments. Webpng allows you to
624
set transparency and interlacing and output interesting information
625
about the PNG in question.
627
webpng.c is provided in the distribution. Unix users can simply type
628
"make webpng" to compile the program. Type "webpng" with no arguments
629
to see the available options.
631
Function and type reference
634
* Image creation, destruction, loading and saving
635
* Drawing, styling, brushing, tiling and filling functions
636
* Query functions (not color-related)
637
* Font and text-handling functions
638
* Color handling functions
639
* Copying and resizing functions
640
* Miscellaneous Functions
646
The data structure in which gd stores images. gdImageCreate
647
returns a pointer to this type, and the other functions expect
648
to receive a pointer to this type as their first argument. You
649
may read the members sx (size on X axis), sy (size on Y axis),
650
colorsTotal (total colors), red (red component of colors; an
651
array of 256 integers between 0 and 255), green (green
652
component of colors, as above), blue (blue component of colors,
653
as above), and transparent (index of transparent color, -1 if
654
none); please do so using the macros provided. Do NOT set the
655
members directly from your code; use the functions provided.
659
unsigned char ** pixels;
663
int red[gdMaxColors];
664
int green[gdMaxColors];
665
int blue[gdMaxColors];
666
int open[gdMaxColors];
671
A pointer to an image structure. gdImageCreate returns this
672
type, and the other functions expect it as the first argument.
675
A font structure. Used to declare the characteristics of a
676
font. Plese see the files gdfontl.c and gdfontl.h for an
677
example of the proper declaration of this structure. You can
678
provide your own font data by providing such a structure and
679
the associated pixel array. You can determine the width and
680
height of a single character in a font by examining the w and h
681
members of the structure. If you will not be creating your own
682
fonts, you will not need to concern yourself with the rest of
683
the components of this structure.
687
/* # of characters in font */
689
/* First character is numbered... (usually 32 = space) */
691
/* Character width and height */
694
/* Font data; array of characters, one row after another.
695
Easily included in code, also easily loaded from
701
A pointer to a font structure. Text-output functions expect
702
these as their second argument, following the gdImagePtr
703
argument. Two such pointers are declared in the provided
704
include files gdfonts.h and gdfontl.h.
707
Represents a point in the coordinate space of the image; used
708
by gdImagePolygon and gdImageFilledPolygon.
713
} gdPoint, *gdPointPtr;
716
A pointer to a gdPoint structure; passed as an argument to
717
gdImagePolygon and gdImageFilledPolygon.
722
int (*source) (void *context, char *buffer, int len);
724
} gdSource, *gdSourcePtr;
726
Represents a source from which a PNG can be read. Programmers who do
727
not wish to read PNGs from a file can provide their own alternate
728
input mechanism, using the gdImageCreateFromPngSource function. See
729
the documentation of that function for an example of the proper use of
735
int (*sink) (void *context, char *buffer, int len);
737
} gdSink, *gdSinkPtr;
739
Represents a "sink" (destination) to which a PNG can be written.
740
Programmers who do not wish to write PNGs to a file can provide their
741
own alternate output mechanism, using the gdImagePngToSink function.
742
See the documentation of that function for an example of the proper
745
Image creation, destruction, loading and saving
747
gdImageCreate(sx, sy) _(FUNCTION)_
748
gdImageCreate is called to create images. Invoke gdImageCreate
749
with the x and y dimensions of the desired image. gdImageCreate
750
returns a gdImagePtr to the new image, or NULL if unable to
751
allocate the image. The image must eventually be destroyed
752
using gdImageDestroy().
755
... inside a function ...
757
im = gdImageCreate(64, 64);
758
/* ... Use the image ... */
761
gdImageCreateFromJpeg(FILE *in) _(FUNCTION)_
762
gdImageCreateFromJpegCtx(FILE *in) _(FUNCTION)_
765
gdImageCreateFromJpeg is called to load images from JPEG format
766
files. Invoke gdImageCreateFromJpeg with an already opened
767
pointer to a file containing the desired image.
768
gdImageCreateFromJpeg returns a gdImagePtr to the new image, or
769
NULL if unable to load the image (most often because the file
770
is corrupt or does not contain a JPEG image).
771
gdImageCreateFromPng does _not_ close the file. You can inspect
772
the sx and sy members of the image to determine its size. The
773
image must eventually be destroyed using gdImageDestroy().
777
... inside a function ...
779
in = fopen("myjpeg.jpg", "rb");
780
im = gdImageCreateFromJpeg(in);
782
/* ... Use the image ... */
785
gdImageCreateFromPng(FILE *in) _(FUNCTION)_
786
gdImageCreateFromPngCtx(gdIOCtx *in) _(FUNCTION)_
789
gdImageCreateFromPng is called to load images from PNG format
790
files. Invoke gdImageCreateFromPng with an already opened
791
pointer to a file containing the desired image.
792
gdImageCreateFromPng returns a gdImagePtr to the new image, or
793
NULL if unable to load the image (most often because the file
794
is corrupt or does not contain a PNG image).
795
gdImageCreateFromPng does _not_ close the file. You can inspect
796
the sx and sy members of the image to determine its size. The
797
image must eventually be destroyed using gdImageDestroy().
801
... inside a function ...
803
in = fopen("mypng.png", "rb");
804
im = gdImageCreateFromPng(in);
806
/* ... Use the image ... */
809
gdImageCreateFromPngSource(gdSourcePtr in) _(FUNCTION)_
810
gdImageCreateFromPngSource is called to load a PNG from a data
811
source other than a file. Usage is very similar to the
812
gdImageCreateFromPng function, except that the programmer
813
provides a custom data source.
815
The programmer must write an input function which accepts a
816
context pointer, a buffer, and a number of bytes to be read as
817
arguments. This function must read the number of bytes
818
requested, unless the end of the file has been reached, in
819
which case the function should return zero, or an error has
820
occurred, in which case the function should return -1. The
821
programmer then creates a gdSource structure and sets the
822
source pointer to the input function and the context pointer to
823
any value which is useful to the programmer.
825
The example below implements gdImageCreateFromPng by creating a
826
custom data source and invoking gdImageCreateFromPngSource.
829
static int freadWrapper(void *context, char *buf, int len);
831
gdImagePtr gdImageCreateFromPng(FILE *in)
834
s.source = freadWrapper;
836
return gdImageCreateFromPngSource(&s);
839
static int freadWrapper(void *context, char *buf, int len)
841
int got = fread(buf, 1, len, (FILE *) context);
845
gdImageCreateFromGd(FILE *in) _(FUNCTION)_
846
gdImageCreateFromGdCtx(gdIOCtx *in) _(FUNCTION)_
849
gdImageCreateFromGd is called to load images from gd format
850
files. Invoke gdImageCreateFromGd with an already opened
851
pointer to a file containing the desired image in the gd file
852
format, which is specific to gd and intended for very fast
853
loading. (It is _not_ intended for compression; for
854
compression, use PNG or JPEG.) gdImageCreateFromGd returns a
855
gdImagePtr to the new image, or NULL if unable to load the
856
image (most often because the file is corrupt or does not
857
contain a gd format image). gdImageCreateFromGd does _not_
858
close the file. You can inspect the sx and sy members of the
859
image to determine its size. The image must eventually be
860
destroyed using gdImageDestroy().
863
... inside a function ...
866
in = fopen("mygd.gd", "rb");
867
im = gdImageCreateFromGd(in);
869
/* ... Use the image ... */
872
gdImageCreateFromGd2(FILE *in) _(FUNCTION)_
873
gdImageCreateFromGd2Ctx(gdIOCtx *in) _(FUNCTION)_
876
gdImageCreateFromGd2 is called to load images from gd2 format
877
files. Invoke gdImageCreateFromGd2 with an already opened
878
pointer to a file containing the desired image in the gd2 file
879
format, which is specific to gd2 and intended for fast loading
880
of parts of large images. (It is a compressed format, but
881
generally not as good a LZW compression). gdImageCreateFromGd
882
returns a gdImagePtr to the new image, or NULL if unable to
883
load the image (most often because the file is corrupt or does
884
not contain a gd format image). gdImageCreateFromGd2 does _not_
885
close the file. You can inspect the sx and sy members of the
886
image to determine its size. The image must eventually be
887
destroyed using gdImageDestroy().
890
... inside a function ...
893
in = fopen("mygd.gd2", "rb");
894
im = gdImageCreateFromGd2(in);
896
/* ... Use the image ... */
899
gdImageCreateFromGd2Part(FILE *in, int srcX, int srcY, int w, int h)
901
gdImageCreateFromGd2PartCtx(gdIOCtx *in) _(FUNCTION)_
904
gdImageCreateFromGd2Part is called to load parts of images from
905
gd2 format files. Invoked in the same way as
906
gdImageCreateFromGd2, but with extra parameters indicating the
907
source (x, y) and width/height of the desired image.
908
gdImageCreateFromGd2Part returns a gdImagePtr to the new image,
909
or NULL if unable to load the image. The image must eventually
910
be destroyed using gdImageDestroy().
912
gdImageCreateFromXbm(FILE *in) _(FUNCTION)_
913
gdImageCreateFromXbm is called to load images from X bitmap
914
format files. Invoke gdImageCreateFromXbm with an already
915
opened pointer to a file containing the desired image.
916
gdImageCreateFromXbm returns a gdImagePtr to the new image, or
917
NULL if unable to load the image (most often because the file
918
is corrupt or does not contain an X bitmap format image).
919
gdImageCreateFromXbm does _not_ close the file. You can inspect
920
the sx and sy members of the image to determine its size. The
921
image must eventually be destroyed using gdImageDestroy().
924
... inside a function ...
927
in = fopen("myxbm.xbm", "rb");
928
im = gdImageCreateFromXbm(in);
930
/* ... Use the image ... */
933
gdImageCreateFromXpm(char *filename) _(FUNCTION)_
934
gdImageCreateFromXbm is called to load images from XPM X Window
935
System color bitmap format files. This function is available
936
only if HAVE_XPM is selected in the Makefile and the Xpm
937
library is linked with the application. Unlike most gd file
938
functions, the Xpm functions require filenames, not file
939
pointers. gdImageCreateFromXpm returns a gdImagePtr to the new
940
image, or NULL if unable to load the image (most often because
941
the file is corrupt or does not contain an XPM bitmap format
942
image). You can inspect the sx and sy members of the image to
943
determine its size. The image must eventually be destroyed
944
using gdImageDestroy().
947
... inside a function ...
950
in = fopen("myxpm.xpm", "rb");
951
im = gdImageCreateFromXpm(in);
953
/* ... Use the image ... */
956
gdImageDestroy(gdImagePtr im) _(FUNCTION)_
957
gdImageDestroy is used to free the memory associated with an
958
image. It is important to invoke gdImageDestroy before exiting
959
your program or assigning a new image to a gdImagePtr variable.
962
... inside a function ...
964
im = gdImageCreate(10, 10);
965
/* ... Use the image ... */
969
void gdImageJpeg(gdImagePtr im, FILE *out, int quality) _(FUNCTION)_
970
void gdImageJpegCtx(gdImagePtr im, gdIOCtx *out, int quality)
974
gdImageJpeg outputs the specified image to the specified file in JPEG
975
format. The file must be open for writing. Under MSDOS and all
976
versions of Windows, it is important to use "wb" as opposed to simply
977
"w" as the mode when opening the file, and under Unix there is no
978
penalty for doing so. gdImageJpeg does _not_ close the file; your code
981
If quality is negative, the default IJG JPEG quality value (which
982
should yield a good general quality / size tradeoff for most
983
situations) is used. Otherwise, for practical purposes, quality should
984
be a value in the range 0-95, higher quality values usually implying
985
both higher quality and larger image sizes.
987
If you have set image interlacing using gdImageInterlace, this
988
function will interpret that to mean you wish to output a progressive
989
JPEG. Some programs (e.g., Web browsers) can display progressive JPEGs
990
incrementally; this can be useful when browsing over a relatively slow
991
communications link, for example. Progressive JPEGs can also be
992
slightly smaller than sequential (non-progressive) JPEGs.
994
... inside a function ...
998
/* Create the image */
999
im = gdImageCreate(100, 100);
1000
/* Allocate background */
1001
white = gdImageColorAllocate(im, 255, 255, 255);
1002
/* Allocate drawing color */
1003
black = gdImageColorAllocate(im, 0, 0, 0);
1004
/* Draw rectangle */
1005
gdImageRectangle(im, 0, 0, 99, 99, black);
1006
/* Open output file in binary mode */
1007
out = fopen("rect.jpg", "wb");
1008
/* Write JPEG using default quality */
1009
gdImageJpeg(im, out, -1);
1015
void* gdImageJpegPtr(gdImagePtr im, int *size) _(FUNCTION)_
1016
Identical to gdImageJpeg except that it returns a pointer to a memory
1017
area with the JPEG data. This memory must be freed by the caller when
1018
it is no longer needed. The 'size' parameter receives the total size
1019
of the block of memory.
1021
void gdImagePng(gdImagePtr im, FILE *out) _(FUNCTION)_
1022
gdImagePng outputs the specified image to the specified file in PNG
1023
format. The file must be open for writing. Under MSDOS and all
1024
versions of Windows, it is important to use "wb" as opposed to simply
1025
"w" as the mode when opening the file, and under Unix there is no
1026
penalty for doing so. gdImagePng does _not_ close the file; your code
1029
... inside a function ...
1033
/* Create the image */
1034
im = gdImageCreate(100, 100);
1035
/* Allocate background */
1036
white = gdImageColorAllocate(im, 255, 255, 255);
1037
/* Allocate drawing color */
1038
black = gdImageColorAllocate(im, 0, 0, 0);
1039
/* Draw rectangle */
1040
gdImageRectangle(im, 0, 0, 99, 99, black);
1041
/* Open output file in binary mode */
1042
out = fopen("rect.png", "wb");
1044
gdImagePng(im, out);
1050
void* gdImagePngPtr(gdImagePtr im, int *size) _(FUNCTION)_
1051
Identical to gdImagePng except that it returns a pointer to a memory
1052
area with the PNG data. This memory must be freed by the caller when
1053
it is no longer needed. The 'size' parameter receives the total size
1054
of the block of memory.
1056
gdImagePngToSink(gdImagePtr im, gdSinkPtr out) _(FUNCTION)_
1057
gdImagePngToSink is called to write a PNG to a data "sink"
1058
(destination) other than a file. Usage is very similar to the
1059
gdImagePng function, except that the programmer provides a custom data
1062
The programmer must write an output function which accepts a context
1063
pointer, a buffer, and a number of bytes to be written as arguments.
1064
This function must write the number of bytes requested and return that
1065
number, unless an error has occurred, in which case the function
1066
should return -1. The programmer then creates a gdSink structure and
1067
sets the sink pointer to the output function and the context pointer
1068
to any value which is useful to the programmer.
1070
The example below implements gdImagePng by creating a custom data
1071
source and invoking gdImagePngFromSink.
1073
static int stdioSink(void *context, char *buffer, int len)
1075
return fwrite(buffer, 1, len, (FILE *) context);
1078
void gdImagePng(gdImagePtr im, FILE *out)
1081
mySink.context = (void *) out;
1082
mySink.sink = stdioSink;
1083
gdImagePngToSink(im, &mySink);
1086
void gdImageWBMP(gdImagePtr im, int fg, FILE *out)
1087
gdImageWBMPCtx(gdIOCtx *out) _(FUNCTION)__(FUNCTION)_
1088
gdImageWBMP outputs the specified image to the specified file in WBMP
1089
format. The file must be open for writing. Under MSDOS and all
1090
versions of Windows, it is important to use "wb" as opposed to simply
1091
"w" as the mode when opening the file, and under Unix there is no
1092
penalty for doing so. gdImageWBMP does _not_ close the file; your code
1095
_WBMP file support is black and white only. The color index specified
1096
by the fg argument is the "foreground," and only pixels of this color
1097
will be set in the WBMP file._ All other pixels will be considered
1100
... inside a function ...
1104
/* Create the image */
1105
im = gdImageCreate(100, 100);
1106
/* Allocate background */
1107
white = gdImageColorAllocate(im, 255, 255, 255);
1108
/* Allocate drawing color */
1109
black = gdImageColorAllocate(im, 0, 0, 0);
1110
/* Draw rectangle */
1111
gdImageRectangle(im, 0, 0, 99, 99, black);
1112
/* Open output file in binary mode */
1113
out = fopen("rect.wbmp", "wb");
1114
/* Write WBMP, with black as foreground */
1115
gdImageWBMP(im, black, out);
1121
void* gdImageWBMPPtr(gdImagePtr im, int *size) _(FUNCTION)_
1122
Identical to gdImageWBMP except that it returns a pointer to a memory
1123
area with the WBMP data. This memory must be freed by the caller when
1124
it is no longer needed. The 'size' parameter receives the total size
1125
of the block of memory.
1127
void gdImageGd(gdImagePtr im, FILE *out) _(FUNCTION)_
1128
gdImageGd outputs the specified image to the specified file in the gd
1129
image format. The file must be open for writing. Under MSDOS and all
1130
versions of Windows, it is important to use "wb" as opposed to simply
1131
"w" as the mode when opening the file, and under Unix there is no
1132
penalty for doing so. gdImagePng does _not_ close the file; your code
1135
The gd image format is intended for fast reads and writes of images
1136
your program will need frequently to build other images. It is _not_ a
1137
compressed format, and is not intended for general use.
1139
... inside a function ...
1143
/* Create the image */
1144
im = gdImageCreate(100, 100);
1145
/* Allocate background */
1146
white = gdImageColorAllocate(im, 255, 255, 255);
1147
/* Allocate drawing color */
1148
black = gdImageColorAllocate(im, 0, 0, 0);
1149
/* Draw rectangle */
1150
gdImageRectangle(im, 0, 0, 99, 99, black);
1151
/* Open output file in binary mode */
1152
out = fopen("rect.gd", "wb");
1153
/* Write gd format file */
1160
void* gdImageGdPtr(gdImagePtr im, int *size) _(FUNCTION)_
1161
Identical to gdImageGd except that it returns a pointer to a memory
1162
area with the GD data. This memory must be freed by the caller when it
1163
is no longer needed. The 'size' parameter receives the total size of
1164
the block of memory.
1166
void gdImageGd2(gdImagePtr im, FILE *out, int chunkSize, int fmt)
1168
gdImageGd2 outputs the specified image to the specified file in the
1169
gd2 image format. The file must be open for writing. Under MSDOS and
1170
all versions of Windows, it is important to use "wb" as opposed to
1171
simply "w" as the mode when opening the file, and under Unix there is
1172
no penalty for doing so. gdImageGd2 does _not_ close the file; your
1175
The gd2 image format is intended for fast reads and writes of parts of
1176
images. It is a compressed format, and well suited to retrieving smll
1177
sections of much larger images. The third and fourth parameters are
1178
the 'chunk size' and format resposectively.
1180
The file is stored as a series of compressed subimages, and the _Chunk
1181
Size_ determines the sub-image size - a value of zero causes the GD
1182
library to use the default.
1184
It is also possible to store GD2 files in an uncompressed format, in
1185
which case the fourth parameter should be GD2_FMT_RAW.
1187
... inside a function ...
1191
/* Create the image */
1192
im = gdImageCreate(100, 100);
1193
/* Allocate background */
1194
white = gdImageColorAllocate(im, 255, 255, 255);
1195
/* Allocate drawing color */
1196
black = gdImageColorAllocate(im, 0, 0, 0);
1197
/* Draw rectangle */
1198
gdImageRectangle(im, 0, 0, 99, 99, black);
1199
/* Open output file in binary mode */
1200
out = fopen("rect.gd", "wb");
1201
/* Write gd2 format file */
1202
gdImageGd2(im, out, 0, GD2_FMT_COMPRESSED);
1208
void* gdImageGd2Ptr(gdImagePtr im, int chunkSize, int fmt, int *size)
1210
Identical to gdImageGd2 except that it returns a pointer to a memory
1211
area with the GD2 data. This memory must be freed by the caller when
1212
it is no longer needed. The 'size' parameter receives the total size
1213
of the block of memory.
1217
void gdImageSetPixel(gdImagePtr im, int x, int y, int color)
1219
gdImageSetPixel sets a pixel to a particular color index.
1220
Always use this function or one of the other drawing functions
1221
to access pixels; do not access the pixels of the gdImage
1225
... inside a function ...
1229
im = gdImageCreate(100, 100);
1230
/* Background color (first allocated) */
1231
black = gdImageColorAllocate(im, 0, 0, 0);
1232
/* Allocate the color white (red, green and blue all maximum). */
1233
white = gdImageColorAllocate(im, 255, 255, 255);
1234
/* Set a pixel near the center. */
1235
gdImageSetPixel(im, 50, 50, white);
1236
/* ... Do something with the image, such as saving it to a file... */
1240
void gdImageLine(gdImagePtr im, int x1, int y1, int x2, int y2, int
1242
gdImageLine is used to draw a line between two endpoints (x1,y1
1243
and x2, y2). The line is drawn using the color index specified.
1244
Note that the color index can be an actual color returned by
1245
gdImageColorAllocate or one of gdStyled, gdBrushed or
1249
... inside a function ...
1253
im = gdImageCreate(100, 100);
1254
/* Background color (first allocated) */
1255
black = gdImageColorAllocate(im, 0, 0, 0);
1256
/* Allocate the color white (red, green and blue all maximum). */
1257
white = gdImageColorAllocate(im, 255, 255, 255);
1258
/* Draw a line from the upper left corner to the lower right corner. */
1259
gdImageLine(im, 0, 0, 99, 99, white);
1260
/* ... Do something with the image, such as saving it to a file... */
1264
void gdImageDashedLine(gdImagePtr im, int x1, int y1, int x2, int y2,
1265
int color) _(FUNCTION)_
1266
gdImageDashedLine is provided _solely for backwards
1267
compatibility _with gd 1.0. New programs should draw dashed
1268
lines using the normal gdImageLine function and the new
1269
gdImageSetStyle function.
1271
gdImageDashedLine is used to draw a dashed line between two
1272
endpoints (x1,y1 and x2, y2). The line is drawn using the color
1273
index specified. The portions of the line that are not drawn
1274
are left transparent so the background is visible.
1277
... inside a function ...
1281
im = gdImageCreate(100, 100);
1282
/* Background color (first allocated) */
1283
black = gdImageColorAllocate(im, 0, 0, 0);
1284
/* Allocate the color white (red, green and blue all maximum). */
1285
white = gdImageColorAllocate(im, 255, 255, 255);
1286
/* Draw a dashed line from the upper left corner to the lower right corner. */
1287
gdImageDashedLine(im, 0, 0, 99, 99);
1288
/* ... Do something with the image, such as saving it to a file... */
1292
void gdImagePolygon(gdImagePtr im, gdPointPtr points, int pointsTotal,
1293
int color) _(FUNCTION)_
1294
gdImagePolygon is used to draw a polygon with the verticies (at
1295
least 3) specified, using the color index specified. See also
1296
gdImageFilledPolygon.
1299
... inside a function ...
1303
/* Points of polygon */
1305
im = gdImageCreate(100, 100);
1306
/* Background color (first allocated) */
1307
black = gdImageColorAllocate(im, 0, 0, 0);
1308
/* Allocate the color white (red, green and blue all maximum). */
1309
white = gdImageColorAllocate(im, 255, 255, 255);
1310
/* Draw a triangle. */
1317
gdImagePolygon(im, points, 3, white);
1318
/* ... Do something with the image, such as saving it to a file... */
1322
void gdImageRectangle(gdImagePtr im, int x1, int y1, int x2, int y2,
1323
int color) _(FUNCTION)_
1324
gdImageRectangle is used to draw a rectangle with the two
1325
corners (upper left first, then lower right) specified, using
1326
the color index specified.
1329
... inside a function ...
1333
im = gdImageCreate(100, 100);
1334
/* Background color (first allocated) */
1335
black = gdImageColorAllocate(im, 0, 0, 0);
1336
/* Allocate the color white (red, green and blue all maximum). */
1337
white = gdImageColorAllocate(im, 255, 255, 255);
1338
/* Draw a rectangle occupying the central area. */
1339
gdImageRectangle(im, 25, 25, 74, 74, white);
1340
/* ... Do something with the image, such as saving it to a file... */
1344
void gdImageFilledPolygon(gdImagePtr im, gdPointPtr points, int
1345
pointsTotal, int color) _(FUNCTION)_
1346
gdImageFilledPolygon is used to fill a polygon with the
1347
verticies (at least 3) specified, using the color index
1348
specified. See also gdImagePolygon.
1351
... inside a function ...
1356
/* Points of polygon */
1358
im = gdImageCreate(100, 100);
1359
/* Background color (first allocated) */
1360
black = gdImageColorAllocate(im, 0, 0, 0);
1361
/* Allocate the color white (red, green and blue all maximum). */
1362
white = gdImageColorAllocate(im, 255, 255, 255);
1363
/* Allocate the color red. */
1364
red = gdImageColorAllocate(im, 255, 0, 0);
1365
/* Draw a triangle. */
1372
/* Paint it in white */
1373
gdImageFilledPolygon(im, points, 3, white);
1374
/* Outline it in red; must be done second */
1375
gdImagePolygon(im, points, 3, red);
1376
/* ... Do something with the image, such as saving it to a file... */
1380
void gdImageFilledRectangle(gdImagePtr im, int x1, int y1, int x2, int
1381
y2, int color) _(FUNCTION)_
1382
gdImageFilledRectangle is used to draw a solid rectangle with
1383
the two corners (upper left first, then lower right) specified,
1384
using the color index specified.
1387
... inside a function ...
1391
im = gdImageCreate(100, 100);
1392
/* Background color (first allocated) */
1393
black = gdImageColorAllocate(im, 0, 0, 0);
1394
/* Allocate the color white (red, green and blue all maximum). */
1395
white = int gdImageColorAllocate(im, 255, 255, 255);
1396
/* Draw a filled rectangle occupying the central area. */
1397
gdImageFilledRectangle(im, 25, 25, 74, 74, white);
1398
/* ... Do something with the image, such as saving it to a file... */
1402
void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s,
1403
int e, int color) _(FUNCTION)_
1404
gdImageArc is used to draw a partial ellipse centered at the
1405
given point, with the specified width and height in pixels. The
1406
arc begins at the position in degrees specified by s and ends
1407
at the position specified by e. The arc is drawn in the color
1408
specified by the last argument. A circle can be drawn by
1409
beginning from 0 degrees and ending at 360 degrees, with width
1410
and height being equal. e must be greater than s. Values
1411
greater than 360 are interpreted modulo 360.
1414
... inside a function ...
1418
im = gdImageCreate(100, 50);
1419
/* Background color (first allocated) */
1420
black = gdImageColorAllocate(im, 0, 0, 0);
1421
/* Allocate the color white (red, green and blue all maximum). */
1422
white = gdImageColorAllocate(im, 255, 255, 255);
1423
/* Inscribe an ellipse in the image. */
1424
gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
1425
/* ... Do something with the image, such as saving it to a file... */
1429
void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int
1431
gdImageFillToBorder floods a portion of the image with the
1432
specified color, beginning at the specified point and stopping
1433
at the specified border color. For a way of flooding an area
1434
defined by the color of the starting point, see gdImageFill.
1436
The border color _cannot_ be a special color such as gdTiled;
1437
it must be a proper solid color. The fill color can be,
1440
Note that gdImageFillToBorder is recursive. It is not the most
1441
naive implementation possible, and the implementation is
1442
expected to improve, but there will always be degenerate cases
1443
in which the stack can become very deep. This can be a problem
1444
in MSDOS and MS Windows 3.1 environments. (Of course, in a Unix
1445
or Windows 95/98/NT environment with a proper stack, this is
1446
not a problem at all.)
1449
... inside a function ...
1454
im = gdImageCreate(100, 50);
1455
/* Background color (first allocated) */
1456
black = gdImageColorAllocate(im, 0, 0, 0);
1457
/* Allocate the color white (red, green and blue all maximum). */
1458
white = gdImageColorAllocate(im, 255, 255, 255);
1459
/* Allocate the color red. */
1460
red = gdImageColorAllocate(im, 255, 0, 0);
1461
/* Inscribe an ellipse in the image. */
1462
gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
1463
/* Flood-fill the ellipse. Fill color is red, border color is
1465
gdImageFillToBorder(im, 50, 50, white, red);
1466
/* ... Do something with the image, such as saving it to a file... */
1470
void gdImageFill(gdImagePtr im, int x, int y, int color) _(FUNCTION)_
1471
gdImageFill floods a portion of the image with the specified
1472
color, beginning at the specified point and flooding the
1473
surrounding region of the same color as the starting point. For
1474
a way of flooding a region defined by a specific border color
1475
rather than by its interior color, see gdImageFillToBorder.
1477
The fill color can be gdTiled, resulting in a tile fill using
1478
another image as the tile. However, the tile image cannot be
1479
transparent. If the image you wish to fill with has a
1480
transparent color index, call gdImageTransparent on the tile
1481
image and set the transparent color index to -1 to turn off its
1484
Note that gdImageFill is recursive. It is not the most naive
1485
implementation possible, and the implementation is expected to
1486
improve, but there will always be degenerate cases in which the
1487
stack can become very deep. This can be a problem in MSDOS and
1488
MS Windows environments. (Of course, in a Unix or Windows
1489
95/98/NT environment with a proper stack, this is not a problem
1493
... inside a function ...
1498
im = gdImageCreate(100, 50);
1499
/* Background color (first allocated) */
1500
black = gdImageColorAllocate(im, 0, 0, 0);
1501
/* Allocate the color white (red, green and blue all maximum). */
1502
white = gdImageColorAllocate(im, 255, 255, 255);
1503
/* Allocate the color red. */
1504
red = gdImageColorAllocate(im, 255, 0, 0);
1505
/* Inscribe an ellipse in the image. */
1506
gdImageArc(im, 50, 25, 98, 48, 0, 360, white);
1507
/* Flood-fill the ellipse. Fill color is red, and will replace the
1508
black interior of the ellipse. */
1509
gdImageFill(im, 50, 50, red);
1510
/* ... Do something with the image, such as saving it to a file... */
1514
void gdImageSetBrush(gdImagePtr im, gdImagePtr brush) _(FUNCTION)_
1515
A "brush" is an image used to draw wide, shaped strokes in
1516
another image. Just as a paintbrush is not a single point, a
1517
brush image need not be a single pixel. _Any_ gd image can be
1518
used as a brush, and by setting the transparent color index of
1519
the brush image with gdImageColorTransparent, a brush of any
1520
shape can be created. All line-drawing functions, such as
1521
gdImageLine and gdImagePolygon, will use the current brush if
1522
the special "color" gdBrushed or gdStyledBrushed is used when
1525
gdImageSetBrush is used to specify the brush to be used in a
1526
particular image. You can set any image to be the brush. If the
1527
brush image does not have the same color map as the first
1528
image, any colors missing from the first image will be
1529
allocated. If not enough colors can be allocated, the closest
1530
colors already available will be used. This allows arbitrary
1531
PNGs to be used as brush images. It also means, however, that
1532
you should not set a brush unless you will actually use it; if
1533
you set a rapid succession of different brush images, you can
1534
quickly fill your color map, and the results will not be
1537
You need not take any special action when you are finished with
1538
a brush. As for any other image, if you will not be using the
1539
brush image for any further purpose, you should call
1540
gdImageDestroy. You must not use the color gdBrushed if the
1541
current brush has been destroyed; you can of course set a new
1542
brush to replace it.
1545
... inside a function ...
1546
gdImagePtr im, brush;
1549
im = gdImageCreate(100, 100);
1550
/* Open the brush PNG. For best results, portions of the
1551
brush that should be transparent (ie, not part of the
1552
brush shape) should have the transparent color index. */
1553
in = fopen("star.png", "rb");
1554
brush = gdImageCreateFromPng(in);
1555
/* Background color (first allocated) */
1556
black = gdImageColorAllocate(im, 0, 0, 0);
1557
gdImageSetBrush(im, brush);
1558
/* Draw a line from the upper left corner to the lower right corner
1560
gdImageLine(im, 0, 0, 99, 99, gdBrushed);
1561
/* ... Do something with the image, such as saving it to a file... */
1564
/* Destroy the brush image */
1565
gdImageDestroy(brush);
1567
void gdImageSetTile(gdImagePtr im, gdImagePtr tile) _(FUNCTION)_
1568
A "tile" is an image used to fill an area with a repeated
1569
pattern. _Any_ gd image can be used as a tile, and by setting
1570
the transparent color index of the tile image with
1571
gdImageColorTransparent, a tile that allows certain parts of
1572
the underlying area to shine through can be created. All
1573
region-filling functions, such as gdImageFill and
1574
gdImageFilledPolygon, will use the current tile if the special
1575
"color" gdTiled is used when calling them.
1577
gdImageSetTile is used to specify the tile to be used in a
1578
particular image. You can set any image to be the tile. If the
1579
tile image does not have the same color map as the first image,
1580
any colors missing from the first image will be allocated. If
1581
not enough colors can be allocated, the closest colors already
1582
available will be used. This allows arbitrary PNGs to be used
1583
as tile images. It also means, however, that you should not set
1584
a tile unless you will actually use it; if you set a rapid
1585
succession of different tile images, you can quickly fill your
1586
color map, and the results will not be optimal.
1588
You need not take any special action when you are finished with
1589
a tile. As for any other image, if you will not be using the
1590
tile image for any further purpose, you should call
1591
gdImageDestroy. You must not use the color gdTiled if the
1592
current tile has been destroyed; you can of course set a new
1596
... inside a function ...
1597
gdImagePtr im, tile;
1600
im = gdImageCreate(100, 100);
1601
/* Open the tile PNG. For best results, portions of the
1602
tile that should be transparent (ie, allowing the
1603
background to shine through) should have the transparent
1605
in = fopen("star.png", "rb");
1606
tile = gdImageCreateFromPng(in);
1607
/* Background color (first allocated) */
1608
black = gdImageColorAllocate(im, 0, 0, 0);
1609
gdImageSetTile(im, tile);
1610
/* Fill an area using the tile. */
1611
gdImageFilledRectangle(im, 25, 25, 75, 75, gdTiled);
1612
/* ... Do something with the image, such as saving it to a file... */
1615
/* Destroy the tile image */
1616
gdImageDestroy(tile);
1618
void gdImageSetStyle(gdImagePtr im, int *style, int styleLength)
1620
It is often desirable to draw dashed lines, dotted lines, and
1621
other variations on a broken line. gdImageSetStyle can be used
1622
to set any desired series of colors, including a special color
1623
that leaves the background intact, to be repeated during the
1626
To use gdImageSetStyle, create an array of integers and assign
1627
them the desired series of color values to be repeated. You can
1628
assign the special color value gdTransparent to indicate that
1629
the existing color should be left unchanged for that particular
1630
pixel (allowing a dashed line to be attractively drawn over an
1633
Then, to draw a line using the style, use the normal
1634
gdImageLine function with the special color value gdStyled.
1636
As of version 1.1.1, the style array is copied when you set the
1637
style, so you need not be concerned with keeping the array
1638
around indefinitely. This should not break existing code that
1639
assumes styles are not copied.
1641
You can also combine styles and brushes to draw the brush image
1642
at intervals instead of in a continuous stroke. When creating a
1643
style for use with a brush, the style values are interpreted
1644
differently: zero (0) indicates pixels at which the brush
1645
should not be drawn, while one (1) indicates pixels at which
1646
the brush should be drawn. To draw a styled, brushed line, you
1647
must use the special color value gdStyledBrushed. For an
1648
example of this feature in use, see gddemo.c (provided in the
1653
int styleDotted[2], styleDashed[6];
1657
im = gdImageCreate(100, 100);
1658
/* Background color (first allocated) */
1659
black = gdImageColorAllocate(im, 0, 0, 0);
1660
red = gdImageColorAllocate(im, 255, 0, 0);
1661
/* Set up dotted style. Leave every other pixel alone. */
1662
styleDotted[0] = red;
1663
styleDotted[1] = gdTransparent;
1664
/* Set up dashed style. Three on, three off. */
1665
styleDashed[0] = red;
1666
styleDashed[1] = red;
1667
styleDashed[2] = red;
1668
styleDashed[3] = gdTransparent;
1669
styleDashed[4] = gdTransparent;
1670
styleDashed[5] = gdTransparent;
1671
/* Set dotted style. Note that we have to specify how many pixels are
1673
gdImageSetStyle(im, styleDotted, 2);
1674
/* Draw a line from the upper left corner to the lower right corner. */
1675
gdImageLine(im, 0, 0, 99, 99, gdStyled);
1676
/* Now the dashed line. */
1677
gdImageSetStyle(im, styleDashed, 6);
1678
gdImageLine(im, 0, 99, 0, 99, gdStyled);
1680
/* ... Do something with the image, such as saving it to a file ... */
1687
int gdImageBlue(gdImagePtr im, int color) _(MACRO)_
1688
gdImageBlue is a macro which returns the blue component
1689
of the specified color index. Use this macro rather than
1690
accessing the structure members directly.
1692
int gdImageGetPixel(gdImagePtr im, int x, int y) _(FUNCTION)_
1693
gdImageGetPixel() retrieves the color index of a
1694
particular pixel. Always use this function to query
1695
pixels; do not access the pixels of the gdImage structure
1699
... inside a function ...
1703
in = fopen("mypng.png", "rb");
1704
im = gdImageCreateFromPng(in);
1706
c = gdImageGetPixel(im, gdImageSX(im) / 2, gdImageSY(im) / 2);
1707
printf("The value of the center pixel is %d; RGB values are %d,%d,%d\n",
1708
c, im->red[c], im->green[c], im->blue[c]);
1711
int gdImageBoundsSafe(gdImagePtr im, int x, int y) _(FUNCTION)_
1712
gdImageBoundsSafe returns true (1) if the specified point
1713
is within the bounds of the image, false (0) if not. This
1714
function is intended primarily for use by those who wish
1715
to add functions to gd. All of the gd drawing functions
1716
already clip safely to the edges of the image.
1719
... inside a function ...
1723
im = gdImageCreate(100, 100);
1724
if (gdImageBoundsSafe(im, 50, 50)) {
1725
printf("50, 50 is within the image bounds\n");
1727
printf("50, 50 is outside the image bounds\n");
1731
int gdImageGreen(gdImagePtr im, int color) _(MACRO)_
1732
gdImageGreen is a macro which returns the green component
1733
of the specified color index. Use this macro rather than
1734
accessing the structure members directly.
1736
int gdImageRed(gdImagePtr im, int color) _(MACRO)_
1737
gdImageRed is a macro which returns the red component of
1738
the specified color index. Use this macro rather than
1739
accessing the structure members directly.
1741
int gdImageSX(gdImagePtr im) _(MACRO)_
1742
gdImageSX is a macro which returns the width of the image
1743
in pixels. Use this macro rather than accessing the
1744
structure members directly.
1746
int gdImageSY(gdImagePtr im) _(MACRO)_
1747
gdImageSY is a macro which returns the height of the
1748
image in pixels. Use this macro rather than accessing the
1749
structure members directly.
1751
Fonts and text-handling functions
1753
void gdImageChar(gdImagePtr im, gdFontPtr font, int x, int y, int
1754
c, int color) _(FUNCTION)_
1755
gdImageChar is used to draw single characters on the
1756
image. (To draw multiple characters, use gdImageString or
1757
gdImageString16. See also gdImageStringTTF, new with
1758
gd-1.6.2.) The second argument is a pointer to a font
1759
definition structure; five fonts are provided with gd,
1760
gdFontTiny, gdFontSmall, gdFontMediumBold, gdFontLarge,
1761
and gdFontGiant. You must include the files "gdfontt.h",
1762
"gdfonts.h", "gdfontmb.h", "gdfontl.h" and "gdfontg.h"
1763
respectively and (if you are not using a library-based
1764
approach) link with the corresponding .c files to use the
1765
provided fonts. The character specified by the fifth
1766
argument is drawn from left to right in the specified
1767
color. (See gdImageCharUp for a way of drawing vertical
1768
text.) Pixels not set by a particular character retain
1769
their previous color.
1773
#include "gdfontl.h"
1774
... inside a function ...
1778
im = gdImageCreate(100, 100);
1779
/* Background color (first allocated) */
1780
black = gdImageColorAllocate(im, 0, 0, 0);
1781
/* Allocate the color white (red, green and blue all maximum). */
1782
white = gdImageColorAllocate(im, 255, 255, 255);
1783
/* Draw a character. */
1784
gdImageChar(im, gdFontLarge, 0, 0, 'Q', white);
1785
/* ... Do something with the image, such as saving it to a file... */
1789
void gdImageCharUp(gdImagePtr im, gdFontPtr font, int x, int y,
1790
int c, int color) _(FUNCTION)_
1791
gdImageCharUp is used to draw single characters on the
1792
image, rotated 90 degrees. (To draw multiple characters,
1793
use gdImageStringUp or gdImageStringUp16.) The second
1794
argument is a pointer to a font definition structure;
1795
five fonts are provided with gd, gdFontTiny, gdFontSmall,
1796
gdFontMediumBold, gdFontLarge, and gdFontGiant. You must
1797
include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
1798
"gdfontl.h" and "gdfontg.h" respectively and (if you are
1799
not using a library-based approach) link with the
1800
corresponding .c files to use the provided fonts. The
1801
character specified by the fifth argument is drawn from
1802
bottom to top, rotated at a 90-degree angle, in the
1803
specified color. (See gdImageChar for a way of drawing
1804
horizontal text.) Pixels not set by a particular
1805
character retain their previous color.
1809
#include "gdfontl.h"
1810
... inside a function ...
1814
im = gdImageCreate(100, 100);
1815
/* Background color (first allocated) */
1816
black = gdImageColorAllocate(im, 0, 0, 0);
1817
/* Allocate the color white (red, green and blue all maximum). */
1818
white = gdImageColorAllocate(im, 255, 255, 255);
1819
/* Draw a character upwards so it rests against the top of the image. */
1820
gdImageCharUp(im, gdFontLarge,
1821
0, gdFontLarge->h, 'Q', white);
1822
/* ... Do something with the image, such as saving it to a file... */
1826
void gdImageString(gdImagePtr im, gdFontPtr font, int x, int y,
1827
unsigned char *s, int color) _(FUNCTION)_
1828
gdImageString is used to draw multiple characters on the
1829
image. (To draw single characters, use gdImageChar.) The
1830
second argument is a pointer to a font definition
1831
structure; five fonts are provided with gd, gdFontTiny,
1832
gdFontSmall, gdFontMediumBold, gdFontLarge, and
1833
gdFontGiant. You must include the files "gdfontt.h",
1834
"gdfonts.h", "gdfontmb.h", "gdfontl.h" and "gdfontg.h"
1835
respectively and (if you are not using a library-based
1836
approach) link with the corresponding .c files to use the
1837
provided fonts. The null-terminated C string specified by
1838
the fifth argument is drawn from left to right in the
1839
specified color. (See gdImageStringUp for a way of
1840
drawing vertical text. See also gdImageStringTTF, new
1841
with gd-1.6.2.) Pixels not set by a particular character
1842
retain their previous color.
1846
#include "gdfontl.h"
1848
... inside a function ...
1852
/* String to draw. */
1854
im = gdImageCreate(100, 100);
1855
/* Background color (first allocated) */
1856
black = gdImageColorAllocate(im, 0, 0, 0);
1857
/* Allocate the color white (red, green and blue all maximum). */
1858
white = gdImageColorAllocate(im, 255, 255, 255);
1859
/* Draw a centered string. */
1860
gdImageString(im, gdFontLarge,
1861
im->w / 2 - (strlen(s) * gdFontLarge->w / 2),
1862
im->h / 2 - gdFontLarge->h / 2,
1864
/* ... Do something with the image, such as saving it to a file... */
1868
void gdImageString16(gdImagePtr im, gdFontPtr font, int x, int y,
1869
unsigned short *s, int color) _(FUNCTION)_
1870
gdImageString is used to draw multiple 16-bit characters
1871
on the image. (To draw single characters, use
1872
gdImageChar.) The second argument is a pointer to a font
1873
definition structure; five fonts are provided with gd,
1874
gdFontTiny, gdFontSmall, gdFontMediumBold, gdFontLarge,
1875
and gdFontGiant. You must include the files "gdfontt.h",
1876
"gdfonts.h", "gdfontmb.h", "gdfontl.h" and "gdfontg.h"
1877
respectively and (if you are not using a library-based
1878
approach) link with the corresponding .c files to use the
1879
provided fonts. The null-terminated string of characters
1880
represented as 16-bit unsigned short integers specified
1881
by the fifth argument is drawn from left to right in the
1882
specified color. (See gdImageStringUp16 for a way of
1883
drawing vertical text.) Pixels not set by a particular
1884
character retain their previous color.
1886
This function was added in gd1.3 to provide a means of
1887
rendering fonts with more than 256 characters for those
1888
who have them. A more frequently used routine is
1891
void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y,
1892
unsigned char *s, int color) _(FUNCTION)_
1893
gdImageStringUp is used to draw multiple characters on
1894
the image, rotated 90 degrees. (To draw single
1895
characters, use gdImageCharUp.) The second argument is a
1896
pointer to a font definition structure; five fonts are
1897
provided with gd, gdFontTiny, gdFontSmall,
1898
gdFontMediumBold, gdFontLarge, and gdFontGiant. You must
1899
include the files "gdfontt.h", "gdfonts.h", "gdfontmb.h",
1900
"gdfontl.h" and "gdfontg.h" respectively and (if you are
1901
not using a library-based approach) link with the
1902
corresponding .c files to use the provided fonts.The
1903
null-terminated C string specified by the fifth argument
1904
is drawn from bottom to top (rotated 90 degrees) in the
1905
specified color. (See gdImageString for a way of drawing
1906
horizontal text.) Pixels not set by a particular
1907
character retain their previous color.
1911
#include "gdfontl.h"
1913
... inside a function ...
1917
/* String to draw. */
1919
im = gdImageCreate(100, 100);
1920
/* Background color (first allocated) */
1921
black = gdImageColorAllocate(im, 0, 0, 0);
1922
/* Allocate the color white (red, green and blue all maximum). */
1923
white = gdImageColorAllocate(im, 255, 255, 255);
1924
/* Draw a centered string going upwards. Axes are reversed,
1925
and Y axis is decreasing as the string is drawn. */
1926
gdImageStringUp(im, gdFontLarge,
1927
im->w / 2 - gdFontLarge->h / 2,
1928
im->h / 2 + (strlen(s) * gdFontLarge->w / 2),
1930
/* ... Do something with the image, such as saving it to a file... */
1934
void gdImageStringUp16(gdImagePtr im, gdFontPtr font, int x, int
1935
y, unsigned short *s, int color) _(FUNCTION)_
1936
gdImageString is used to draw multiple 16-bit characters
1937
vertically on the image. (To draw single characters, use
1938
gdImageChar.) The second argument is a pointer to a font
1939
definition structure; five fonts are provided with gd,
1940
gdFontTiny, gdFontSmall, gdFontMediumBold, gdFontLarge,
1941
and gdFontGiant. You must include the files "gdfontt.h",
1942
"gdfonts.h", "gdfontmb.h", "gdfontl.h" and "gdfontg.h"
1943
respectively and (if you are not using a library-based
1944
approach) link with the corresponding .c files to use the
1945
provided fonts. The null-terminated string of characters
1946
represented as 16-bit unsigned short integers specified
1947
by the fifth argument is drawn from bottom to top in the
1948
specified color. (See gdImageStringUp16 for a way of
1949
drawing horizontal text.) Pixels not set by a particular
1950
character retain their previous color.
1952
This function was added in gd1.3 to provide a means of
1953
rendering fonts with more than 256 characters for those
1954
who have them. A more frequently used routine is
1957
char *gdImageStringTTF(gdImagePtr im, int *brect, int fg, char
1958
*fontname, double ptsize, double angle, int x, int y,
1959
char *string) _(FUNCTION)_
1960
gdImageStringTTF is draws a string of anti-aliased
1961
characters on the image using the FreeType library to
1962
print from user-supplied TrueType fonts. _We do not
1963
provide TrueType fonts. Obtaining them is entirely up to
1964
you._ The string is anti-aliased, meaning that there
1965
should be less "jaggies." The fontname is the full
1966
pathname to a TrueType font file. The string may be
1967
arbitrarily scaled (ptsize) and rotated (angle in
1970
The user-supplied int brect[8] array is filled on return
1971
from gdImageStringTTF with the 8 elements representing
1972
the 4 corner coordinates of the bounding rectangle.
1973
0 lower left corner, X position
1974
lower left corner, Y position
1975
lower right corner, X position
1976
3 lower right corner, Y position
1977
4 upper right corner, X position
1978
5 upper right corner, Y position
1979
6 upper left corner, X position
1980
7 upper left corner, Y position
1982
The points are relative to the text regardless of the
1983
angle, so "upper left" means in the top left-hand corner
1984
seeing the text horizontally.
1986
Use a NULL gdImagePtr to get the bounding rectangle
1987
without rendering. This is a relatively cheap operation
1988
if followed by a rendering of the same string, because of
1989
the caching of the partial rendering during bounding
1990
rectangle calculation.
1992
The string is rendered in the color indicated by the gf
1993
color index. Use the negative of the desired color index
1994
to disable anti-aliasing.
1996
The string may contain UTF-8 sequences like: "À"
1998
gdImageStringTTF will return a null char* on success, or
1999
an error string on failure.
2004
... inside a function ...
2012
char *s = "Hello."; /* String to draw. */
2014
char *f = "/usr/local/share/ttf/Times.ttf"; /* User supplied font */
2016
/* obtain brect so that we can size the image */
2017
err = gdImageStringTTF(NULL,&brect[0],0,f,sz,0.,0,0,s);
2018
if (err) {fprintf(stderr,err); return 1;}
2020
/* create an image big enough for the string plus a little whitespace */
2021
x = brect[2]-brect[6] + 6;
2022
y = brect[3]-brect[7] + 6;
2023
im = gdImageCreate(x,y);
2025
/* Background color (first allocated) */
2026
white = gdImageColorResolve(im, 255, 255, 255);
2027
black = gdImageColorResolve(im, 0, 0, 0);
2029
/* render the string, offset origin to center string*/
2030
/* note that we use top-left coordinate for adjustment
2031
* since gd origin is in top-left with y increasing downwards. */
2034
err = gdImageStringTTF(im,&brect[0],black,f,sz,0.0,x,y,s);
2035
if (err) {fprintf(stderr,err); return 1;}
2037
/* Write img to stdout */
2038
gdImagePng(im, stdout);
2043
Color-handling functions
2045
int gdImageColorAllocate(gdImagePtr im, int r, int g, int b)
2047
gdImageColorAllocate finds the first available color
2048
index in the image specified, sets its RGB values to
2049
those requested (255 is the maximum for each), and
2050
returns the index of the new color table entry. When
2051
creating a new image, the first time you invoke this
2052
function, you are setting the background color for that
2055
In the event that all gdMaxColors colors (256) have
2056
already been allocated, gdImageColorAllocate will return
2057
-1 to indicate failure. (This is not uncommon when
2058
working with existing PNG files that already use 256
2059
colors.) Note that gdImageColorAllocate does not check
2060
for existing colors that match your request; see
2061
gdImageColorExact, gdImageColorClosest and
2062
gdImageColorClosestHWB for ways to locate existing colors
2063
that approximate the color desired in situations where a
2064
new color is not available. Also see gdImageColorResolve,
2068
... inside a function ...
2072
im = gdImageCreate(100, 100);
2073
/* Background color (first allocated) */
2074
black = gdImageColorAllocate(im, 0, 0, 0);
2075
/* Allocate the color red. */
2076
red = gdImageColorAllocate(im, 255, 0, 0);
2077
/* Draw a dashed line from the upper left corner to the lower right corner. */
2078
gdImageDashedLine(im, 0, 0, 99, 99, red);
2079
/* ... Do something with the image, such as saving it to a file... */
2083
int gdImageColorClosest(gdImagePtr im, int r, int g, int b)
2085
gdImageColorClosest searches the colors which have been
2086
defined thus far in the image specified and returns the
2087
index of the color with RGB values closest to those of
2088
the request. (Closeness is determined by Euclidian
2089
distance, which is used to determine the distance in
2090
three-dimensional color space between colors.)
2092
If no colors have yet been allocated in the image,
2093
gdImageColorClosest returns -1.
2095
This function is most useful as a backup method for
2096
choosing a drawing color when an image already contains
2097
gdMaxColors (256) colors and no more can be allocated.
2098
(This is not uncommon when working with existing PNG
2099
files that already use many colors.) See
2100
gdImageColorExact for a method of locating exact matches
2104
... inside a function ...
2108
/* Let's suppose that photo.png is a scanned photograph with
2110
in = fopen("photo.png", "rb");
2111
im = gdImageCreateFromPng(in);
2113
/* Try to allocate red directly */
2114
red = gdImageColorAllocate(im, 255, 0, 0);
2115
/* If we fail to allocate red... */
2117
/* Find the _closest_ color instead. */
2118
red = gdImageColorClosest(im, 255, 0, 0);
2120
/* Draw a dashed line from the upper left corner to the lower right corner */
2121
gdImageDashedLine(im, 0, 0, 99, 99, red);
2122
/* ... Do something with the image, such as saving it to a file... */
2126
int gdImageColorClosestHWB(gdImagePtr im, int r, int g, int b)
2128
gdImageColorClosestHWB searches the colors which have
2129
been defined thus far in the image specified and returns
2130
the index of the color with hue, whiteness and blackness
2131
closest to the requested color. This scheme is typically
2132
superior to the Euclidian distance scheme used by
2133
gdImageColorClosest.
2135
If no colors have yet been allocated in the image,
2136
gdImageColorClosestHWB returns -1.
2138
This function is most useful as a backup method for
2139
choosing a drawing color when an image already contains
2140
gdMaxColors (256) colors and no more can be allocated.
2141
(This is not uncommon when working with existing PNG
2142
files that already use many colors.) See
2143
gdImageColorExact for a method of locating exact matches
2147
... inside a function ...
2151
/* Let's suppose that photo.png is a scanned photograph with
2153
in = fopen("photo.png", "rb");
2154
im = gdImageCreateFromPng(in);
2156
/* Try to allocate red directly */
2157
red = gdImageColorAllocate(im, 255, 0, 0);
2158
/* If we fail to allocate red... */
2160
/* Find the _closest_ color instead. */
2161
red = gdImageColorClosestHWB(im, 255, 0, 0);
2163
/* Draw a dashed line from the upper left corner to the lower right corner */
2164
gdImageDashedLine(im, 0, 0, 99, 99, red);
2165
/* ... Do something with the image, such as saving it to a file... */
2169
int gdImageColorExact(gdImagePtr im, int r, int g, int b)
2171
gdImageColorExact searches the colors which have been
2172
defined thus far in the image specified and returns the
2173
index of the first color with RGB values which exactly
2174
match those of the request. If no allocated color matches
2175
the request precisely, gdImageColorExact returns -1. See
2176
gdImageColorClosest for a way to find the color closest
2177
to the color requested.
2180
... inside a function ...
2183
in = fopen("photo.png", "rb");
2184
im = gdImageCreateFromPng(in);
2186
/* The image may already contain red; if it does, we'll save a slot
2187
in the color table by using that color. */
2188
/* Try to allocate red directly */
2189
red = gdImageColorExact(im, 255, 0, 0);
2190
/* If red isn't already present... */
2192
/* Second best: try to allocate it directly. */
2193
red = gdImageColorAllocate(im, 255, 0, 0);
2194
/* Out of colors, so find the _closest_ color instead. */
2195
red = gdImageColorClosest(im, 255, 0, 0);
2197
/* Draw a dashed line from the upper left corner to the lower right corner */
2198
gdImageDashedLine(im, 0, 0, 99, 99, red);
2199
/* ... Do something with the image, such as saving it to a file... */
2203
int gdImageColorResolve(gdImagePtr im, int r, int g, int b)
2205
gdImageColorResolve searches the colors which have been
2206
defined thus far in the image specified and returns the
2207
index of the first color with RGB values which exactly
2208
match those of the request. If no allocated color matches
2209
the request precisely, then gdImageColorResolve tries to
2210
allocate the exact color. If there is no space left in
2211
the color table then gdImageColorResolve returns the
2212
closest color (as in gdImageColorClosest). This function
2213
always returns an index of a color.
2216
... inside a function ...
2219
in = fopen("photo.png", "rb");
2220
im = gdImageCreateFromPng(in);
2222
/* The image may already contain red; if it does, we'll save a slot
2223
in the color table by using that color. */
2224
/* Get index of red, or color closest to red */
2225
red = gdImageColorResolve(im, 255, 0, 0);
2226
/* Draw a dashed line from the upper left corner to the lower right corner */
2227
gdImageDashedLine(im, 0, 0, 99, 99, red);
2228
/* ... Do something with the image, such as saving it to a file... */
2232
int gdImageColorsTotal(gdImagePtr im) _(MACRO)_
2233
gdImageColorsTotal is a macro which returns the number of
2234
colors currently allocated in the image. Use this macro
2235
to obtain this information; do not access the structure
2238
int gdImageColorRed(gdImagePtr im, int c) _(MACRO)_
2239
gdImageColorRed is a macro which returns the red portion
2240
of the specified color in the image. Use this macro to
2241
obtain this information; do not access the structure
2244
int gdImageColorGreen(gdImagePtr im, int c) _(MACRO)_
2245
gdImageColorGreen is a macro which returns the green
2246
portion of the specified color in the image. Use this
2247
macro to obtain this information; do not access the
2250
int gdImageColorBlue(gdImagePtr im, int c) _(MACRO)_
2251
gdImageColorBlue is a macro which returns the green
2252
portion of the specified color in the image. Use this
2253
macro to obtain this information; do not access the
2256
int gdImageGetInterlaced(gdImagePtr im) _(MACRO)_
2257
gdImageGetInterlaced is a macro which returns true (1) if
2258
the image is interlaced, false (0) if not. Use this macro
2259
to obtain this information; do not access the structure
2260
directly. See gdImageInterlace for a means of interlacing
2263
int gdImageGetTransparent(gdImagePtr im) _(MACRO)_
2264
gdImageGetTransparent is a macro which returns the
2265
current transparent color index in the image. If there is
2266
no transparent color, gdImageGetTransparent returns -1.
2267
Use this macro to obtain this information; do not access
2268
the structure directly.
2270
void gdImageColorDeallocate(gdImagePtr im, int color) _(FUNCTION)_
2272
gdImageColorDeallocate marks the specified color as being
2273
available for reuse. It does not attempt to determine
2274
whether the color index is still in use in the image.
2275
After a call to this function, the next call to
2276
gdImageColorAllocate for the same image will set new RGB
2277
values for that color index, changing the color of any
2278
pixels which have that index as a result. If multiple
2279
calls to gdImageColorDeallocate are made consecutively,
2280
the lowest-numbered index among them will be reused by
2281
the next gdImageColorAllocate call.
2284
... inside a function ...
2287
in = fopen("photo.png", "rb");
2288
im = gdImageCreateFromPng(in);
2290
/* Look for red in the color table. */
2291
red = gdImageColorExact(im, 255, 0, 0);
2292
/* If red is present... */
2294
/* Deallocate it. */
2295
gdImageColorDeallocate(im, red);
2296
/* Allocate blue, reusing slot in table.
2297
Existing red pixels will change color. */
2298
blue = gdImageColorAllocate(im, 0, 0, 255);
2300
/* ... Do something with the image, such as saving it to a file... */
2304
void gdImageColorTransparent(gdImagePtr im, int color)
2306
gdImageColorTransparent sets the transparent color index
2307
for the specified image to the specified index. To
2308
indicate that there should be _no_ transparent color,
2309
invoke gdImageColorTransparent with a color index of -1.
2310
Note that JPEG images do not support transparency, so
2311
this setting has no effect when writing JPEG images.
2313
The color index used should be an index allocated by
2314
gdImageColorAllocate, whether explicitly invoked by your
2315
code or implicitly invoked by loading an image. In order
2316
to ensure that your image has a reasonable appearance
2317
when viewed by users who do not have transparent
2318
background capabilities (or when you are writing a
2319
JPEG-format file, which does not support transparency),
2320
be sure to give reasonable RGB values to the color you
2321
allocate for use as a transparent color, _even though it
2322
will be transparent on systems that support PNG
2326
... inside a function ...
2330
in = fopen("photo.png", "rb");
2331
im = gdImageCreateFromPng(in);
2333
/* Look for black in the color table and make it transparent. */
2334
black = gdImageColorExact(im, 0, 0, 0);
2335
/* If black is present... */
2336
if (black != (-1)) {
2337
/* Make it transparent */
2338
gdImageColorTransparent(im, black);
2340
/* Save the newly-transparent image back to the file */
2341
out = fopen("photo.png", "wb");
2342
gdImagePng(im, out);
2347
Copying and resizing functions
2349
void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int
2350
dstY, int srcX, int srcY, int w, int h) _(FUNCTION)_
2351
gdImageCopy is used to copy a rectangular portion of one
2352
image to another image. (For a way of stretching or
2353
shrinking the image in the process, see
2354
gdImageCopyResized.)
2356
The dst argument is the destination image to which the
2357
region will be copied. The src argument is the source
2358
image from which the region is copied. The dstX and dstY
2359
arguments specify the point in the destination image to
2360
which the region will be copied. The srcX and srcY
2361
arguments specify the upper left corner of the region in
2362
the source image. The w and h arguments specify the width
2363
and height of the region.
2365
When you copy a region from one location in an image to
2366
another location in the same image, gdImageCopy will
2367
perform as expected unless the regions overlap, in which
2368
case the result is unpredictable.
2370
_Important note on copying between images:_ since
2371
different images do not necessarily have the same color
2372
tables, pixels are not simply set to the same color index
2373
values to copy them. gdImageCopy will attempt to find an
2374
identical RGB value in the destination image for each
2375
pixel in the copied portion of the source image by
2376
invoking gdImageColorExact. If such a value is not found,
2377
gdImageCopy will attempt to allocate colors as needed
2378
using gdImageColorAllocate. If both of these methods
2379
fail, gdImageCopy will invoke gdImageColorClosest to find
2380
the color in the destination image which most closely
2381
approximates the color of the pixel being copied.
2384
... Inside a function ...
2390
/* Load a small png to tile the larger one with */
2391
in = fopen("small.png", "rb");
2392
im_in = gdImageCreateFromPng(in);
2394
/* Make the output image four times as large on both axes */
2395
im_out = gdImageCreate(im_in->sx * 4, im_in->sy * 4);
2396
/* Now tile the larger image using the smaller one */
2397
for (y = 0; (y < 4); y++) {
2398
for (x = 0; (x < 4); x++) {
2399
gdImageCopy(im_out, im_in,
2400
x * im_in->sx, y * im_in->sy,
2402
im_in->sx, im_in->sy);
2405
out = fopen("tiled.png", "wb");
2406
gdImagePng(im_out, out);
2408
gdImageDestroy(im_in);
2409
gdImageDestroy(im_out);
2411
void gdImageCopyResized(gdImagePtr dst, gdImagePtr src, int dstX,
2412
int dstY, int srcX, int srcY, int destW, int destH, int
2413
srcW, int srcH) _(FUNCTION)_
2414
gdImageCopyResized is used to copy a rectangular portion
2415
of one image to another image. The X and Y dimensions of
2416
the original region and the destination region can vary,
2417
resulting in stretching or shrinking of the region as
2418
appropriate. (For a simpler version of this function
2419
which does not deal with resizing, see gdImageCopy.)
2421
The dst argument is the destination image to which the
2422
region will be copied. The src argument is the source
2423
image from which the region is copied. The dstX and dstY
2424
arguments specify the point in the destination image to
2425
which the region will be copied. The srcX and srcY
2426
arguments specify the upper left corner of the region in
2427
the source image. The dstW and dstH arguments specify the
2428
width and height of the destination region. The srcW and
2429
srcH arguments specify the width and height of the source
2430
region and can differ from the destination size, allowing
2431
a region to be scaled during the copying process.
2433
When you copy a region from one location in an image to
2434
another location in the same image, gdImageCopy will
2435
perform as expected unless the regions overlap, in which
2436
case the result is unpredictable. If this presents a
2437
problem, create a scratch image in which to keep
2438
intermediate results.
2440
_Important note on copying between images:_ since images
2441
do not necessarily have the same color tables, pixels are
2442
not simply set to the same color index values to copy
2443
them. gdImageCopy will attempt to find an identical RGB
2444
value in the destination image for each pixel in the
2445
copied portion of the source image by invoking
2446
gdImageColorExact. If such a value is not found,
2447
gdImageCopy will attempt to allocate colors as needed
2448
using gdImageColorAllocate. If both of these methods
2449
fail, gdImageCopy will invoke gdImageColorClosest to find
2450
the color in the destination image which most closely
2451
approximates the color of the pixel being copied.
2454
... Inside a function ...
2460
/* Load a small png to expand in the larger one */
2461
in = fopen("small.png", "rb");
2462
im_in = gdImageCreateFromPng(in);
2464
/* Make the output image four times as large on both axes */
2465
im_out = gdImageCreate(im_in->sx * 4, im_in->sy * 4);
2466
/* Now copy the smaller image, but four times larger */
2467
gdImageCopyResized(im_out, im_in, 0, 0, 0, 0,
2468
im_out->sx, im_out->sy,
2469
im_in->sx, im_in->sy);
2470
out = fopen("large.png", "wb");
2471
gdImagePng(im_out, out);
2473
gdImageDestroy(im_in);
2474
gdImageDestroy(im_out);
2476
void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX,
2477
int dstY, int srcX, int srcY, int w, int h, int pct)
2479
gdImageCopyMerge is almost identical to gdImageCopy,
2480
except that it 'merges' the two images by an amount
2481
specified in the last parameter. If the last parameter is
2482
100, then it will function identically to gdImageCopy -
2483
the source image replaces the pixels in the destination.
2485
If, however, the _pct_ parameter is less than 100, then
2486
the two images are merged. With pct = 0, no action is
2489
This feature is most useful to 'highlight' sections of an
2490
image by merging a solid color with pct = 50:
2493
... Inside a function ...
2494
gdImageCopyMerge(im_out, im_in, 100, 200, 0, 0, 30, 50, 50);
2496
void gdImageCopyMergeGray(gdImagePtr dst, gdImagePtr src, int
2497
dstX, int dstY, int srcX, int srcY, int w, int h, int
2499
gdImageCopyMergeGray is almost identical to
2500
gdImageCopyMerge, except that when merging images it
2501
preserves the hue of the source by converting the
2502
destination pixels to grey scale before the copy
2506
... Inside a function ...
2507
gdImageCopyMergeGray(im_out, im_in, 100, 200, 0, 0, 30, 50, 50);
2509
void gdImagePaletteCopy(gdImagePtr dst, gdImagePtr src)
2511
Copies a palette from one image to another, attempting to
2512
match the colors in the target image to the colors in the
2515
Miscellaneous Functions
2517
int gdImageCompare(gdImagePtr im1, gdImagePtr im2)
2519
gdImageCompare returns a bitmap indicating if the
2520
two images are different. The members of the bitmap
2521
are defined in gd.h, but the most important is
2522
GD_CMP_IMAGE, which indicated that the images will
2523
actually appear different when displayed. Other,
2524
less important, differences relate to pallette
2525
entries. Any difference in the transparent colour
2526
is assumed to make images display differently, even
2527
if the transparent colour is not used.
2530
... Inside a function ...
2531
cmpMask = gdImageCompare(im1, im2);
2533
gdImageInterlace(gdImagePtr im, int interlace) _(FUNCTION)_
2535
gdImageInterlace is used to determine whether an
2536
image should be stored in a linear fashion, in
2537
which lines will appear on the display from first
2538
to last, or in an interlaced fashion, in which the
2539
image will "fade in" over several passes. By
2540
default, images are not interlaced. (When writing
2541
JPEG images, interlacing implies generating
2542
progressive JPEG files, which are represented as a
2543
series of scans of increasing quality.
2544
Noninterlaced gd images result in regular
2545
[sequential] JPEG data streams.)
2547
A nonzero value for the interlace argument turns on
2548
interlace; a zero value turns it off. Note that
2549
interlace has no effect on other functions, and has
2550
no meaning unless you save the image in PNG or JPEG
2551
format; the gd and xbm formats do not support
2554
When a PNG is loaded with gdImageCreateFromPng or a
2555
JPEG is loaded with gdImageCreateFromJpeg,
2556
interlace will be set according to the setting in
2557
the PNG or JPEG file.
2559
Note that many PNG and JPEG viewers and web
2560
browsers do _not_ support interlace or the
2561
incremental display of progressive JPEGs. However,
2562
the interlaced PNG or progressive JPEG should still
2563
display; it will simply appear all at once, just as
2569
/* ... Create or load the image... */
2571
/* Now turn on interlace */
2572
gdImageInterlace(im, 1);
2573
/* And open an output file */
2574
out = fopen("test.png", "wb");
2575
/* And save the image -- could also use gdImageJpeg */
2576
gdImagePng(im, out);
2582
gdBrushed _(CONSTANT)_
2583
Used in place of a color when invoking a
2584
line-drawing function such as gdImageLine or
2585
gdImageRectangle. When gdBrushed is used as
2586
the color, the brush image set with
2587
gdImageSetBrush is drawn in place of each
2588
pixel of the line (the brush is usually
2589
larger than one pixel, creating the effect of
2590
a wide paintbrush). See also gdStyledBrushed
2591
for a way to draw broken lines with a series
2592
of distinct copies of an image.
2594
gdMaxColors_(CONSTANT)_
2595
The constant 256. This is the maximum number
2596
of colors in a PNG file according to the PNG
2597
standard, and is also the maximum number of
2598
colors in a gd image.
2600
gdStyled _(CONSTANT)_
2601
Used in place of a color when invoking a
2602
line-drawing function such as gdImageLine or
2603
gdImageRectangle. When gdStyled is used as
2604
the color, the colors of the pixels are drawn
2605
successively from the style that has been set
2606
with gdImageSetStyle. If the color of a pixel
2607
is equal to gdTransparent, that pixel is not
2608
altered. (This mechanism is completely
2609
unrelated to the "transparent color" of the
2610
image itself; see gdImageColorTransparent
2611
gdImageColorTransparent for that mechanism.)
2612
See also gdStyledBrushed.
2614
gdStyledBrushed _(CONSTANT)_
2615
Used in place of a color when invoking a
2616
line-drawing function such as gdImageLine or
2617
gdImageRectangle. When gdStyledBrushed is
2618
used as the color, the brush image set with
2619
gdImageSetBrush is drawn at each pixel of the
2620
line, providing that the style set with
2621
gdImageSetStyle contains a nonzero value (OR
2622
gdTransparent, which does not equal zero but
2623
is supported for consistency) for the current
2624
pixel. (Pixels are drawn successively from
2625
the style as the line is drawn, returning to
2626
the beginning when the available pixels in
2627
the style are exhausted.) Note that this
2628
differs from the behavior of gdStyled, in
2629
which the values in the style are used as
2630
actual pixel colors, except for
2633
gdDashSize _(CONSTANT)_
2634
The length of a dash in a dashed line.
2635
Defined to be 4 for backwards compatibility
2636
with programs that use gdImageDashedLine. New
2637
programs should use gdImageSetStyle and call
2638
the standard gdImageLine function with the
2639
special "color" gdStyled or gdStyledBrushed.
2641
gdTiled _(CONSTANT)_
2642
Used in place of a normal color in
2643
gdImageFilledRectangle, gdImageFilledPolygon,
2644
gdImageFill, and gdImageFillToBorder. gdTiled
2645
selects a pixel from the tile image set with
2646
gdImageSetTile in such a way as to ensure
2647
that the filled area will be tiled with
2648
copies of the tile image. See the discussions
2649
of gdImageFill and gdImageFillToBorder for
2650
special restrictions regarding those
2653
gdTransparent _(CONSTANT)_
2654
Used in place of a normal color in a style to
2655
be set with gdImageSetStyle. gdTransparent is
2656
_not_ the transparent color index of the
2657
image; for that functionality please see
2658
gdImageColorTransparent.
2660
About the additional .gd image file format
2662
In addition to reading and writing the PNG
2663
and JPEG formats and reading the X Bitmap
2664
format, gd has the capability to read and
2665
write its own ".gd" format. This format is
2666
_not_ intended for general purpose use and
2667
should never be used to distribute images. It
2668
is not a compressed format. Its purpose is
2669
solely to allow very fast loading of images
2670
your program needs often in order to build
2671
other images for output. If you are
2672
experiencing performance problems when
2673
loading large, fixed PNG images your program
2674
needs to produce its output images, you may
2675
wish to examine the functions
2676
gdImageCreateFromGd and gdImageGd, which read
2677
and write .gd format images.
2679
The program "pngtogd.c" is provided as a
2680
simple way of converting .png files to .gd
2681
format. I emphasize again that you will not
2682
need to use this format unless you have a
2683
need for high-speed loading of a few
2684
frequently-used images in your program.
2686
About the .gd2 image file format
2688
In addition to reading and writing the PNG
2689
format and reading the X Bitmap format, gd
2690
has the capability to read and write its own
2691
".gd2" format. This format is _not_ intended
2692
for general purpose use and should never be
2693
used to distribute images. It is a compressed
2694
format allowing pseudo-random access to large
2695
image files. Its purpose is solely to allow
2696
very fast loading of _parts_ of images If you
2697
are experiencing performance problems when
2698
loading large, fixed PNG or JPEG images your
2699
program needs to produce its output images,
2700
you may wish to examine the functions
2701
gdImageCreateFromGd2,
2702
gdImageCreateFromGd2Part and gdImageGd2,
2703
which read and write .gd2 format images.
2705
The program "pngtogd2.c" is provided as a
2706
simple way of converting .png files to .gd2
2709
About the gdIOCtx structure
2711
Version 1.5 of GD added a new style of I/O
2712
based on an IOCtx structure (the most
2713
up-to-date version can be found in gd_io.h):
2716
typedef struct gdIOCtx {
2717
int (*getC)(struct gdIOCtx*);
2718
int (*getBuf)(struct gdIOCtx*, void*, int);
2720
void (*putC)(struct gdIOCtx*, int);
2721
int (*putBuf)(struct gdIOCtx*, const void*, int);
2723
int (*seek)(struct gdIOCtx*, const int);
2724
long (*tell)(struct gdIOCtx*);
2726
void (*free)(struct gdIOCtx*);
2730
Most functions that accepted files in previous
2731
versions now also have a counterpart that
2732
accepts an I/O context. These functions have
2735
The Ctx routines use the function pointers in
2736
the I/O context pointed to by gdIOCtx to
2737
perform all I/O. Examples of how to implement
2738
an I/O context can be found in io_file.c
2739
(which provides a wrapper for file routines),
2740
and io_dp.c (which implements in-memory
2743
It is not necessary to implement all
2744
functions in an I/O context if you know that
2745
it will only be used in limited
2746
cirsumstances. At the time of writing
2747
(Version 1.6.1, July 1999), the known
2750
All Must have 'free',
2751
Anything that reads from the context Must
2752
have 'getC' and 'getBuf',
2753
Anything that writes to the context Must have
2754
'putC' and 'putBuf'.
2755
If gdCreateFromGd2Part is called Must also
2756
have 'seek' and 'tell'.
2757
If gdImageGd2 is called Must also have 'seek'
2760
Please tell us you're using gd!
2762
When you contact us and let us know you are
2763
using gd, you help us justify the time spent
2764
in maintaining and improving it. So please
2765
let us know. If the results are publicly
2766
visible on the web, a URL is a wonderful
2767
thing to receive, but if it's not a publicly
2768
visible project, a simple note is just as
2771
If you have problems
2773
If you have any difficulties with gd, feel
2774
free to contact the author, Thomas Boutell.
2775
Problems relating to the gd2 format should be
2776
addressed to Philip Warner.
2778
_Be sure to read this manual carefully first.
2780
Alphabetical quick index
2782
gdBrushed | gdDashSize | gdFont | gdFontPtr |
2783
gdImage | gdImageArc | gdImageBlue |
2784
gdImageBoundsSafe | gdImageChar |
2785
gdImageCharUp | gdImageColorAllocate |
2786
gdImageColorClosest | gdImageColorDeallocate
2787
| gdImageColorExact | gdImageColorResolve |
2788
gdImageColorTransparent | gdImageCopy |
2789
gdImageCopyResized | gdImageCreate |
2790
gdImageCreateFromGd | gdImageCreateFromGd2 |
2791
gdImageCreateFromGd2Part |
2792
gdImageCreateFromJpeg | gdImageCreateFromPng
2793
| gdImageCreateFromPngSource |
2794
gdImageCreateFromXbm | gdImageCreateFromXpm |
2795
gdImageDashedLine | gdImageDestroy |
2796
gdImageFill | gdImageFillToBorder |
2797
gdImageFilledRectangle | gdImageGd |
2798
gdImageGd2 | gdImageGetInterlaced |
2799
gdImageGetPixel | gdImageGetTransparent |
2800
gdImageGreen | gdImageInterlace | gdImageJpeg
2801
| gdImageLine | gdImageFilledPolygon |
2802
gdImagePaletteCopy | gdImagePng |
2803
gdImagePngToSink | gdImagePolygon |
2804
gdImagePtr | gdImageWBMP | gdImageRectangle |
2805
gdImageRed | gdImageSetBrush |
2806
gdImageSetPixel | gdImageSetStyle |
2807
gdImageSetTile | gdImageString |
2808
gdImageString16 | gdImageStringTTF |
2809
gdImageStringUp | gdImageStringUp16 |
2810
gdImageWBMP | gdMaxColors | gdPoint |
2811
gdStyled | gdStyledBrushed | gdTiled |