summaryrefslogtreecommitdiff
path: root/src/gifanimtest.c
blob: 28b7d27381b9802e45887063f4843d46694140e5 (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
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "gd.h"

int main(void)
{
	gdImagePtr im;
	gdImagePtr last, cim;
	int blue;
	FILE *out;
	int i;
	im = gdImageCreate(100, 100);
	blue = gdImageColorAllocate(im, 0, 0, 255);
	out = fopen("gifanim.gif", "wb");
	gdImageGifAnimBegin(im, out, 1, 10);
	last = 0;
	for (i = 0; (i <= 100); i += 2) {
		cim = gdImageCreate(100, 100);
		gdImagePaletteCopy(cim, im);
		gdImageArc(cim, 50, 50, i, i, 0, 360, blue);
		gdImageGifAnimAdd(cim, out, 0, 0, 0, 10, gdDisposalNone, last);
		if (last) {
			gdImageDestroy(last);
		}
		last = cim;
	}
	gdImageDestroy(last);
	gdImageGifAnimEnd(out);
	fclose(out);
	gdImageDestroy(im);
	return 0;
}