gd-libgd / 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);


	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");
		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");
		return 1;

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

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


	return 0;
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
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.