1 #include <stdio.h>
2 #include "gd.h"
3 #include "gdtest.h"
4 
main()5 int main() {
6 	/* Declare the image */
7 	gdImagePtr im, ref;
8 
9 	/* Declare output files */
10 	/* FILE *pngout; */
11 	int black, white;
12 
13 	/* If the data seg size is less than 195000,
14 	 * gdImageCrateTrueColor will return NULL.
15 	 * See https://github.com/libgd/libgd/issues/621 */
16 	im = gdImageCreateTrueColor(63318, 771);
17 	if (gdTestAssertMsg(im != NULL, "gdImageCreateTrueColor() returns NULL\n") == 0) {
18 		return gdNumFailures();
19 	}
20 
21 	/* Allocate the color white (red, green and blue all maximum). */
22 	white = gdImageColorAllocate(im, 255, 255, 255);
23 	/* Allocate the color white (red, green and blue all maximum). */
24 	black = gdImageColorAllocate(im, 0, 0, 0);
25 
26 	/* white background */
27 	gdImageFill(im, 1, 1, white);
28 
29     /* Make a reference copy. */
30     ref = gdImageClone(im);
31 
32 	gdImageSetAntiAliased(im, black);
33 
34 	/* This line used to fail. */
35 	gdImageLine(im, 28562, 631, 34266, 750, gdAntiAliased);
36 
37     gdTestAssert(gdMaxPixelDiff(im, ref) > 0);
38 
39 #if 0
40     {
41         FILE *pngout;
42 
43         /* Open a file for writing. "wb" means "write binary",
44          * important under MSDOS, harmless under Unix. */
45         pngout = fopen("test.png", "wb");
46 
47         /* Output the image to the disk file in PNG format. */
48         gdImagePng(im, pngout);
49 
50         /* Close the files. */
51         fclose(pngout);
52     }
53 #endif
54 
55 	/* Destroy the image in memory. */
56 	gdImageDestroy(im);
57     gdImageDestroy(ref);
58 
59     return gdNumFailures();
60 }
61