1 /**
2 * Base test for gdImageString()
3 */
4 #include <gd.h>
5 #include <gdfontl.h>
6 #include "gdtest.h"
7 #include <string.h>
8
main()9 int main()
10 {
11 /* Declare the image */
12 gdImagePtr im = NULL;
13 char *s = "Hello gd";
14 int foreground = 0;
15 int error = 0;
16 gdFontPtr fontptr = gdFontGetLarge();
17
18 im = gdImageCreate(100, 50);
19 gdImageColorAllocate(im, 202, 202, 0);
20 foreground = gdImageColorAllocate(im, 22, 4, 238);
21
22 gdImageString(im, fontptr,
23 im->sx / 2 - (strlen(s) * fontptr->w / 2),
24 im->sy / 2 - fontptr->h / 2,
25 (unsigned char*)s, foreground);
26
27 if (!gdAssertImageEqualsToFile("gdimagestring/gdimagestring_exp.png", im))
28 error= 1;
29
30 /* Destroy the image in memory. */
31 gdImageDestroy(im);
32
33 return error;
34 }
35