summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/tests/bmp/bug00276.c
blob: dd5d5131202e307777b7d0c1a021a7f27023c8bb (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
/* See <https://github.com/libgd/libgd/issues/276> */


#include "gd.h"
#include "gdtest.h"


int main()
{
	gdImagePtr im_orig, im_saved;
	int white;
	void *data;
	int size;

	/* create an image */
	im_orig = gdImageCreate(10, 10);
	gdImageColorAllocate(im_orig, 0, 0, 0);
	white = gdImageColorAllocate(im_orig, 255, 255, 255);
	gdImageLine(im_orig, 0,0, 9,9, white);

	/* save the image, re-read it and compare it with the original */
	data = gdImageBmpPtr(im_orig, &size, 1);
	im_saved = gdImageCreateFromBmpPtr(size, data);
	gdTestAssert(im_saved != NULL);
	gdAssertImageEquals(im_orig, im_saved);

	/* clean up */
	gdImageDestroy(im_orig);
	gdImageDestroy(im_saved);

	gdFree(data);

	return gdNumFailures();
}