diff options
Diffstat (limited to 'Build/source/libs/gd/libgd-2.1.0/tests/gdimageline')
20 files changed, 277 insertions, 0 deletions
diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/CMakeLists.txt b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/CMakeLists.txt new file mode 100644 index 00000000000..fb3212eba71 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/CMakeLists.txt @@ -0,0 +1,14 @@ +SET(TESTS_FILES + gdimageline_aa + gdimageline_aa_outofrange + bug00077 + bug00072 + bug00111 +) + +FOREACH(test_name ${TESTS_FILES}) + add_executable(${test_name} "${test_name}.c") + target_link_libraries (${test_name} gdTest) + get_target_property(test_path ${test_name} LOCATION) + ADD_TEST(${test_name} ${test_path}) +ENDFOREACH(test_name) diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00072.c b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00072.c new file mode 100644 index 00000000000..c3a3137e539 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00072.c @@ -0,0 +1,35 @@ +#include "gd.h" +#include "gdtest.h" + +int main() +{ + gdImagePtr im; + const char *exp = "bug00072_exp.png"; + int error = 0; + + char path[1024]; + + + im = gdImageCreateTrueColor(11, 11); + gdImageFilledRectangle(im, 0, 0, 10, 10, 0xFFFFFF); + gdImageSetThickness(im, 3); + + gdImageLine(im, 5, 0, 5, 11, 0x000000); + gdImageLine(im, 0, 5, 11, 5, 0x000000); + gdImageLine(im, 0, 0, 11, 11, 0x000000); + + gdImageSetThickness(im, 1); + + gdImageLine(im, 5, 0, 5, 11, 0xFF0000); + gdImageLine(im, 0, 5, 11, 5, 0xFF0000); + gdImageLine(im, 0, 0, 11, 11, 0xFF0000); + + sprintf(path, "%s/gdimageline/%s", GDTEST_TOP_DIR, exp); + if (!gdAssertImageEqualsToFile(path, im)) { + error = 1; + } + + gdImageDestroy(im); + + return error; +} diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00072_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00072_exp.png Binary files differnew file mode 100644 index 00000000000..6439e061f1d --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00072_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00077.c b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00077.c new file mode 100644 index 00000000000..d69e88177f2 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00077.c @@ -0,0 +1,31 @@ +#include "gd.h" +#include "gdtest.h" + +int main() +{ + gdImagePtr im; + const char *exp = "bug00077_exp.png"; + int error = 0; + + char path[1024]; + + + im = gdImageCreateTrueColor(11, 11); + gdImageFilledRectangle(im, 0, 0, 10, 10, 0xFFFFFF); + gdImageSetThickness(im, 1); + + gdImageLine(im, 0, 10, 0, 0, 0x0); + gdImageLine(im, 5, 10, 5, 0, 0x0); + gdImageLine(im, 10, 5, 0, 5, 0x0); + gdImageLine(im, 10, 10, 0, 10, 0x0); + + sprintf(path, "%s/gdimageline/%s", GDTEST_TOP_DIR, exp); + + if (!gdAssertImageEqualsToFile(path, im)) { + error = 1; + } + + gdImageDestroy(im); + + return error; +} diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00077_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00077_exp.png Binary files differnew file mode 100644 index 00000000000..bfa097a5c56 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00077_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00111.c b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00111.c new file mode 100644 index 00000000000..4277534874d --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00111.c @@ -0,0 +1,35 @@ +/* $Id$ */ + +#include "gd.h" +#include <stdio.h> +#include <stdlib.h> +#include "gdtest.h" + +int main() +{ + gdImagePtr im; + 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; +} diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00111_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00111_exp.png Binary files differnew file mode 100644 index 00000000000..ecd44b25d66 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/bug00111_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdImageAALine_thickness.c b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdImageAALine_thickness.c new file mode 100644 index 00000000000..6db2c72f57c --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdImageAALine_thickness.c @@ -0,0 +1,28 @@ +#include <stdio.h> +#include "gd.h" +#include "gdtest.h" + +int main(int argc, char **argv) +{ + gdImagePtr im; + char path[2048]; + const char *file_exp = "gdimageline/gdImageAALine_thickness_exp.png"; + + im = gdImageCreateTrueColor(100, 100); + gdImageFilledRectangle(im, 0, 0, 99, 99, + gdImageColorExactAlpha(im, 255, 255, 255, 0)); + + gdImageSetThickness(im, 5); + gdImageSetAntiAliased(im, gdImageColorExactAlpha(im, 0, 0, 0, 0)); + gdImageLine(im, 0,0, 99, 99, gdAntiAliased); + + sprintf(path, "%s/%s", GDTEST_TOP_DIR, file_exp); + + if (!gdAssertImageEqualsToFile(path, im)) { + printf("comparing rotated image to %s failed.\n", path); + gdImageDestroy(im); + return 1; + } + + gdImageDestroy(im); +} diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdImageAALine_thickness_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdImageAALine_thickness_exp.png Binary files differnew file mode 100644 index 00000000000..26e02bc3661 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdImageAALine_thickness_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa.c b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa.c new file mode 100644 index 00000000000..b0bea3a4d5c --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa.c @@ -0,0 +1,76 @@ +#include <stdio.h> +#include <math.h> +#include "gd.h" +#include "gdtest.h" + +#ifdef _MSC_VER +# define snprintf _snprintf +#endif + +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)) { + gdTestErrorMsg("gdAssertImageEqualsToFile failed: <%s>\n", filename); + error = 1; + } + gdImageDestroy(im); + return error; +} + +int main() +{ + int error = 0; + char path[1024]; + + snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_a_0_exp.png", GDTEST_TOP_DIR); + error |= gen_image(path,0,1,10,100, 1); + + snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_a_1_exp.png", GDTEST_TOP_DIR); + error |= gen_image(path,1,1,10,100, 2); + + snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_b_0_exp.png", GDTEST_TOP_DIR); + error |= gen_image(path,2,-1,10,100, 1); + snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_b_1_exp.png", GDTEST_TOP_DIR); + error |= gen_image(path,1,-1,10,100, 2); + + snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_c_0_exp.png", GDTEST_TOP_DIR); + error |= gen_image(path,0,1,100,10, 1); + snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_c_1_exp.png", GDTEST_TOP_DIR); + error |= gen_image(path,1,1,100,10, 2); + + snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_d_0_exp.png", GDTEST_TOP_DIR); + error |= gen_image(path,2,-1,100,10, 1); + snprintf(path, sizeof(path)-1, "%s/gdimageline/gdimageline_aa_d_1_exp.png", GDTEST_TOP_DIR); + error |= gen_image(path,1,-1,100,10, 2); + + return error; +} diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_a_0_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_a_0_exp.png Binary files differnew file mode 100644 index 00000000000..83f893453ed --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_a_0_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_a_1_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_a_1_exp.png Binary files differnew file mode 100644 index 00000000000..c4edcfa36ec --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_a_1_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_b_0_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_b_0_exp.png Binary files differnew file mode 100644 index 00000000000..130d6c36cc7 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_b_0_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_b_1_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_b_1_exp.png Binary files differnew file mode 100644 index 00000000000..678800658d3 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_b_1_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_c_0_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_c_0_exp.png Binary files differnew file mode 100644 index 00000000000..6d03ae6652e --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_c_0_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_c_1_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_c_1_exp.png Binary files differnew file mode 100644 index 00000000000..6e1a38aa7e1 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_c_1_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_d_0_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_d_0_exp.png Binary files differnew file mode 100644 index 00000000000..c6f9e27e4fc --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_d_0_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_d_1_exp.png b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_d_1_exp.png Binary files differnew file mode 100644 index 00000000000..709c186c26a --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_d_1_exp.png diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_outofrange.c b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_outofrange.c new file mode 100644 index 00000000000..5c1ed05ab03 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_aa_outofrange.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include "gd.h" +#include "gdtest.h" + +int main() +{ + gdImagePtr im; + + im = gdImageCreateTrueColor(300, 300); + + gdImageSetAntiAliased(im, gdTrueColorAlpha(255, 255, 255, 0)); + + gdImageLine(im, -1, -1, -1, -1, gdAntiAliased); + gdImageLine(im, 299, 299, 0, 299, gdAntiAliased); + gdImageLine(im, 1,1, 50, 50, gdAntiAliased); + + /* Test for segfaults, if we reach this point, the test worked */ + return 0; +} diff --git a/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_bug5.c b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_bug5.c new file mode 100644 index 00000000000..ef57f6c1cb2 --- /dev/null +++ b/Build/source/libs/gd/libgd-2.1.0/tests/gdimageline/gdimageline_bug5.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include "gd.h" +#include "gdtest.h" + +int main() { + /* Declare the image */ + gdImagePtr im; + + /* Declare output files */ + /* FILE *pngout; */ + int black, white; + + im = gdImageCreateTrueColor(63318, 771); + + /* Allocate the color white (red, green and blue all maximum). */ + white = gdImageColorAllocate(im, 255, 255, 255); + /* Allocate the color white (red, green and blue all maximum). */ + black = gdImageColorAllocate(im, 0, 0, 0); + + /* white background */ + gdImageFill(im, 1, 1, white); + + gdImageSetAntiAliased(im, black); + + /* This line fails! */ + gdImageLine(im, 28562, 631, 34266, 750, gdAntiAliased); + + /* Open a file for writing. "wb" means "write binary", important under MSDOS, harmless under Unix. */ + /* pngout = fopen("test.png", "wb"); */ + + /* Output the image to the disk file in PNG format. */ + /* gdImagePng(im, pngout); */ + + /* Close the files. */ + /* fclose(pngout); */ + + /* Destroy the image in memory. */ + gdImageDestroy(im); +} |