summaryrefslogtreecommitdiff
path: root/Build/source/libs/gd/libgd-2.1.1/tests/gdimagerotate/php_bug_64898.c
blob: 9bbd98b53131dbba08aac594070c639b5d26295b (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
54
55
56
57
58
#include <stdio.h>
#include <stdlib.h>
#include "gd.h"

#include "gdtest.h"

int main()
{
	gdImagePtr im, exp;
	char path[2048];
	const char *file_im = "gdimagerotate/php_bug_64898.png";
	const char *file_exp = "gdimagerotate/php_bug_64898_exp.png";
	FILE *fp;
	int color;

	sprintf(path, "%s/%s", GDTEST_TOP_DIR, file_im);

	fp = fopen(path, "rb");

	if (!fp) {
		gdTestErrorMsg("opening PNG %s for reading failed.\n", path);
		return 1;
	}

	im = gdImageCreateTrueColor(141, 200);

	if (!im) {
		gdTestErrorMsg("loading %s failed.\n", path);
		return 1;
	}

	gdImageFilledRectangle(im, 0, 0, 140, 199, 0x00ffffff);

/*	Try default interpolation method, but any non-optimized fails */
/*	gdImageSetInterpolationMethod(im, GD_BICUBIC_FIXED); */

	exp = gdImageRotateInterpolated(im, 45, 0x0);

	if (!exp) {
		gdTestErrorMsg("rotating image failed.\n");
		gdImageDestroy(im);
		return 1;
	}

	sprintf(path, "%s/%s", GDTEST_TOP_DIR, file_exp);

	if (!gdAssertImageEqualsToFile(path, exp)) {
		printf("comparing rotated image to %s failed.\n", path);
		gdImageDestroy(im);
		gdImageDestroy(exp);
		return 1;
	}

	gdImageDestroy(exp);
	gdImageDestroy(im);

	return 0;
}