summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2016-09-25 17:37:45 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2016-09-27 13:34:18 +0200
commit3e8b5c5ee2b17629095e17773ff5c30422756c12 (patch)
tree27bf794a9d2eb44e82f3ae12c04b4feba8dc2a15
parent827bfd4cdddbd4c60d713c78e4407bf58a2e3fca (diff)
downloadlibgd-3e8b5c5ee2b17629095e17773ff5c30422756c12.tar.gz
Test and document some filter functions
-rw-r--r--docs/naturaldocs/images/edge_detect_quick.jpgbin0 -> 22444 bytes
-rw-r--r--docs/naturaldocs/images/emboss.jpgbin0 -> 20811 bytes
-rw-r--r--docs/naturaldocs/images/mean_removal.jpgbin0 -> 27366 bytes
-rw-r--r--docs/naturaldocs/images/smooth.jpgbin0 -> 15528 bytes
-rwxr-xr-xdocs/naturaldocs/run_docs.sh1
-rw-r--r--src/gd_filter.c185
-rw-r--r--tests/CMakeLists.txt6
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/gdimagebrightness/.gitignore1
-rw-r--r--tests/gdimagebrightness/CMakeLists.txt5
-rw-r--r--tests/gdimagebrightness/Makemodule.am10
-rw-r--r--tests/gdimagebrightness/basic+100.pngbin0 -> 2028 bytes
-rw-r--r--tests/gdimagebrightness/basic-100.pngbin0 -> 2004 bytes
-rw-r--r--tests/gdimagebrightness/basic.c41
-rw-r--r--tests/gdimagebrightness/basic.pngbin0 -> 2009 bytes
-rw-r--r--tests/gdimagecolor/.gitignore1
-rw-r--r--tests/gdimagecolor/CMakeLists.txt5
-rw-r--r--tests/gdimagecolor/Makemodule.am9
-rw-r--r--tests/gdimagecolor/basic.c29
-rw-r--r--tests/gdimagecolor/basic.pngbin0 -> 2092 bytes
-rw-r--r--tests/gdimagecolor/basic_exp.pngbin0 -> 2140 bytes
-rw-r--r--tests/gdimagecontrast/.gitignore1
-rw-r--r--tests/gdimagecontrast/CMakeLists.txt5
-rw-r--r--tests/gdimagecontrast/Makemodule.am10
-rw-r--r--tests/gdimagecontrast/basic+50.pngbin0 -> 2024 bytes
-rw-r--r--tests/gdimagecontrast/basic-50.pngbin0 -> 2034 bytes
-rw-r--r--tests/gdimagecontrast/basic.c41
-rw-r--r--tests/gdimagecontrast/basic.pngbin0 -> 2009 bytes
-rw-r--r--tests/gdimageconvolution/.gitignore1
-rw-r--r--tests/gdimageconvolution/CMakeLists.txt5
-rw-r--r--tests/gdimageconvolution/Makemodule.am12
-rw-r--r--tests/gdimageconvolution/basic.c62
-rw-r--r--tests/gdimageconvolution/basic.pngbin0 -> 49446 bytes
-rw-r--r--tests/gdimageconvolution/basic_edge_detect_quick.pngbin0 -> 42824 bytes
-rw-r--r--tests/gdimageconvolution/basic_emboss.pngbin0 -> 36783 bytes
-rw-r--r--tests/gdimageconvolution/basic_mean_removal.pngbin0 -> 45395 bytes
-rw-r--r--tests/gdimageconvolution/basic_smooth.pngbin0 -> 24595 bytes
-rw-r--r--tests/gdimagegrayscale/.gitignore1
-rw-r--r--tests/gdimagegrayscale/CMakeLists.txt5
-rw-r--r--tests/gdimagegrayscale/Makemodule.am9
-rw-r--r--tests/gdimagegrayscale/basic.c29
-rw-r--r--tests/gdimagegrayscale/basic.pngbin0 -> 2009 bytes
-rw-r--r--tests/gdimagegrayscale/basic_exp.pngbin0 -> 2092 bytes
-rw-r--r--tests/gdimagenegate/.gitignore1
-rw-r--r--tests/gdimagenegate/CMakeLists.txt5
-rw-r--r--tests/gdimagenegate/Makemodule.am9
-rw-r--r--tests/gdimagenegate/basic.c29
-rw-r--r--tests/gdimagenegate/basic.pngbin0 -> 2009 bytes
-rw-r--r--tests/gdimagenegate/basic_exp.pngbin0 -> 2014 bytes
49 files changed, 498 insertions, 26 deletions
diff --git a/docs/naturaldocs/images/edge_detect_quick.jpg b/docs/naturaldocs/images/edge_detect_quick.jpg
new file mode 100644
index 0000000..015fd4f
--- /dev/null
+++ b/docs/naturaldocs/images/edge_detect_quick.jpg
Binary files differ
diff --git a/docs/naturaldocs/images/emboss.jpg b/docs/naturaldocs/images/emboss.jpg
new file mode 100644
index 0000000..b818fd5
--- /dev/null
+++ b/docs/naturaldocs/images/emboss.jpg
Binary files differ
diff --git a/docs/naturaldocs/images/mean_removal.jpg b/docs/naturaldocs/images/mean_removal.jpg
new file mode 100644
index 0000000..d3f9c11
--- /dev/null
+++ b/docs/naturaldocs/images/mean_removal.jpg
Binary files differ
diff --git a/docs/naturaldocs/images/smooth.jpg b/docs/naturaldocs/images/smooth.jpg
new file mode 100644
index 0000000..e6987b8
--- /dev/null
+++ b/docs/naturaldocs/images/smooth.jpg
Binary files differ
diff --git a/docs/naturaldocs/run_docs.sh b/docs/naturaldocs/run_docs.sh
index 0bc3ae3..dce3072 100755
--- a/docs/naturaldocs/run_docs.sh
+++ b/docs/naturaldocs/run_docs.sh
@@ -67,6 +67,7 @@ sed -e "s/@VERSION@/$VERSION/g" preamble.txt > tmp/preamble.txt
# Run naturaldocs to create the manual.
$(nd) --rebuild --rebuild-output --documented-only \
-i tmp/ \
+ -img images/ \
-o html html \
--project project/ \
-s Default libgd
diff --git a/src/gd_filter.c b/src/gd_filter.c
index de48080..0d52e06 100644
--- a/src/gd_filter.c
+++ b/src/gd_filter.c
@@ -1,3 +1,8 @@
+/**
+ * File: Image Filters
+ */
+
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -184,10 +189,16 @@ BGD_DECLARE(int) gdImagePixelate(gdImagePtr im, int block_size, const unsigned i
return 1;
}
-/*
- Function: gdImageNegate
-
- Invert src image.
+/**
+ * Function: gdImageNegate
+ *
+ * Invert an image
+ *
+ * Parameters:
+ * src - The image.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
*/
BGD_DECLARE(int) gdImageNegate(gdImagePtr src)
{
@@ -220,10 +231,16 @@ BGD_DECLARE(int) gdImageNegate(gdImagePtr src)
return 1;
}
-/*
- Function: gdImageGrayScale
-
- Convert the image src to a grayscale image.
+/**
+ * Function: gdImageGrayScale
+ *
+ * Convert an image to grayscale
+ *
+ * Parameters:
+ * src - The image.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
*/
BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src)
{
@@ -257,10 +274,21 @@ BGD_DECLARE(int) gdImageGrayScale(gdImagePtr src)
return 1;
}
-/*
- Function: gdImageBrightness
-
- Set the brightness level <level> for the image src.
+/**
+ * Function: gdImageBrightness
+ *
+ * Change the brightness of an image
+ *
+ * Parameters:
+ * src - The image.
+ * brightness - The value to add to the color channels of all pixels.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
+ *
+ * See also:
+ * - <gdImageContrast>
+ * - <gdImageColor>
*/
BGD_DECLARE(int) gdImageBrightness(gdImagePtr src, int brightness)
{
@@ -307,8 +335,22 @@ BGD_DECLARE(int) gdImageBrightness(gdImagePtr src, int brightness)
}
-/*
- Function: gdImageContrast
+/**
+ * Function: gdImageContrast
+ *
+ * Change the contrast of an image
+ *
+ * Parameters:
+ * src - The image.
+ * contrast - The contrast adjustment value. Negative values increase, postive
+ * values decrease the contrast. The larger the absolute value, the
+ * stronger the effect.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
+ *
+ * See also:
+ * - <gdImageBrightness>
*/
BGD_DECLARE(int) gdImageContrast(gdImagePtr src, double contrast)
{
@@ -370,8 +412,23 @@ BGD_DECLARE(int) gdImageContrast(gdImagePtr src, double contrast)
}
-/*
- Function: gdImageColor
+/**
+ * Function: gdImageColor
+ *
+ * Change channel values of an image
+ *
+ * Parameters:
+ * src - The image.
+ * red - The value to add to the red channel of all pixels.
+ * green - The value to add to the green channel of all pixels.
+ * blue - The value to add to the blue channel of all pixels.
+ * alpha - The value to add to the alpha channel of all pixels.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
+ *
+ * See also:
+ * - <gdImageBrightness>
*/
BGD_DECLARE(int) gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha)
{
@@ -415,8 +472,29 @@ BGD_DECLARE(int) gdImageColor(gdImagePtr src, const int red, const int green, co
return 1;
}
-/*
- Function: gdImageConvolution
+/**
+ * Function: gdImageConvolution
+ *
+ * Apply a convolution matrix to an image
+ *
+ * Depending on the matrix a wide range of effects can be accomplished, e.g.
+ * blurring, sharpening, embossing and edge detection.
+ *
+ * Parameters:
+ * src - The image.
+ * filter - The 3x3 convolution matrix.
+ * filter_div - The value to divide the convoluted channel values by.
+ * offset - The value to add to the convoluted channel values.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
+ *
+ * See also:
+ * - <gdImageEdgeDetectQuick>
+ * - <gdImageGaussianBlur>
+ * - <gdImageEmboss>
+ * - <gdImageMeanRemoval>
+ * - <gdImageSmooth>
*/
BGD_DECLARE(int) gdImageConvolution(gdImagePtr src, float filter[3][3], float filter_div, float offset)
{
@@ -599,8 +677,22 @@ BGD_DECLARE(int) gdImageSelectiveBlur( gdImagePtr src)
return 1;
}
-/*
- Function: gdImageEdgeDetectQuick
+/**
+ * Function: gdImageEdgeDetectQuick
+ *
+ * Edge detection of an image
+ *
+ * (see edge_detect_quick.jpg)
+ *
+ * Parameters:
+ * src - The image.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
+ *
+ * See also:
+ * - <gdImageMeanRemoval>
+ * - <gdImageConvolution>
*/
BGD_DECLARE(int) gdImageEdgeDetectQuick(gdImagePtr src)
{
@@ -642,8 +734,21 @@ BGD_DECLARE(int) gdImageGaussianBlur(gdImagePtr im)
return gdImageConvolution(im, filter, 16, 0);
}
-/*
- Function: gdImageEmboss
+/**
+ * Function: gdImageEmboss
+ *
+ * Emboss an image
+ *
+ * (see emboss.jpg)
+ *
+ * Parameters:
+ * im - The image.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
+ *
+ * See also:
+ * - <gdImageConvolution>
*/
BGD_DECLARE(int) gdImageEmboss(gdImagePtr im)
{
@@ -659,8 +764,22 @@ BGD_DECLARE(int) gdImageEmboss(gdImagePtr im)
return gdImageConvolution(im, filter, 1, 127);
}
-/*
- Function: gdImageMeanRemoval
+/**
+ * Function: gdImageMeanRemoval
+ *
+ * Mean removal of an image
+ *
+ * (see mean_removal.jpg)
+ *
+ * Parameters:
+ * im - The image.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
+ *
+ * See also:
+ * - <gdImageEdgeDetectQuick>
+ * - <gdImageConvolution>
*/
BGD_DECLARE(int) gdImageMeanRemoval(gdImagePtr im)
{
@@ -671,8 +790,22 @@ BGD_DECLARE(int) gdImageMeanRemoval(gdImagePtr im)
return gdImageConvolution(im, filter, 1, 0);
}
-/*
- Function: gdImageSmooth
+/**
+ * Function: gdImageSmooth
+ *
+ * Smooth an image
+ *
+ * (see smooth.jpg)
+ *
+ * Parameters:
+ * im - The image.
+ * weight - The strength of the smoothing.
+ *
+ * Returns:
+ * Non-zero on success, zero on failure.
+ *
+ * See also:
+ * - <gdImageConvolution>
*/
BGD_DECLARE(int) gdImageSmooth(gdImagePtr im, float weight)
{
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5edcc5b..aa94b89 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -24,13 +24,17 @@ if (BUILD_TEST)
gd
gd2
gdimagearc
+ gdimagebrightness
gdimageclone
+ gdimagecolor
gdimagecolorclosest
gdimagecolordeallocate
gdimagecolorexact
gdimagecolorreplace
gdimagecolorresolve
gdimagecolortransparent
+ gdimagecontrast
+ gdimageconvolution
gdimagecopy
gdimagecopyresampled
gdimagecopyrotated
@@ -43,7 +47,9 @@ if (BUILD_TEST)
gdimagefilledrectangle
gdimagefilltoborder
gdimagefilter
+ gdimagegrayscale
gdimageline
+ gdimagenegate
gdimageopenpolygon
gdimagepixelate
gdimagepolygon
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 97380ae..921cf96 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,13 +19,17 @@ include freetype/Makemodule.am
include gd/Makemodule.am
include gd2/Makemodule.am
include gdimagearc/Makemodule.am
+include gdimagebrightness/Makemodule.am
include gdimageclone/Makemodule.am
+include gdimagecolor/Makemodule.am
include gdimagecolorclosest/Makemodule.am
include gdimagecolordeallocate/Makemodule.am
include gdimagecolorexact/Makemodule.am
include gdimagecolorreplace/Makemodule.am
include gdimagecolorresolve/Makemodule.am
include gdimagecolortransparent/Makemodule.am
+include gdimagecontrast/Makemodule.am
+include gdimageconvolution/Makemodule.am
include gdimagecopy/Makemodule.am
include gdimagecopyresampled/Makemodule.am
include gdimagecopyrotated/Makemodule.am
@@ -38,7 +42,9 @@ include gdimagefilledpolygon/Makemodule.am
include gdimagefilledrectangle/Makemodule.am
include gdimagefilltoborder/Makemodule.am
include gdimagefilter/Makemodule.am
+include gdimagegrayscale/Makemodule.am
include gdimageline/Makemodule.am
+include gdimagenegate/Makemodule.am
include gdimageopenpolygon/Makemodule.am
include gdimagepixelate/Makemodule.am
include gdimagepolygon/Makemodule.am
diff --git a/tests/gdimagebrightness/.gitignore b/tests/gdimagebrightness/.gitignore
new file mode 100644
index 0000000..1ffd796
--- /dev/null
+++ b/tests/gdimagebrightness/.gitignore
@@ -0,0 +1 @@
+/basic
diff --git a/tests/gdimagebrightness/CMakeLists.txt b/tests/gdimagebrightness/CMakeLists.txt
new file mode 100644
index 0000000..381c74d
--- /dev/null
+++ b/tests/gdimagebrightness/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagebrightness/Makemodule.am b/tests/gdimagebrightness/Makemodule.am
new file mode 100644
index 0000000..142fd94
--- /dev/null
+++ b/tests/gdimagebrightness/Makemodule.am
@@ -0,0 +1,10 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagebrightness/basic
+endif
+
+EXTRA_DIST += \
+ gdimagebrightness/CMakeLists.txt \
+ gdimagebrightness/basic.png \
+ gdimagebrightness/basic+100.png \
+ gdimagebrightness/basic-100.png
diff --git a/tests/gdimagebrightness/basic+100.png b/tests/gdimagebrightness/basic+100.png
new file mode 100644
index 0000000..5ed3289
--- /dev/null
+++ b/tests/gdimagebrightness/basic+100.png
Binary files differ
diff --git a/tests/gdimagebrightness/basic-100.png b/tests/gdimagebrightness/basic-100.png
new file mode 100644
index 0000000..80c2997
--- /dev/null
+++ b/tests/gdimagebrightness/basic-100.png
Binary files differ
diff --git a/tests/gdimagebrightness/basic.c b/tests/gdimagebrightness/basic.c
new file mode 100644
index 0000000..8c3a73c
--- /dev/null
+++ b/tests/gdimagebrightness/basic.c
@@ -0,0 +1,41 @@
+/**
+ * Basic test for gdImageBrightness()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void test_brightness(int brightness);
+
+
+int main()
+{
+ test_brightness(+100);
+ test_brightness(-100);
+
+ return gdNumFailures();
+}
+
+
+static void test_brightness(int brightness)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char basename[256];
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagebrightness", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageBrightness(im, brightness);
+
+ sprintf(basename, "basic%+03d.png", brightness);
+ path = gdTestFilePath2("gdimagebrightness", basename);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
diff --git a/tests/gdimagebrightness/basic.png b/tests/gdimagebrightness/basic.png
new file mode 100644
index 0000000..517010b
--- /dev/null
+++ b/tests/gdimagebrightness/basic.png
Binary files differ
diff --git a/tests/gdimagecolor/.gitignore b/tests/gdimagecolor/.gitignore
new file mode 100644
index 0000000..1ffd796
--- /dev/null
+++ b/tests/gdimagecolor/.gitignore
@@ -0,0 +1 @@
+/basic
diff --git a/tests/gdimagecolor/CMakeLists.txt b/tests/gdimagecolor/CMakeLists.txt
new file mode 100644
index 0000000..381c74d
--- /dev/null
+++ b/tests/gdimagecolor/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecolor/Makemodule.am b/tests/gdimagecolor/Makemodule.am
new file mode 100644
index 0000000..caf26a4
--- /dev/null
+++ b/tests/gdimagecolor/Makemodule.am
@@ -0,0 +1,9 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecolor/basic
+endif
+
+EXTRA_DIST += \
+ gdimagecolor/CMakeLists.txt \
+ gdimagecolor/basic.png \
+ gdimagecolor/basic_exp.png
diff --git a/tests/gdimagecolor/basic.c b/tests/gdimagecolor/basic.c
new file mode 100644
index 0000000..2ad0f3c
--- /dev/null
+++ b/tests/gdimagecolor/basic.c
@@ -0,0 +1,29 @@
+/**
+ * Basic test for gdImageColor()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagecolor", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageColor(im, 127, -127, -127, 0);
+
+ path = gdTestFilePath2("gdimagecolor", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagecolor/basic.png b/tests/gdimagecolor/basic.png
new file mode 100644
index 0000000..310f4ae
--- /dev/null
+++ b/tests/gdimagecolor/basic.png
Binary files differ
diff --git a/tests/gdimagecolor/basic_exp.png b/tests/gdimagecolor/basic_exp.png
new file mode 100644
index 0000000..0af3250
--- /dev/null
+++ b/tests/gdimagecolor/basic_exp.png
Binary files differ
diff --git a/tests/gdimagecontrast/.gitignore b/tests/gdimagecontrast/.gitignore
new file mode 100644
index 0000000..1ffd796
--- /dev/null
+++ b/tests/gdimagecontrast/.gitignore
@@ -0,0 +1 @@
+/basic
diff --git a/tests/gdimagecontrast/CMakeLists.txt b/tests/gdimagecontrast/CMakeLists.txt
new file mode 100644
index 0000000..381c74d
--- /dev/null
+++ b/tests/gdimagecontrast/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagecontrast/Makemodule.am b/tests/gdimagecontrast/Makemodule.am
new file mode 100644
index 0000000..635e2dc
--- /dev/null
+++ b/tests/gdimagecontrast/Makemodule.am
@@ -0,0 +1,10 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagecontrast/basic
+endif
+
+EXTRA_DIST += \
+ gdimagecontrast/CMakeLists.txt \
+ gdimagecontrast/basic.png \
+ gdimagecontrast/basic+50.png \
+ gdimagecontrast/basic-50.png
diff --git a/tests/gdimagecontrast/basic+50.png b/tests/gdimagecontrast/basic+50.png
new file mode 100644
index 0000000..d2a85ed
--- /dev/null
+++ b/tests/gdimagecontrast/basic+50.png
Binary files differ
diff --git a/tests/gdimagecontrast/basic-50.png b/tests/gdimagecontrast/basic-50.png
new file mode 100644
index 0000000..94151ec
--- /dev/null
+++ b/tests/gdimagecontrast/basic-50.png
Binary files differ
diff --git a/tests/gdimagecontrast/basic.c b/tests/gdimagecontrast/basic.c
new file mode 100644
index 0000000..d001bf9
--- /dev/null
+++ b/tests/gdimagecontrast/basic.c
@@ -0,0 +1,41 @@
+/**
+ * Basic test for gdImageContrast()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void test_contrast(double contrast);
+
+
+int main()
+{
+ test_contrast(+50.0);
+ test_contrast(-50.0);
+
+ return gdNumFailures();
+}
+
+
+static void test_contrast(double contrast)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char basename[256];
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagecontrast", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageContrast(im, contrast);
+
+ sprintf(basename, "basic%+03.0f.png", contrast);
+ path = gdTestFilePath2("gdimagecontrast", basename);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
diff --git a/tests/gdimagecontrast/basic.png b/tests/gdimagecontrast/basic.png
new file mode 100644
index 0000000..517010b
--- /dev/null
+++ b/tests/gdimagecontrast/basic.png
Binary files differ
diff --git a/tests/gdimageconvolution/.gitignore b/tests/gdimageconvolution/.gitignore
new file mode 100644
index 0000000..1ffd796
--- /dev/null
+++ b/tests/gdimageconvolution/.gitignore
@@ -0,0 +1 @@
+/basic
diff --git a/tests/gdimageconvolution/CMakeLists.txt b/tests/gdimageconvolution/CMakeLists.txt
new file mode 100644
index 0000000..381c74d
--- /dev/null
+++ b/tests/gdimageconvolution/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimageconvolution/Makemodule.am b/tests/gdimageconvolution/Makemodule.am
new file mode 100644
index 0000000..8f65b0f
--- /dev/null
+++ b/tests/gdimageconvolution/Makemodule.am
@@ -0,0 +1,12 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimageconvolution/basic
+endif
+
+EXTRA_DIST += \
+ gdimageconvolution/CMakeLists.txt \
+ gdimageconvolution/basic.png \
+ gdimageconvolution/basic_edge_detect_quick.png \
+ gdimageconvolution/basic_emboss.png \
+ gdimageconvolution/basic_mean_removal.png \
+ gdimageconvolution/basic_smooth.png
diff --git a/tests/gdimageconvolution/basic.c b/tests/gdimageconvolution/basic.c
new file mode 100644
index 0000000..7ca98be
--- /dev/null
+++ b/tests/gdimageconvolution/basic.c
@@ -0,0 +1,62 @@
+/**
+ * Basic test for gdImageConvolution() and related functions
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+static void test_convolution(void (*convolution_func)(gdImagePtr im), const char *expected)
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimageconvolution", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ convolution_func(im);
+
+ path = gdTestFilePath2("gdimageconvolution", expected);
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+}
+
+
+static void test_edge_detect_quick(gdImagePtr im)
+{
+ gdImageEdgeDetectQuick(im);
+}
+
+
+static void test_smooth(gdImagePtr im)
+{
+ gdImageSmooth(im, 5);
+}
+
+
+static void test_emboss(gdImagePtr im)
+{
+ gdImageEmboss(im);
+}
+
+
+static void test_mean_removal(gdImagePtr im)
+{
+ gdImageMeanRemoval(im);
+}
+
+
+int main()
+{
+ test_convolution(&test_edge_detect_quick, "basic_edge_detect_quick.png");
+ test_convolution(&test_smooth, "basic_smooth.png");
+ test_convolution(&test_emboss, "basic_emboss.png");
+ test_convolution(&test_mean_removal, "basic_mean_removal.png");
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimageconvolution/basic.png b/tests/gdimageconvolution/basic.png
new file mode 100644
index 0000000..2db7882
--- /dev/null
+++ b/tests/gdimageconvolution/basic.png
Binary files differ
diff --git a/tests/gdimageconvolution/basic_edge_detect_quick.png b/tests/gdimageconvolution/basic_edge_detect_quick.png
new file mode 100644
index 0000000..195a0fd
--- /dev/null
+++ b/tests/gdimageconvolution/basic_edge_detect_quick.png
Binary files differ
diff --git a/tests/gdimageconvolution/basic_emboss.png b/tests/gdimageconvolution/basic_emboss.png
new file mode 100644
index 0000000..bafd882
--- /dev/null
+++ b/tests/gdimageconvolution/basic_emboss.png
Binary files differ
diff --git a/tests/gdimageconvolution/basic_mean_removal.png b/tests/gdimageconvolution/basic_mean_removal.png
new file mode 100644
index 0000000..e98a91a
--- /dev/null
+++ b/tests/gdimageconvolution/basic_mean_removal.png
Binary files differ
diff --git a/tests/gdimageconvolution/basic_smooth.png b/tests/gdimageconvolution/basic_smooth.png
new file mode 100644
index 0000000..7907143
--- /dev/null
+++ b/tests/gdimageconvolution/basic_smooth.png
Binary files differ
diff --git a/tests/gdimagegrayscale/.gitignore b/tests/gdimagegrayscale/.gitignore
new file mode 100644
index 0000000..1ffd796
--- /dev/null
+++ b/tests/gdimagegrayscale/.gitignore
@@ -0,0 +1 @@
+/basic
diff --git a/tests/gdimagegrayscale/CMakeLists.txt b/tests/gdimagegrayscale/CMakeLists.txt
new file mode 100644
index 0000000..381c74d
--- /dev/null
+++ b/tests/gdimagegrayscale/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagegrayscale/Makemodule.am b/tests/gdimagegrayscale/Makemodule.am
new file mode 100644
index 0000000..e715c5b
--- /dev/null
+++ b/tests/gdimagegrayscale/Makemodule.am
@@ -0,0 +1,9 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagegrayscale/basic
+endif
+
+EXTRA_DIST += \
+ gdimagegrayscale/CMakeLists.txt \
+ gdimagegrayscale/basic.png \
+ gdimagegrayscale/basic_exp.png
diff --git a/tests/gdimagegrayscale/basic.c b/tests/gdimagegrayscale/basic.c
new file mode 100644
index 0000000..e3c21d8
--- /dev/null
+++ b/tests/gdimagegrayscale/basic.c
@@ -0,0 +1,29 @@
+/**
+ * Basic test for gdImageGrayScale()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagegrayscale", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageGrayScale(im);
+
+ path = gdTestFilePath2("gdimagegrayscale", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagegrayscale/basic.png b/tests/gdimagegrayscale/basic.png
new file mode 100644
index 0000000..517010b
--- /dev/null
+++ b/tests/gdimagegrayscale/basic.png
Binary files differ
diff --git a/tests/gdimagegrayscale/basic_exp.png b/tests/gdimagegrayscale/basic_exp.png
new file mode 100644
index 0000000..310f4ae
--- /dev/null
+++ b/tests/gdimagegrayscale/basic_exp.png
Binary files differ
diff --git a/tests/gdimagenegate/.gitignore b/tests/gdimagenegate/.gitignore
new file mode 100644
index 0000000..1ffd796
--- /dev/null
+++ b/tests/gdimagenegate/.gitignore
@@ -0,0 +1 @@
+/basic
diff --git a/tests/gdimagenegate/CMakeLists.txt b/tests/gdimagenegate/CMakeLists.txt
new file mode 100644
index 0000000..381c74d
--- /dev/null
+++ b/tests/gdimagenegate/CMakeLists.txt
@@ -0,0 +1,5 @@
+LIST(APPEND TESTS_FILES
+ basic
+)
+
+ADD_GD_TESTS()
diff --git a/tests/gdimagenegate/Makemodule.am b/tests/gdimagenegate/Makemodule.am
new file mode 100644
index 0000000..03b4dce
--- /dev/null
+++ b/tests/gdimagenegate/Makemodule.am
@@ -0,0 +1,9 @@
+if HAVE_LIBPNG
+libgd_test_programs += \
+ gdimagenegate/basic
+endif
+
+EXTRA_DIST += \
+ gdimagenegate/CMakeLists.txt \
+ gdimagenegate/basic.png \
+ gdimagenegate/basic_exp.png
diff --git a/tests/gdimagenegate/basic.c b/tests/gdimagenegate/basic.c
new file mode 100644
index 0000000..b904eb8
--- /dev/null
+++ b/tests/gdimagenegate/basic.c
@@ -0,0 +1,29 @@
+/**
+ * Basic test for gdImageNegate()
+ */
+
+
+#include "gd.h"
+#include "gdtest.h"
+
+
+int main()
+{
+ gdImagePtr im;
+ FILE *fp;
+ char *path;
+
+ fp = gdTestFileOpen2("gdimagenegate", "basic.png");
+ im = gdImageCreateFromPng(fp);
+ fclose(fp);
+
+ gdImageNegate(im);
+
+ path = gdTestFilePath2("gdimagenegate", "basic_exp.png");
+ gdAssertImageEqualsToFile(path, im);
+ gdFree(path);
+
+ gdImageDestroy(im);
+
+ return gdNumFailures();
+}
diff --git a/tests/gdimagenegate/basic.png b/tests/gdimagenegate/basic.png
new file mode 100644
index 0000000..517010b
--- /dev/null
+++ b/tests/gdimagenegate/basic.png
Binary files differ
diff --git a/tests/gdimagenegate/basic_exp.png b/tests/gdimagenegate/basic_exp.png
new file mode 100644
index 0000000..2dc0484
--- /dev/null
+++ b/tests/gdimagenegate/basic_exp.png
Binary files differ