summaryrefslogtreecommitdiff
path: root/ext/gd
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-01-11 15:43:42 +0100
committerOndřej Surý <ondrej@sury.org>2012-01-11 15:43:42 +0100
commit8f1428d29ef91d74b4d272af171675f2971eb15b (patch)
treea1f4f4d7dc5bfe8096806dd5c5266634e19fa07a /ext/gd
parentc6e4182351e0173fe58de141e143aac2eacf5efe (diff)
downloadphp-8f1428d29ef91d74b4d272af171675f2971eb15b.tar.gz
Imported Upstream version 5.3.9upstream/5.3.9
Diffstat (limited to 'ext/gd')
-rw-r--r--ext/gd/gd.c4
-rw-r--r--ext/gd/gd_ctx.c4
-rw-r--r--ext/gd/libgd/gd.c21
-rw-r--r--ext/gd/php_gd.h4
-rw-r--r--ext/gd/tests/bug60160.phpt26
-rw-r--r--ext/gd/tests/image_type_to_mime_type_basic.phpt63
-rw-r--r--ext/gd/tests/image_type_to_mime_type_error.phpt35
-rw-r--r--ext/gd/tests/image_type_to_mime_type_variation1.phpt152
-rw-r--r--ext/gd/tests/image_type_to_mime_type_variation2.phpt80
-rw-r--r--ext/gd/tests/image_type_to_mime_type_variation3.phpt76
-rw-r--r--ext/gd/tests/image_type_to_mime_type_variation4.phpt29
11 files changed, 40 insertions, 454 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index cc2ae4a16..378881d56 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c 313665 2011-07-25 11:42:53Z felipe $ */
+/* $Id: gd.c 321634 2012-01-01 13:15:04Z felipe $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
index 47ad9f6e5..a82220111 100644
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd_ctx.c 306939 2011-01-01 02:19:59Z felipe $ */
+/* $Id: gd_ctx.c 321634 2012-01-01 13:15:04Z felipe $ */
#include "php_gd.h"
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 0cc2e1d7d..fa75898dd 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -1894,19 +1894,14 @@ void gdImageFill(gdImagePtr im, int x, int y, int nc)
if (im->sx < 4) {
int ix = x, iy = y, c;
do {
- c = gdImageGetPixel(im, ix, iy);
- if (c != oc) {
- goto done;
- }
- gdImageSetPixel(im, ix, iy, nc);
- } while(ix++ < (im->sx -1));
- ix = x; iy = y + 1;
- do {
- c = gdImageGetPixel(im, ix, iy);
- if (c != oc) {
- goto done;
- }
- gdImageSetPixel(im, ix, iy, nc);
+ do {
+ c = gdImageGetPixel(im, ix, iy);
+ if (c != oc) {
+ goto done;
+ }
+ gdImageSetPixel(im, ix, iy, nc);
+ } while(ix++ < (im->sx -1));
+ ix = x;
} while(iy++ < (im->sy -1));
goto done;
}
diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h
index f33c5bdcd..da4f40724 100644
--- a/ext/gd/php_gd.h
+++ b/ext/gd/php_gd.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2011 The PHP Group |
+ | Copyright (c) 1997-2012 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_gd.h 306939 2011-01-01 02:19:59Z felipe $ */
+/* $Id: php_gd.h 321634 2012-01-01 13:15:04Z felipe $ */
#ifndef PHP_GD_H
#define PHP_GD_H
diff --git a/ext/gd/tests/bug60160.phpt b/ext/gd/tests/bug60160.phpt
new file mode 100644
index 000000000..af2df4182
--- /dev/null
+++ b/ext/gd/tests/bug60160.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #60160 (imagefill does not work correctly for small images) @see bug51671
+--SKIPIF--
+<?php
+ if(!extension_loaded('gd')){ die('skip gd extension not available'); }
+?>
+--FILE--
+<?php
+$w = 3;
+$h = 50;
+$im = imagecreatetruecolor($w, $h);
+$white = imagecolorallocate($im, 255, 255, 255);
+imagefill($im, 0, 0, $white);
+
+for ($ix = 0; $ix < $w; $ix++) {
+ for ($iy = 0; $iy < $h; $iy++) {
+ if (($c = imagecolorat($im, $ix, $iy)) != $white) {
+ printf("Failed, ($ix, $iy) is %X\n", $c);
+ }
+ }
+}
+
+echo "OK\n";
+?>
+--EXPECTF--
+OK
diff --git a/ext/gd/tests/image_type_to_mime_type_basic.phpt b/ext/gd/tests/image_type_to_mime_type_basic.phpt
deleted file mode 100644
index b81bdbde5..000000000
--- a/ext/gd/tests/image_type_to_mime_type_basic.phpt
+++ /dev/null
@@ -1,63 +0,0 @@
---TEST--
-image_type_to_mime_type()
---SKIPIF--
-<?php
- if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available');
-?>
---FILE--
-<?php
-
-/* Prototype : string image_type_to_mime_type ( int $imagetype )
- * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype.
- * Source code: ext/standard/image.c
- * Alias to functions:
- */
-
-echo "Starting image_type_to_mime_type() test\n\n";
-
-$image_types = array (
- IMAGETYPE_GIF,
- IMAGETYPE_JPEG,
- IMAGETYPE_PNG,
- IMAGETYPE_SWF,
- IMAGETYPE_PSD,
- IMAGETYPE_BMP,
- IMAGETYPE_TIFF_II,
- IMAGETYPE_TIFF_MM,
- IMAGETYPE_JPC,
- IMAGETYPE_JP2,
- IMAGETYPE_JPX,
- IMAGETYPE_JB2,
- IMAGETYPE_IFF,
- IMAGETYPE_WBMP,
- IMAGETYPE_JPEG2000,
- IMAGETYPE_XBM
-);
-
- foreach($image_types as $image_type) {
- var_dump(image_type_to_mime_type($image_type));
- }
-
-echo "\nDone image_type_to_mime_type() test\n";
-?>
---EXPECT--
-Starting image_type_to_mime_type() test
-
-string(9) "image/gif"
-string(10) "image/jpeg"
-string(9) "image/png"
-string(29) "application/x-shockwave-flash"
-string(9) "image/psd"
-string(14) "image/x-ms-bmp"
-string(10) "image/tiff"
-string(10) "image/tiff"
-string(24) "application/octet-stream"
-string(9) "image/jp2"
-string(24) "application/octet-stream"
-string(24) "application/octet-stream"
-string(9) "image/iff"
-string(18) "image/vnd.wap.wbmp"
-string(24) "application/octet-stream"
-string(9) "image/xbm"
-
-Done image_type_to_mime_type() test
diff --git a/ext/gd/tests/image_type_to_mime_type_error.phpt b/ext/gd/tests/image_type_to_mime_type_error.phpt
deleted file mode 100644
index 88aacbf17..000000000
--- a/ext/gd/tests/image_type_to_mime_type_error.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-Test image_type_to_mime_type() function : error conditions - Pass incorrect number of arguments
---FILE--
-<?php
-/* Prototype : proto string image_type_to_mime_type(int imagetype)
- * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
- * Source code: ext/standard/image.c
- */
-
-$imagetype = IMAGETYPE_GIF;
-$extra_arg = 10;
-echo "*** Testing image_type_to_mime_type() : error conditions ***\n";
-
-// Zero arguments
-echo "\n-- Testing image_type_to_mime_type() function with Zero arguments --\n";
-var_dump( image_type_to_mime_type() );
-
-//Test image_type_to_mime_type with one more than the expected number of arguments
-echo "\n-- Testing image_type_to_mime_type() function with more than expected no. of arguments --\n";
-var_dump( image_type_to_mime_type($imagetype, $extra_arg) );
-?>
-===DONE===
---EXPECTF--
-*** Testing image_type_to_mime_type() : error conditions ***
-
--- Testing image_type_to_mime_type() function with Zero arguments --
-
-Warning: image_type_to_mime_type() expects exactly 1 parameter, 0 given in %simage_type_to_mime_type_error.php on line 13
-NULL
-
--- Testing image_type_to_mime_type() function with more than expected no. of arguments --
-
-Warning: image_type_to_mime_type() expects exactly 1 parameter, 2 given in %simage_type_to_mime_type_error.php on line 17
-NULL
-===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/image_type_to_mime_type_variation1.phpt b/ext/gd/tests/image_type_to_mime_type_variation1.phpt
deleted file mode 100644
index 0023b7125..000000000
--- a/ext/gd/tests/image_type_to_mime_type_variation1.phpt
+++ /dev/null
@@ -1,152 +0,0 @@
---TEST--
-Test image_type_to_mime_type() function : usage variations - Pass different data types as imagetype
---FILE--
-<?php
-/* Prototype : string image_type_to_mime_type(int imagetype)
- * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
- * Source code: ext/standard/image.c
- */
-
-echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
-
-error_reporting(E_ALL ^ E_NOTICE);
-
-//get an unset variable
-$unset_var = 10;
-unset ($unset_var);
-
-class MyClass
-{
- function __toString() {
- return "MyClass";
- }
-}
-
-//array of values to iterate over
-$values = array(
-
- // float data
- 100.5,
- -100.5,
- 100.1234567e10,
- 100.7654321E-10,
- .5,
-
- // array data
- array(),
- array('color' => 'red', 'item' => 'pen'),
-
- // null data
- NULL,
- null,
-
- // boolean data
- true,
- false,
- TRUE,
- FALSE,
-
- // empty data
- "",
- '',
-
- // string data
- "string",
- 'string',
-
- // object data
- new MyClass(),
-
- // undefined data
- @$undefined_var,
-
- // unset data
- @$unset_var,
-);
-
-// loop through each element of the array for imagetype
-$iterator = 1;
-foreach($values as $value) {
- echo "\n-- Iteration $iterator --\n";
- var_dump( image_type_to_mime_type($value) );
- $iterator++;
-};
-?>
-===DONE===
---EXPECTF--
-*** Testing image_type_to_mime_type() : usage variations ***
-
--- Iteration 1 --
-string(24) "application/octet-stream"
-
--- Iteration 2 --
-string(24) "application/octet-stream"
-
--- Iteration 3 --
-string(24) "application/octet-stream"
-
--- Iteration 4 --
-string(24) "application/octet-stream"
-
--- Iteration 5 --
-string(24) "application/octet-stream"
-
--- Iteration 6 --
-
-Warning: image_type_to_mime_type() expects parameter 1 to be long, array given in %s on line %d
-NULL
-
--- Iteration 7 --
-
-Warning: image_type_to_mime_type() expects parameter 1 to be long, array given in %s on line %d
-NULL
-
--- Iteration 8 --
-string(24) "application/octet-stream"
-
--- Iteration 9 --
-string(24) "application/octet-stream"
-
--- Iteration 10 --
-string(9) "image/gif"
-
--- Iteration 11 --
-string(24) "application/octet-stream"
-
--- Iteration 12 --
-string(9) "image/gif"
-
--- Iteration 13 --
-string(24) "application/octet-stream"
-
--- Iteration 14 --
-
-Warning: image_type_to_mime_type() expects parameter 1 to be long, string given in %s on line %d
-NULL
-
--- Iteration 15 --
-
-Warning: image_type_to_mime_type() expects parameter 1 to be long, string given in %s on line %d
-NULL
-
--- Iteration 16 --
-
-Warning: image_type_to_mime_type() expects parameter 1 to be long, string given in %s on line %d
-NULL
-
--- Iteration 17 --
-
-Warning: image_type_to_mime_type() expects parameter 1 to be long, string given in %s on line %d
-NULL
-
--- Iteration 18 --
-
-Warning: image_type_to_mime_type() expects parameter 1 to be long, object given in %s on line %d
-NULL
-
--- Iteration 19 --
-string(24) "application/octet-stream"
-
--- Iteration 20 --
-string(24) "application/octet-stream"
-===DONE=== \ No newline at end of file
diff --git a/ext/gd/tests/image_type_to_mime_type_variation2.phpt b/ext/gd/tests/image_type_to_mime_type_variation2.phpt
deleted file mode 100644
index 141bc576f..000000000
--- a/ext/gd/tests/image_type_to_mime_type_variation2.phpt
+++ /dev/null
@@ -1,80 +0,0 @@
---TEST--
-Test image_type_to_mime_type() function : usage variations - Pass decimal, octal, and hexadecimal values as imagetype
---FILE--
-<?php
-/* Prototype : string image_type_to_mime_type(int imagetype)
- * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
- * Source code: ext/standard/image.c
- */
-
-echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
-
-error_reporting(E_ALL ^ E_NOTICE);
-$values = array (
- //Decimal values
- 0,
- 1,
- 12345,
- -12345,
-
- //Octal values
- 02,
- 010,
- 030071,
- -030071,
-
- //Hexadecimal values
- 0x0,
- 0x1,
- 0xABCD,
- -0xABCD
-);
-
-// loop through each element of the array for imagetype
-$iterator = 1;
-foreach($values as $value) {
- echo "\n-- Iteration $iterator --\n";
- var_dump( image_type_to_mime_type($value) );
- $iterator++;
-};
-?>
-===DONE===
---EXPECT--
-*** Testing image_type_to_mime_type() : usage variations ***
-
--- Iteration 1 --
-string(24) "application/octet-stream"
-
--- Iteration 2 --
-string(9) "image/gif"
-
--- Iteration 3 --
-string(24) "application/octet-stream"
-
--- Iteration 4 --
-string(24) "application/octet-stream"
-
--- Iteration 5 --
-string(10) "image/jpeg"
-
--- Iteration 6 --
-string(10) "image/tiff"
-
--- Iteration 7 --
-string(24) "application/octet-stream"
-
--- Iteration 8 --
-string(24) "application/octet-stream"
-
--- Iteration 9 --
-string(24) "application/octet-stream"
-
--- Iteration 10 --
-string(9) "image/gif"
-
--- Iteration 11 --
-string(24) "application/octet-stream"
-
--- Iteration 12 --
-string(24) "application/octet-stream"
-===DONE===
diff --git a/ext/gd/tests/image_type_to_mime_type_variation3.phpt b/ext/gd/tests/image_type_to_mime_type_variation3.phpt
deleted file mode 100644
index 8383facb0..000000000
--- a/ext/gd/tests/image_type_to_mime_type_variation3.phpt
+++ /dev/null
@@ -1,76 +0,0 @@
---TEST--
-Test image_type_to_mime_type() function : usage variations - Pass equivalent imagetype constant integer values
---FILE--
-<?php
-/* Prototype : string image_type_to_mime_type(int imagetype)
- * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
- * Source code: ext/standard/image.c
- */
-
-echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
-
-//There are 17 imagetypes
-$number_of_imagetypes = 17;
-
-$iterator = 1;
-for($imagetype = 1; $imagetype<=$number_of_imagetypes; $imagetype++) {
- echo "\n-- Iteration $iterator --\n";
- var_dump( image_type_to_mime_type($imagetype) );
- $iterator++;
-}
-?>
-===DONE===
---EXPECTREGEX--
-\*\*\* Testing image_type_to_mime_type\(\) : usage variations \*\*\*
-
--- Iteration 1 --
-string\(9\) "image\/gif"
-
--- Iteration 2 --
-string\(10\) "image\/jpeg"
-
--- Iteration 3 --
-string\(9\) "image\/png"
-
--- Iteration 4 --
-string\(29\) "application\/x-shockwave-flash"
-
--- Iteration 5 --
-string\(9\) "image\/psd"
-
--- Iteration 6 --
-string\(14\) "image\/x-ms-bmp"
-
--- Iteration 7 --
-string\(10\) "image\/tiff"
-
--- Iteration 8 --
-string\(10\) "image\/tiff"
-
--- Iteration 9 --
-string\(24\) "application\/octet-stream"
-
--- Iteration 10 --
-string\(9\) "image\/jp2"
-
--- Iteration 11 --
-string\(24\) "application\/octet-stream"
-
--- Iteration 12 --
-string\(24\) "application\/octet-stream"
-
--- Iteration 13 --
-string\(2[49]\) "application\/(x-shockwave-flash|octet-stream)"
-
--- Iteration 14 --
-string\(9\) "image\/iff"
-
--- Iteration 15 --
-string\(18\) "image\/vnd.wap.wbmp"
-
--- Iteration 16 --
-string\(9\) "image\/xbm"
-
--- Iteration 17 --
-string\(24\) "image\/vnd.microsoft.icon"
-===DONE===
diff --git a/ext/gd/tests/image_type_to_mime_type_variation4.phpt b/ext/gd/tests/image_type_to_mime_type_variation4.phpt
deleted file mode 100644
index a67bb86a6..000000000
--- a/ext/gd/tests/image_type_to_mime_type_variation4.phpt
+++ /dev/null
@@ -1,29 +0,0 @@
---TEST--
-Test image_type_to_mime_type() function : usage variations - Passing IMAGETYPE_ICO and IMAGETYPE_SWC
---SKIPIF--
-<?php
- if (!defined("IMAGETYPE_SWC") || !defined("IMAGETYPE_ICO") || !extension_loaded('zlib')) {
- die("skip zlib extension is not available or IMAGETYPE_SWC/IMAGETYPE_ICO is not defined ");
- }
-?>
---FILE--
-<?php
-/* Prototype : string image_type_to_mime_type(int imagetype)
- * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
- * Source code: ext/standard/image.c
- */
-
-
-echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
-
-error_reporting(E_ALL ^ E_NOTICE);
-
-var_dump( image_type_to_mime_type(IMAGETYPE_ICO) );
-var_dump( image_type_to_mime_type(IMAGETYPE_SWC) );
-?>
-===DONE===
---EXPECT--
-*** Testing image_type_to_mime_type() : usage variations ***
-string(24) "image/vnd.microsoft.icon"
-string(29) "application/x-shockwave-flash"
-===DONE===