summaryrefslogtreecommitdiff
path: root/tests/gdimagestring/gdimagestring.c
blob: c4b4aa1e8981d96bac8ed0b8a99fbcf57882c804 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
 * Base test for gdImageString()
 */
#include <gd.h>
#include <gdfontl.h>
#include "gdtest.h"
#include <string.h>

int main()
{
	/* Declare the image */
	gdImagePtr im = NULL;
	char *s = "Hello gd";
	int foreground = 0;
	int error = 0;
	gdFontPtr fontptr = gdFontGetLarge();

	im = gdImageCreate(100, 50);
	gdImageColorAllocate(im, 202, 202, 0);
	foreground = gdImageColorAllocate(im, 22, 4, 238);

	gdImageString(im, fontptr,
			im->sx / 2 - (strlen(s) * fontptr->w / 2),
			im->sy / 2 - fontptr->h / 2,
			(unsigned char*)s, foreground);

	if (!gdAssertImageEqualsToFile("gdimagestring/gdimagestring_exp.png", im))
		error= 1;

	/* Destroy the image in memory. */
	gdImageDestroy(im);

	return error;
}