summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-01-04 23:43:47 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-01-04 23:43:47 +0100
commit9088591eae437358ee5b929adf82865e37e3001e (patch)
tree30407b065fc5074038d031c52f6c1cf504a49740 /tests
parenta59ee51e8d0b4a9ede10f2a5a06c48a00246fd4e (diff)
downloadlibgd-9088591eae437358ee5b929adf82865e37e3001e.tar.gz
Fix #585: gdTransformAffineCopy() changes interpolation method
We have to properly initialize `interpolation_id_bak`.
Diffstat (limited to 'tests')
-rw-r--r--tests/gdtransformaffinecopy/.gitignore1
-rw-r--r--tests/gdtransformaffinecopy/CMakeLists.txt1
-rw-r--r--tests/gdtransformaffinecopy/Makemodule.am3
-rw-r--r--tests/gdtransformaffinecopy/github_bug_00585.c33
4 files changed, 37 insertions, 1 deletions
diff --git a/tests/gdtransformaffinecopy/.gitignore b/tests/gdtransformaffinecopy/.gitignore
index a6b56ec..632fc5d 100644
--- a/tests/gdtransformaffinecopy/.gitignore
+++ b/tests/gdtransformaffinecopy/.gitignore
@@ -1 +1,2 @@
/github_bug_00583
+/github_bug_00585
diff --git a/tests/gdtransformaffinecopy/CMakeLists.txt b/tests/gdtransformaffinecopy/CMakeLists.txt
index 69472fb..b2d47c8 100644
--- a/tests/gdtransformaffinecopy/CMakeLists.txt
+++ b/tests/gdtransformaffinecopy/CMakeLists.txt
@@ -1,5 +1,6 @@
LIST(APPEND TESTS_FILES
github_bug_00583
+ github_bug_00585
)
ADD_GD_TESTS()
diff --git a/tests/gdtransformaffinecopy/Makemodule.am b/tests/gdtransformaffinecopy/Makemodule.am
index f86b3c9..f03969d 100644
--- a/tests/gdtransformaffinecopy/Makemodule.am
+++ b/tests/gdtransformaffinecopy/Makemodule.am
@@ -1,5 +1,6 @@
libgd_test_programs += \
- gdtransformaffinecopy/github_bug_00583
+ gdtransformaffinecopy/github_bug_00583 \
+ gdtransformaffinecopy/github_bug_00585
EXTRA_DIST += \
gdtransformaffinecopy/CMakeLists.txt
diff --git a/tests/gdtransformaffinecopy/github_bug_00585.c b/tests/gdtransformaffinecopy/github_bug_00585.c
new file mode 100644
index 0000000..e83910c
--- /dev/null
+++ b/tests/gdtransformaffinecopy/github_bug_00585.c
@@ -0,0 +1,33 @@
+/*
+ * Test that gdTransformAffineCopy() does not change the interpolation method
+ *
+ * See <https://github.com/libgd/libgd/issues/585>
+ */
+
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr src, dst;
+ gdRect rect = {0, 0, 8, 8};
+ double matrix[] = {1, 1, 1, 1, 1, 1};
+ int res;
+ gdInterpolationMethod old_m, new_m;
+
+ src = gdImageCreateTrueColor(8, 8);
+ gdTestAssert(src != NULL);
+ dst = gdImageCreateTrueColor(8, 8);
+ gdTestAssert(dst != NULL);
+
+ res = gdImageSetInterpolationMethod(src, GD_CATMULLROM);
+ gdTestAssert(res == GD_TRUE);
+ old_m = gdImageGetInterpolationMethod(src);
+ gdTransformAffineCopy(dst, 0, 0, src, &rect, matrix);
+ new_m = gdImageGetInterpolationMethod(src);
+ gdTestAssert(new_m == old_m);
+
+ gdImageDestroy(src);
+ gdImageDestroy(dst);
+ return gdNumFailures();
+}