diff options
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/gdimagecopyresampled/.gitignore | 1 | ||||
-rw-r--r-- | tests/gdimagecopyresampled/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tests/gdimagecopyresampled/Makemodule.am | 9 | ||||
-rw-r--r-- | tests/gdimagecopyresampled/bug00201.c | 71 | ||||
-rw-r--r-- | tests/gdimagecopyresampled/bug00201_exp.png | bin | 0 -> 10772 bytes | |||
-rw-r--r-- | tests/gdimagecopyresampled/bug00201_src.png | bin | 0 -> 1219 bytes |
8 files changed, 88 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 369dec7..c2ec810 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -30,6 +30,7 @@ if (BUILD_TEST) gdimagecolorresolve gdimagecolortransparent gdimagecopy + gdimagecopyresampled gdimagecopyrotated gdimagecrop gdimagefile diff --git a/tests/Makefile.am b/tests/Makefile.am index 5a0ebe8..b59cefa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,6 +24,7 @@ include gdimagecolorreplace/Makemodule.am include gdimagecolorresolve/Makemodule.am include gdimagecolortransparent/Makemodule.am include gdimagecopy/Makemodule.am +include gdimagecopyresampled/Makemodule.am include gdimagecopyrotated/Makemodule.am include gdimagecrop/Makemodule.am include gdimagefile/Makemodule.am diff --git a/tests/gdimagecopyresampled/.gitignore b/tests/gdimagecopyresampled/.gitignore new file mode 100644 index 0000000..dfe2d25 --- /dev/null +++ b/tests/gdimagecopyresampled/.gitignore @@ -0,0 +1 @@ +/bug00201 diff --git a/tests/gdimagecopyresampled/CMakeLists.txt b/tests/gdimagecopyresampled/CMakeLists.txt new file mode 100644 index 0000000..19349d4 --- /dev/null +++ b/tests/gdimagecopyresampled/CMakeLists.txt @@ -0,0 +1,5 @@ +LIST(APPEND TESTS_FILES + bug00201 +) + +ADD_GD_TESTS() diff --git a/tests/gdimagecopyresampled/Makemodule.am b/tests/gdimagecopyresampled/Makemodule.am new file mode 100644 index 0000000..5d352f6 --- /dev/null +++ b/tests/gdimagecopyresampled/Makemodule.am @@ -0,0 +1,9 @@ +if HAVE_LIBPNG +libgd_test_programs += \ + gdimagecopyresampled/bug00201 +endif + +EXTRA_DIST += \ + gdimagecopyrotated/CMakeLists.txt \ + gdimagecopyrotated/bug00201_src.png \ + gdimagecopyrotated/bug00201_exp.png diff --git a/tests/gdimagecopyresampled/bug00201.c b/tests/gdimagecopyresampled/bug00201.c new file mode 100644 index 0000000..0375233 --- /dev/null +++ b/tests/gdimagecopyresampled/bug00201.c @@ -0,0 +1,71 @@ +#include "gd.h" +#include "gdtest.h" + + +#define SRC_WIDTH 80 +#define SRC_HEIGHT 42 +#define DEST_WIDTH 200 +#define DEST_HEIGHT 200 + + +/* Create an image and fill it with true transparency */ +gdImagePtr blank_image(int width, int height) +{ + gdImagePtr img; + int c; + + img = gdImageCreateTrueColor(width, height); + gdImageAlphaBlending(img, 0); + c = gdImageColorAllocateAlpha(img, 255, 0, 255, 127); + gdImageFilledRectangle(img, 0, 0, width-1, height-1, c); + return img; +} + + +/* Merge layers on top of each other */ +gdImagePtr flatten(gdImagePtr *layers, int layer_count, int width, int height) +{ + gdImagePtr img; + int i; + + img = blank_image(width,height); + gdImageAlphaBlending(img, 1); + for (i = 0; i < layer_count; i++) { + gdImageCopy(img, layers[i], 0,0, 0,0, width,height); + } + gdImageSaveAlpha(img, 1); + return img; +} + + +int main() +{ + gdImagePtr layers[2], background, logo_source, logo, scaled_logo, img; + FILE *fp; + + background = blank_image(DEST_WIDTH,DEST_HEIGHT); + + fp = gdTestFileOpen("gdimagecopyresampled/bug00201_src.png"); + logo_source = gdImageCreateFromPng(fp); + fclose(fp); + + logo = blank_image(SRC_WIDTH,SRC_HEIGHT); + gdImageAlphaBlending(logo, 0); + gdImageCopy(logo, logo_source, 0,0, 0,0, SRC_WIDTH,SRC_HEIGHT); + gdImageDestroy(logo_source); + + scaled_logo = blank_image(DEST_WIDTH,DEST_HEIGHT); + gdImageAlphaBlending(scaled_logo, 0); + gdImageCopyResampled(scaled_logo, logo, 0,0, 0,0, 200,105, SRC_WIDTH,SRC_HEIGHT); + gdImageDestroy(logo); + + layers[0] = background; + layers[1] = scaled_logo; + img = flatten(layers, 2, DEST_WIDTH, DEST_HEIGHT); + gdImageDestroy(background); + gdImageDestroy(scaled_logo); + + gdAssertImageEqualsToFile("gdimagecopyresampled/bug00201_exp.png", img); + gdImageDestroy(img); + return gdNumFailures(); +} diff --git a/tests/gdimagecopyresampled/bug00201_exp.png b/tests/gdimagecopyresampled/bug00201_exp.png Binary files differnew file mode 100644 index 0000000..927af21 --- /dev/null +++ b/tests/gdimagecopyresampled/bug00201_exp.png diff --git a/tests/gdimagecopyresampled/bug00201_src.png b/tests/gdimagecopyresampled/bug00201_src.png Binary files differnew file mode 100644 index 0000000..86c0eac --- /dev/null +++ b/tests/gdimagecopyresampled/bug00201_src.png |