]> granicus.if.org Git - php/commitdiff
- gd #106, imagerectangle draws 1x1 rectangles as 1x3 rectangles
authorPierre Joye <pajoye@php.net>
Sun, 26 Aug 2007 20:33:22 +0000 (20:33 +0000)
committerPierre Joye <pajoye@php.net>
Sun, 26 Aug 2007 20:33:22 +0000 (20:33 +0000)
ext/gd/libgd/gd.c
ext/gd/tests/libgd00106.phpt [new file with mode: 0644]

index 168c08bb2a1dbd7054e9be6fc6e75d530ac34648..0a26b89370eca62a463fdf7b4ef6b4efd9195c12 100644 (file)
@@ -2120,6 +2120,11 @@ void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
        int half1 = 1;
        int t;
 
+       if (x1 == x2 && y1 == y2 && thick == 1) {
+               gdImageSetPixel(im, x1, y1, color);
+               return;
+       }
+
        if (y2 < y1) {
                t=y1;
                y1 = y2;
diff --git a/ext/gd/tests/libgd00106.phpt b/ext/gd/tests/libgd00106.phpt
new file mode 100644 (file)
index 0000000..65e4692
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+libgd #106 (imagerectangle 1x1 draws 1x3)
+--SKIPIF--
+<?php
+       if (!extension_loaded('gd')) die("skip gd extension not available\n");
+?>
+--FILE--
+<?php
+$im = imagecreatetruecolor(10,10);
+imagerectangle($im, 1,1, 1,1, 0xFFFFFF);
+$c1 = imagecolorat($im, 1,1);
+$c2 = imagecolorat($im, 1,2);
+$c3 = imagecolorat($im, 2,1);
+$c4 = imagecolorat($im, 2,2);
+if ($c1 == 0xFFFFFF && $c2 == 0 && $c3 == 0 && $c4 == 0) {
+       echo "Ok";
+} else {
+       echo "failed";
+}
+?>
+--EXPECT--
+Ok