int main() { gdImagePtr im; FILE *fp; char path[1024]; int error = 0; sprintf(path, "%s/gif/bug00066.gif", GDTEST_TOP_DIR); fp = fopen(path, "rb"); if (!fp) { printf("cannot open <%s>\n", path); return -1; } im = gdImageCreateFromGif(fp); fclose(fp); sprintf(path, "%s/gif/bug00066_exp.png", GDTEST_TOP_DIR); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; } gdImageDestroy(im); return error; }
int main() { gdImagePtr im, tile; int tile_red, tile_blue; int error = 0; char path[1024]; im = gdImageCreate(200, 150); tile = gdImageCreateTrueColor(2, 2); tile_red = gdImageColorAllocate(tile, 255, 0, 0); tile_blue = gdImageColorAllocate(tile, 0, 0, 255); gdImageSetPixel(tile, 0, 0, tile_red); gdImageSetPixel(tile, 1, 1, tile_red); gdImageSetPixel(tile, 1, 0, tile_blue); gdImageSetPixel(tile, 0, 1, tile_blue); gdImageSetTile(im, tile); gdImageFill(im, 11, 12, gdTiled); sprintf(path, "%s/gdimagefill/bug00104_1_exp.png", GDTEST_TOP_DIR); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; } gdImageDestroy(im); gdImageDestroy(tile); return error; }
int main(void) { gdImagePtr im; int white, black, r; gdPointPtr points; im = gdImageCreate(100, 100); if (!im) exit(EXIT_FAILURE); white = gdImageColorAllocate(im, 0xff, 0xff, 0xff); black = gdImageColorAllocate(im, 0, 0, 0); gdImageFilledRectangle(im, 0, 0, 99, 99, white); points = (gdPointPtr)gdCalloc(3, sizeof(gdPoint)); if (!points) { gdImageDestroy(im); exit(EXIT_FAILURE); } points[0].x = 10; points[0].y = 10; points[1].x = 50; points[1].y = 70; points[2].x = 90; points[2].y = 30; gdImagePolygon(im, points, 3, black); r = gdAssertImageEqualsToFile(GDTEST_TOP_DIR "/gdimagepolygon/gdimagepolygon3.png", im); gdFree(points); gdImageDestroy(im); if (!r) exit(EXIT_FAILURE); return EXIT_SUCCESS; }
int main() { int error; gdImagePtr im; FILE *fp; char path[1024]; sprintf(path, "%s/gd2/conv_test.gd2", GDTEST_TOP_DIR); fp = fopen(path, "rb"); if (!fp) { printf("failed, cannot open file\n"); return 1; } im = gdImageCreateFromGd2(fp); fclose(fp); sprintf(path, "%s/gd2/conv_test_exp.png", GDTEST_TOP_DIR); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; gdImageDestroy(im); } else { if (im) { gdImageDestroy(im); error = 0; } else { error = 1; } } return error; }
int main() { gdImagePtr im, im2; int error = 0; char path[2048]; const char *file_exp = "bug00111_exp.png"; im = gdImageCreateTrueColor(10, 10); if (!im) { printf("can't get truecolor image\n"); return 1; } gdImageLine(im, 2, 2, 2, 2, 0xFFFFFF); gdImageLine(im, 5, 5, 5, 5, 0xFFFFFF); gdImageLine(im, 0, 0, 0, 0, 0xFFFFFF); sprintf(path, "%s/gdimageline/%s", GDTEST_TOP_DIR, file_exp); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; printf("Reference image and destination differ\n"); } gdImageDestroy(im); return error; }
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; }
int main() { gdImagePtr im, tile; int im_white, im_black, tile_white, tile_black; int x,y, error = 0; FILE *fp; char path[1024]; fputs("flag 0\n", stdout); im = gdImageCreate(150, 150); tile = gdImageCreateTrueColor(36, 36); tile_white = gdImageColorAllocate(tile,255,255,255); tile_black = gdImageColorAllocate(tile,55,0,0); im_white = gdImageColorAllocate(im,255,255,255); im_black = gdImageColorAllocate(im,0,0,0); gdImageFill(tile, 0,0, tile_white); gdImageColorTransparent(tile, tile_black); gdImageColorTransparent(im, im_black); /* create the dots pattern */ for (x=0; x<36; x+=2) { for (y=0; y<36; y+=2) { gdImageSetPixel(tile,x,y,tile_black); } } gdImageSetTile(im,tile); gdImageRectangle(im, 9,9,139,139, im_black); gdImageLine(im, 9,9,139,139, im_black); gdImageFill(im, 11,12, gdTiled); fputs("flag 1\n", stdout); gdImageFill(im, 0, 0, 0xffffff); fputs("flag 2\n", stdout); gdImageFill(im, 0, 0, 0xffffff); fputs("flag 3\n", stdout); sprintf(path, "%s/gdimagefill/bug00002_3_exp.png", GDTEST_TOP_DIR); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; } /* Destroy it */ gdImageDestroy(im); return error; }
int main() { gdImagePtr im; int transparent, color; im = gdImageCreateTrueColor(100, 100); transparent = gdImageColorAllocateAlpha(im, 255, 255, 255, 80); gdImageFilledRectangle(im, 0,0, 99,99, transparent); color = gdImageColorAllocateAlpha(im, 0, 255, 0, 100); gdImageFilledArc(im, 49,49, 99,99, 0,360, color, gdPie); gdAssertImageEqualsToFile("gdimagefilledarc/php_bug43828_exp.png", im); gdImageDestroy(im); return gdNumFailures(); }
int main(void) { gdImagePtr im; int white, black, r; im = gdImageCreate(100, 100); if (!im) exit(EXIT_FAILURE); white = gdImageColorAllocate(im, 0xff, 0xff, 0xff); black = gdImageColorAllocate(im, 0, 0, 0); gdImageFilledRectangle(im, 0, 0, 99, 99, white); gdImageFilledPolygon(im, NULL, 0, black); /* no effect */ gdImageFilledPolygon(im, NULL, -1, black); /* no effect */ r = gdAssertImageEqualsToFile(GDTEST_TOP_DIR "/gdimagefilledpolygon/gdimagefilledpolygon0.png", im); gdImageDestroy(im); if (!r) exit(EXIT_FAILURE); return EXIT_SUCCESS; }
int main() { gdImagePtr im, tile; int im_black, tile_black; int x,y, error = 0; /* fputs("flag 0\n", stdout); */ im = gdImageCreate(150, 150); tile = gdImageCreate(36, 36); gdImageColorAllocate(tile,255,255,255); /* allocate white for background color */ tile_black = gdImageColorAllocate(tile,0,0,0); gdImageColorAllocate(im,255,255,255); /* allocate white for background color */ im_black = gdImageColorAllocate(im,0,0,0); /* create the dots pattern */ for (x=0; x<36; x+=2) { for (y=0; y<36; y+=2) { gdImageSetPixel(tile,x,y,tile_black); } } gdImageSetTile(im,tile); gdImageRectangle(im, 9,9,139,139, im_black); gdImageLine(im, 9,9,139,139, im_black); gdImageFill(im, 11,12, gdTiled); /* fputs("flag 1\n", stdout); */ gdImageFill(im, 0, 0, 0xffffff); /* fputs("flag 2\n", stdout); */ gdImageFill(im, 0, 0, 0xffffff); /* fputs("flag 2\n", stdout); */ if (!gdAssertImageEqualsToFile("gdimagefill/bug00002_2_exp.png", im)) { error = 1; } /* Destroy it */ gdImageDestroy(im); gdImageDestroy(tile); return error; }
int main() { gdImagePtr im; char * giffiles[4] = {"bug00005_0.gif", "bug00005_1.gif", "bug00005_2.gif", "bug00005_3.gif"}; int valid[4] = {0, 0, 0, 0}; char *exp[4] = {NULL, NULL, "bug00005_2_exp.png", NULL}; const int files_cnt = 4; FILE *fp; int i = 0; int error = 0; char path[1024]; for (i=0; i < files_cnt; i++) { sprintf(path, "%s/gif/%s", GDTEST_TOP_DIR, giffiles[i]); fp = fopen(path, "rb"); if (!fp) { gdTestErrorMsg("<%s> Input file does not exist!\n", path); return 1; } im = gdImageCreateFromGif(fp); fclose(fp); if (valid[i]) { if (!im) { error = 1; } else { sprintf(path, "%s/gif/%s", GDTEST_TOP_DIR, exp[i]); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; } gdImageDestroy(im); } } else { if (!gdTestAssert(im == NULL)) { error = 1; } } } return error; }
int main() { gdImagePtr im; FILE *fp; char *path; fp = gdTestFileOpen2("xbm", "x10_basic_read.xbm"); im = gdImageCreateFromXbm(fp); fclose(fp); gdTestAssert(im != NULL); path = gdTestFilePath2("xbm", "x10_basic_read_exp.png"); gdAssertImageEqualsToFile(path, im); gdFree(path); gdImageDestroy(im); return gdNumFailures(); }
int main() { gdImagePtr im; int error = 0; char path[1024]; im = gdImageCreateTrueColor(300, 300); gdImageFilledRectangle(im, 0,0, 299,299, 0xFFFFFF); gdImageSetAntiAliased(im, 0x000000); gdImageArc(im, 300, 300, 600,600, 0, 360, gdAntiAliased); sprintf(path, "%s/gdimagearc/bug00079_exp.png", GDTEST_TOP_DIR); if (!gdAssertImageEqualsToFile(path, im)) { printf("%s failed\n", path); error = 1; } gdImageDestroy(im); return error; }
int main() { int error; gdImagePtr im; FILE *fp; char path[1024]; const char * files[2] = {"bug00088_1.png", "bug00088_2.png"}; const char * files_exp[2] = {"bug00088_1_exp.png", "bug00088_2_exp.png"}; int i, cnt = 2; error = 0; for (i = 0; i < cnt; i++) { sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, files[i]); fp = fopen(path, "rb"); if (!fp) { printf("failed, cannot open file <%s>\n", path); return 1; } im = gdImageCreateFromPng(fp); fclose(fp); if (!im) { error |= 1; continue; } sprintf(path, "%s/png/%s", GDTEST_TOP_DIR, files_exp[i]); if (!gdAssertImageEqualsToFile(path, im)) { error |= 1; } gdImageDestroy(im); } return error; }
int gen_image(const char* filename, int idx, int reverse_x, int width, int height, int bgd) { double gradient = height / (width*2.0); int offset = idx*width; int x1,y1,x2,y2, error = 0; gdImagePtr im = gdImageCreateTrueColor(width,height); if (bgd==1) { gdImageFilledRectangle(im,0,0,width-1,height-1, gdTrueColorAlpha(255, 255, 255, 0)); } else { gdImageFilledRectangle(im,0,0,width-1,height-1, gdTrueColorAlpha(255, 255, 0, 0)); } gdImageSetAntiAliased(im, gdTrueColorAlpha(0,0,0,0)); /* test for potential segfault (introduced with AA improvements, fixed with the same patch - but I didn't notice it until later).*/ gdImageLine(im,-1,-1,-1,-1,gdAntiAliased); x1 = floor(reverse_x * -width + 0.5); y1 = (offset-width) * gradient + 0.5; x2 = floor(reverse_x * width*2 + 0.5); y2 = floor((offset+width*2) * gradient + 0.5); // draw an AA line gdImageLine(im, x1, y1, x2, y2, gdAntiAliased); gdImageLine(im, 0, im->sy - 1, im->sx, im->sy - 1, 0x40FF0000); if (!gdAssertImageEqualsToFile(filename, im)) { printf("%s failed\n", filename); error = 1; } gdImageDestroy(im); return error; }
int main() { gdImagePtr im, im2; int error = 0; im = gdImageCreateTrueColor(width, width); gdImageFilledRectangle(im, 0,0, width, width, 0xFF0000); gdImageColorTransparent(im, 0xFF0000); gdImageFilledEllipse(im, width/2, width/2, width - 20, width - 10, 0x50FFFFFF); im2 = gdImageCreateTrueColor(width, width); gdImageCopyRotated(im2, im, width / 2, width / 2, 0,0, width, width, 60); if (!gdAssertImageEqualsToFile("gdimagecopyrotated/bug00020_exp.png", im2)) { error = 1; } gdImageDestroy(im2); gdImageDestroy(im); return error; }
int main() { #if defined(JPEG_LIB_VERSION_MAJOR) && JPEG_LIB_VERSION_MAJOR >= 8 printf("skip, JPEG Major version too high (%i)\n", JPEG_LIB_VERSION_MAJOR); return 0; #else gdImagePtr im; int error = 0; FILE *fp = gdTestFileOpen("jpeg/conv_test.jpeg"); im = gdImageCreateFromJpeg(fp); fclose(fp); if (im == NULL) { gdTestErrorMsg("gdImageCreateFromJpeg failed.\n"); return 1; } if (!gdAssertImageEqualsToFile("jpeg/conv_test_exp.png", im)) error = 1; gdImageDestroy(im); return error; #endif }
int main() { gdImagePtr im; FILE *fp; int red, blue, white, black, error = 0; char path[1024]; im = gdImageCreate(50,100); red = gdImageColorAllocate(im, 255, 0, 0); blue = gdImageColorAllocate(im, 0,0,255); white = gdImageColorAllocate(im, 255,255,255); black = gdImageColorAllocate(im, 0,0,0); gdImageFill(im, 0,0, black); gdImageLine(im, 20,20,180,20, white); gdImageLine(im, 20,20,20,70, blue); gdImageLine(im, 20,70,180,70, red); gdImageLine(im, 180,20,180,45, white); gdImageLine(im, 180,70,180,45, red); gdImageLine(im, 20,20,100,45, blue); gdImageLine(im, 20,70,100,45, blue); gdImageLine(im, 100,45,180,45, red); gdImageFill(im, 21,45, blue); gdImageFill(im, 100,69, red); gdImageFill(im, 100,21, white); sprintf(path, "%s/gdimagefill/bug00002_4_exp.png", GDTEST_TOP_DIR); if (!gdAssertImageEqualsToFile(path, im)) { error = 1; } /* Destroy it */ gdImageDestroy(im); return error; }
int main() { gdImagePtr im, tile; char exp[] = "bug00032_exp.png"; FILE *fp; tile = gdImageCreateTrueColor(10, 10); gdImageFill(tile, 0, 0, 0xFFFFFF); gdImageLine(tile, 0,0, 9,9, 0xff0000); gdImageColorTransparent(tile, 0xFFFFFF); im = gdImageCreateTrueColor(50, 50); gdImageFilledRectangle(im, 0, 0, 25, 25, 0x00FF00); gdImageSetTile(im, tile); gdImageFilledRectangle(im, 10, 10, 49, 49, gdTiled); gdAssertImageEqualsToFile(exp_img, im); /* Destroy it */ gdImageDestroy(im); gdImageDestroy(tile); return 0; }