Commits

Ondřej Surý committed a421625

Add test from PHP bug #64898

Comments (2)

  1. Pierre Joye

    Thanks!

    Can you add it to php too if you got some spare mins? :-) (Yes, I should have done that too :)

    Also as of now, the expected image is wrong. I don't remember if I added a XFAIL to the tests tool, but this test fails right now on Linux (did not test with ICC or other Unices yet).

Files changed (4)

 	bmp/bmp_im2im \
 	gdimagescatterex/bug00208_1 \
 	gdimagescatterex/bug00208_2 \
-	gdimagefilltoborder/bug00037
+	gdimagefilltoborder/bug00037 \
+	gdinterpolation/php_bug_64898
 
 if HAVE_LIBXPM
 check_PROGRAMS += \
 	bmp/bmp_im2im \
 	gdimagescatterex/bug00208_1 \
 	gdimagescatterex/bug00208_2 \
-	gdimagefilltoborder/bug00037
+	gdimagefilltoborder/bug00037 \
+	gdinterpolation/php_bug_64898
 endif
 
 if HAVE_LIBTIFF
 	bmp/CMakeLists.txt \
 	gdimagescatterex/CMakeLists.txt \
 	gdimagefilltoborder/CMakeLists.txt \
-	freetype/CMakeLists.txt
+	freetype/CMakeLists.txt \
+	gdinterpolation/php_bug_64898.png \
+	gdinterpolation/php_bug_64898_exp.png
 
 CLEANFILES = \
 	a.png \

tests/gdinterpolation/php_bug_64898.c

+#include <stdio.h>
+#include <stdlib.h>
+#include "gd.h"
+
+#include "gdtest.h"
+
+int main()
+{
+	gdImagePtr im, exp;
+	char path[2048];
+	const char *file_im = "gdinterpolation/php_bug_64898.png";
+	const char *file_exp = "gdinterpolation/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 = gdImageCreateFromPng(fp);
+
+	fclose(fp);
+
+	if (!im) {
+		gdTestErrorMsg("loading %s failed.\n", path);
+		return 1;
+	}
+
+	color = gdImageColorAllocate(im, 255, 255, 255);
+
+	if (color < 0) {
+		gdTestErrorMsg("allocation color from image failed.\n");
+		gdFree(im);
+		return 1;
+	}
+
+/*	Try default interpolation method, but any non-optimized fails */
+/*	gdImageSetInterpolationMethod(im, GD_BICUBIC_FIXED); */
+
+	exp = gdImageRotateInterpolated(im, 45, color);
+
+	if (!exp) {
+		gdTestErrorMsg("rotating image failed.\n");
+		gdFree(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);
+		gdFree(im);
+		gdFree(exp);
+		return 1;
+	}
+
+	gdImageDestroy(exp);
+	gdImageDestroy(im);
+
+	gdFree(im);
+
+	return 0;
+}

tests/gdinterpolation/php_bug_64898.png

Added
New image

tests/gdinterpolation/php_bug_64898_exp.png

Added
New image