Debian Codegraph @

docs/naturaldocs/preamble.txt

raw
1 Title: About LibGD @VERSION@
2
3 What is gd?:
4
5 gd is a graphics library. It allows your code to quickly draw images
6 complete with lines, arcs, text, multiple colors, cut and paste from
7 other images, and flood fills, and write out the result as a PNG or
8 JPEG file. This is particularly useful in World Wide Web applications,
9 where PNG and JPEG are two of the formats accepted for inline images
10 by most browsers.
11
12 gd is not a paint program. If you are looking for a paint program, you
13 are looking in the wrong place. If you are not a programmer, you are
14 looking in the wrong place, unless you are installing a required
15 library in order to run an application.
16
17 gd does not provide for every possible desirable graphics
18 operation. It is not necessary or desirable for gd to become a
19 kitchen-sink graphics package, but version 2.0 does include most
20 frequently requested features, including both truecolor and palette
21 images, resampling (smooth resizing of truecolor images) and so forth.
22
23 gd basics: using gd in your program:
24
25 gd lets you create PNG or JPEG images on the fly. To use gd in your
26 program, include the file gd.h, and link with the gd library and the
27 other required libraries; the syntax for most Unix flavors is:
28
29 > -lgd -lpng -lz -ljpeg -lfreetype -lm
30
31 Assuming that all of these libraries are available.
32
33 If you want to use the provided simple fonts, include gdfontt.h,
34 gdfonts.h, gdfontmb.h, gdfontl.h and/or gdfontg.h. For more impressive
35 results, install FreeType 2.x and use the gdImageStringFT function. If
36 you are not using the provided Makefile and/or a library-based
37 approach, be sure to include the source modules as well in your
38 project.
39
40 Here is a short example program. (For a more advanced example, see
41 gddemo.c, included in the distribution. gddemo.c is NOT the same
42 program; it demonstrates additional features!)
43
44 >/* Bring in gd library functions */
45 >#include "gd.h"
46 >
47 >/* Bring in standard I/O so we can output the PNG to a file */
48 >#include <stdio.h>
49 >
50 >int main() {
51 > /* Declare the image */
52 > gdImagePtr im;
53 > /* Declare output files */
54 > FILE *pngout, *jpegout;
55 > /* Declare color indexes */
56 > int black;
57 > int white;
58 >
59 > /* Allocate the image: 64 pixels across by 64 pixels tall */
60 > im = gdImageCreate(64, 64);
61 >
62 > /* Allocate the color black (red, green and blue all minimum).
63 > Since this is the first color in a new image, it will
64 > be the background color. */
65 > black = gdImageColorAllocate(im, 0, 0, 0);
66 >
67 > /* Allocate the color white (red, green and blue all maximum). */
68 > white = gdImageColorAllocate(im, 255, 255, 255);
69 >
70 > /* Draw a line from the upper left to the lower right,
71 > using white color index. */
72 > gdImageLine(im, 0, 0, 63, 63, white);
73 >
74 > /* Open a file for writing. "wb" means "write binary", important
75 > under MSDOS, harmless under Unix. */
76 > pngout = fopen("test.png", "wb");
77 >
78 > /* Do the same for a JPEG-format file. */
79 > jpegout = fopen("test.jpg", "wb");
80 >
81 > /* Output the image to the disk file in PNG format. */
82 > gdImagePng(im, pngout);
83 >
84 > /* Output the same image in JPEG format, using the default
85 > JPEG quality setting. */
86 > gdImageJpeg(im, jpegout, -1);
87 >
88 > /* Close the files. */
89 > fclose(pngout);
90 > fclose(jpegout);
91 >
92 > /* Destroy the image in memory. */
93 > gdImageDestroy(im);
94 >}
95 >