summaryrefslogtreecommitdiff
path: root/tests/gdimagesetpixel
diff options
context:
space:
mode:
authorTim Toohey <ttoohey@toowards.com>2014-04-23 10:35:05 +1000
committerTim Toohey <ttoohey@toowards.com>2014-04-23 10:50:02 +1000
commit01dccbdc6924053d630d75e80b44b41c5d68e3f4 (patch)
tree743b03a571870360344c36befb6e1cd2f6fc970a /tests/gdimagesetpixel
parentb39f92b19543f0f4efae4d8dec3016291d1b7dd8 (diff)
downloadlibgd-01dccbdc6924053d630d75e80b44b41c5d68e3f4.tar.gz
add tests for layer effects
Diffstat (limited to 'tests/gdimagesetpixel')
-rw-r--r--tests/gdimagesetpixel/CMakeLists.txt2
-rw-r--r--tests/gdimagesetpixel/gdeffectmultiply.c33
-rw-r--r--tests/gdimagesetpixel/gdeffectoverlay.c35
3 files changed, 70 insertions, 0 deletions
diff --git a/tests/gdimagesetpixel/CMakeLists.txt b/tests/gdimagesetpixel/CMakeLists.txt
index e5b9b2a..907616d 100644
--- a/tests/gdimagesetpixel/CMakeLists.txt
+++ b/tests/gdimagesetpixel/CMakeLists.txt
@@ -1,5 +1,7 @@
SET(TESTS_FILES
bug00186
+ gdeffectoverlay
+ gdeffectmultiply
)
FOREACH(test_name ${TESTS_FILES})
diff --git a/tests/gdimagesetpixel/gdeffectmultiply.c b/tests/gdimagesetpixel/gdeffectmultiply.c
new file mode 100644
index 0000000..3d8da7b
--- /dev/null
+++ b/tests/gdimagesetpixel/gdeffectmultiply.c
@@ -0,0 +1,33 @@
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ int x, y, c;
+ int r=0;
+
+
+ im = gdImageCreateTrueColor(256, 256);
+ gdImageAlphaBlending( im, gdEffectReplace );
+ for (x=0; x<256; x++) {
+ for (y=0; y<256; y++) {
+ c = (y/2 << 24) + (x << 16) + (x << 8) + x;
+ gdImageSetPixel(im, x, y, c );
+ }
+ }
+ gdImageAlphaBlending( im, gdEffectMultiply );
+ gdImageFilledRectangle(im, 0, 0, 255, 255, 0xff7f00);
+
+ if (gdTrueColorGetGreen(gdImageGetPixel(im, 0, 128)) != 0x40) {
+ r = 1;
+ }
+ if (gdTrueColorGetGreen(gdImageGetPixel(im, 128, 128)) != 0x5f) {
+ r = 1;
+ }
+ if (gdTrueColorGetGreen(gdImageGetPixel(im, 255, 128)) != 0x7f) {
+ r = 1;
+ }
+ gdImageDestroy(im);
+ return r;
+}
diff --git a/tests/gdimagesetpixel/gdeffectoverlay.c b/tests/gdimagesetpixel/gdeffectoverlay.c
new file mode 100644
index 0000000..5e42547
--- /dev/null
+++ b/tests/gdimagesetpixel/gdeffectoverlay.c
@@ -0,0 +1,35 @@
+#include "gd.h"
+#include "gdtest.h"
+
+int main()
+{
+ gdImagePtr im;
+ int x, y, c;
+ FILE *out;
+ char path[1024];
+ int r=0;
+
+
+ im = gdImageCreateTrueColor(256, 256);
+ gdImageAlphaBlending( im, gdEffectReplace );
+ for (x=0; x<256; x++) {
+ for (y=0; y<256; y++) {
+ c = (y/2 << 24) + (x << 16) + (x << 8) + x;
+ gdImageSetPixel(im, x, y, c );
+ }
+ }
+ gdImageAlphaBlending( im, gdEffectOverlay );
+ gdImageFilledRectangle(im, 0, 0, 255, 255, 0xff7f00);
+
+ if (gdTrueColorGetGreen(gdImageGetPixel(im, 0, 128)) != 0x00) {
+ r = 1;
+ }
+ if (gdTrueColorGetGreen(gdImageGetPixel(im, 128, 128)) != 0x80) {
+ r = 1;
+ }
+ if (gdTrueColorGetGreen(gdImageGetPixel(im, 255, 128)) != 0xff) {
+ r = 1;
+ }
+ gdImageDestroy(im);
+ return r;
+}