Ondřej Surý avatar Ondřej Surý committed b47e37d

Add another test for correct angle for gdImageRotateInterpolated

Comments (7)

  1. Ondřej Surý author

    The result is same with GD_BICUBIC_FIXED (and every image I have tested), so it's probably something at higher level.

    I just thought this is intentional and it needs some more calls to the API (since Remi already shown that in #67...)

  2. Ondřej Surý author

    I do test on Debian wheezy (current stable). I might also try (tomorrow) on squeeze (previous stable).

    I have a plenty of different chroots for building various packages for various distributions :).

Files changed (17)

 /tests/gdimagerotate/php_bug_64898
 /tests/php_bug_64898.c_55_diff.png
 /tests/php_bug_64898.c_55_out.png
+/tests/gdimagerotate/bug00067

tests/Makefile.am

 	gdimagescatterex/bug00208_1 \
 	gdimagescatterex/bug00208_2 \
 	gdimagefilltoborder/bug00037 \
-	gdimagerotate/php_bug_64898
+	gdimagerotate/php_bug_64898 \
+	gdimagerotate/bug00067
 
 if HAVE_LIBXPM
 check_PROGRAMS += \
 	gdimagescatterex/bug00208_1 \
 	gdimagescatterex/bug00208_2 \
 	gdimagefilltoborder/bug00037 \
-	gdimagerotate/php_bug_64898
+	gdimagerotate/php_bug_64898 \
+	gdimagerotate/bug00067
 endif
 
 if HAVE_LIBTIFF
 	gdimagefilltoborder/CMakeLists.txt \
 	freetype/CMakeLists.txt \
 	gdimagerotate/php_bug_64898.png \
-	gdimagerotate/php_bug_64898_exp.png
+	gdimagerotate/php_bug_64898_exp.png \
+	gdimagerotate/remirh128.jpg \
+	gdimagerotate/php_bug_64898_000_exp.png \
+	gdimagerotate/php_bug_64898_015_exp.png \
+	gdimagerotate/php_bug_64898_030_exp.png \
+	gdimagerotate/php_bug_64898_045_exp.png \
+	gdimagerotate/php_bug_64898_060_exp.png \
+	gdimagerotate/php_bug_64898_075_exp.png \
+	gdimagerotate/php_bug_64898_090_exp.png \
+	gdimagerotate/php_bug_64898_105_exp.png \
+	gdimagerotate/php_bug_64898_120_exp.png \
+	gdimagerotate/php_bug_64898_135_exp.png \
+	gdimagerotate/php_bug_64898_150_exp.png \
+	gdimagerotate/php_bug_64898_165_exp.png \
+	gdimagerotate/php_bug_64898_180_exp.png
 
 CLEANFILES = \
 	a.png \

tests/gdimagerotate/bug00067.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 = "gdimagerotate/remirh128.jpg";
+	const char *file_exp = "gdimagerotate/bug00067";
+	FILE *fp;
+	int color;
+
+	sprintf(path, "%s/%s", GDTEST_TOP_DIR, file_im);
+
+	fp = fopen(path, "rb");
+
+	if (!fp) {
+		gdTestErrorMsg("opening Jpeg %s for reading failed.\n", path);
+		return 1;
+	}
+
+	im = gdImageCreateFromJpeg(fp);
+
+	fclose(fp);
+
+	if (!im) {
+		gdTestErrorMsg("loading %s failed.\n", path);
+		return 1;
+	}
+
+	color = gdImageColorAllocate(im, 0, 0, 0);
+
+	if (color < 0) {
+		gdTestErrorMsg("allocation color from image failed.\n");
+		gdImageDestroy(im);
+		return 1;
+	}
+
+	int error = 0;
+
+	for (int angle = 0; angle <= 180; angle += 15) {
+
+		exp = gdImageRotateInterpolated(im, angle, color);
+
+		if (!exp) {
+			gdTestErrorMsg("rotating image failed.\n");
+			gdImageDestroy(im);
+			return 1;
+		}
+
+		sprintf(path, "%s/%s_%03d_exp.png", GDTEST_TOP_DIR, file_exp, angle);
+
+		if (!gdAssertImageEqualsToFile(path, exp)) {
+			gdTestErrorMsg("comparing rotated image to %s failed.\n", path);
+			error += 1;
+		}
+
+		gdImageDestroy(exp);
+	}
+
+	gdImageDestroy(im);
+
+	return error;
+}
Add a comment to this file

tests/gdimagerotate/bug00067_000_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_015_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_030_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_045_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_060_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_075_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_090_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_105_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_120_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_135_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_150_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_165_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/bug00067_180_exp.png

Added
New image
Add a comment to this file

tests/gdimagerotate/remirh128.jpg

Added
New image
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.