summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-src/tests/bmp/bug00275.c
blob: 710c084c8774faedd485042294c13f26944ead4a (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* See <https://github.com/libgd/libgd/issues/275>. */


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


#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif


/* define callbacks for a non-seekable fake IO context */

static void fakePutC(UNUSED gdIOCtx *ctx, UNUSED int c)
{
	// do nothing
}

static int fakePutBuf(UNUSED gdIOCtx *ctx, UNUSED const void *data, int wanted)
{
	return wanted;
}


int main()
{
	gdImagePtr im;
	int white;
	gdIOCtx ctx;

	/* initialize the fake IO context */
	ctx.getC = NULL;
	ctx.getBuf = NULL;
	ctx.putC = fakePutC;
	ctx.putBuf = fakePutBuf;
	ctx.seek = NULL;
	ctx.tell = NULL;
	ctx.gd_free = NULL;

	/* create an image */
	im = gdImageCreate(10, 10);
	gdImageColorAllocate(im, 0, 0, 0);
	white = gdImageColorAllocate(im, 255, 255, 255);
	gdImageLine(im, 2,2, 7,7, white);

	/* "save" the image as BMP */
	gdImageBmpCtx(im, &ctx, 2);

	return gdNumFailures();
}