1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif /* HAVE_CONFIG_H */
4 
5 #include <stdio.h>
6 #include "gd.h"
7 
8 #define FALSE 0
9 #define TRUE (!FALSE)
10 
11 int
main(void)12 main(void)
13 {
14 	int transparent, green, black;
15 	gdImagePtr im;
16 
17 	im = gdImageCreateTrueColor(100,100);
18 
19 	black =  gdImageColorResolveAlpha(im, 0, 0, 0, gdAlphaOpaque);
20 	green =  gdImageColorResolveAlpha(im, 0, gdGreenMax, 0, gdAlphaOpaque);
21 	transparent = gdImageColorResolveAlpha(im,
22 					       gdRedMax-1, gdGreenMax, gdBlueMax, gdAlphaTransparent);
23 	gdImageColorTransparent(im, transparent);
24 
25 	/* Blending must be off to lay a transparent basecolor.
26 		    Nothing to blend with anyway. */
27 	gdImageAlphaBlending(im, FALSE);
28 	gdImageFill (im, im->sx/2, im->sy/2, transparent);
29 	/* Blend everything else together,
30 		especially fonts over non-transparent backgrounds */
31 	gdImageAlphaBlending(im, TRUE);
32 
33 	gdImageFilledRectangle (im, 30, 30, 70, 70, green);
34 	gdImageStringFT (im, NULL, black, "Times", 18, 0, 50, 50, "Hello");
35 
36 	gdImageSaveAlpha (im, TRUE);
37 #ifdef HAVE_LIBPNG
38 	{
39 		FILE *out = fopen("testtr.png", "wb");
40 		gdImagePng(im, out);
41 		fclose(out);
42 	}
43 #else
44 	fprintf(stderr, "Compiled without libpng support\n");
45 #endif /* HAVE_LIBPNG */
46 	gdImageDestroy (im);
47 
48 	return 0;
49 }
50