com php-src: Add regression test for bug #47946: ext/gd/tests/bug47946.phpt ext/gd/tests/bug47946_exp.png

From: Date: Sun, 22 Jan 2017 14:01:01 +0000
Subject: com php-src: Add regression test for bug #47946: ext/gd/tests/bug47946.phpt ext/gd/tests/bug47946_exp.png
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96837@lists.php.net to get a copy of this message
Commit: 71efe9d8fd0b7486c2943d267c68dcefc6c406b1 Author: Christoph M. Becker <cmbecker69@gmx.de> Sun, 22 Jan 2017 15:01:01 +0100 Parents: e56fe7e5e7a926bfdf142a7a844544c0127e92b7 Branches: PHP-7.0 PHP-7..1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=71efe9d8fd0b7486c2943d267c68dcefc6c406b1 Log: Add regression test for bug #47946 This bug had already been fixed, but apparently there's no regression test yet, so we add one. Note that the expected image has black pixel artifacts, which are another issue (perhaps bug #40158), and would have to be adressed separately. Bugs: https://bugs..php.net/47946 https://bugs.php.net/40158 Changed paths: A ext/gd/tests/bug47946.phpt A ext/gd/tests/bug47946_exp.png Diff: diff --git a/ext/gd/tests/bug47946.phpt b/ext/gd/tests/bug47946.phpt new file mode 100644 index 0000000..c845085 --- /dev/null +++ b/ext/gd/tests/bug47946.phpt @@ -0,0 +1,51 @@ +--TEST-- +Bug #47946 (ImageConvolution overwrites background) +--DESCRIPTION-- +The expected image has black pixel artifacts, what is another issue, though +(perhaps #40158). +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +?> +--FILE-- +<?php +function array_flatten($array) +{ + $tempArray = array(); + + foreach ($array as $value) { + if (is_array($value)) { + $tempArray = array_merge($tempArray, array_flatten($value)); + } else { + $tempArray[] = $value; + } + } + + return $tempArray; +} + +function makeFilter($resource, $matrix, $offset = 1.0) +{ + $divisor = array_sum(array_flatten($matrix)); + if ($divisor == 0) { + $divisor = .01; + } + return imageconvolution($resource, $matrix, $divisor, $offset); +} + +$edgeMatrix = array(array(1, 0, 1), array(0, 5, 0), array(1, 0, 1)); + +$im = imagecreatetruecolor(40, 40); +imagealphablending($im, false); +imagefilledrectangle($im, 0, 0, 39, 39, 0x7fffffff); +imagefilledellipse($im, 19, 19, 20, 20, 0x00ff00); +imagesavealpha($im, true); +makeFilter($im, $edgeMatrix); + +require_once __DIR__ . '/func.inc'; +test_image_equals_file(__DIR__ . '/bug47946_exp.png', $im); +?> +===DONE=== +--EXPECT-- +The images are equal. +===DONE=== diff --git a/ext/gd/tests/bug47946_exp.png b/ext/gd/tests/bug47946_exp.png new file mode 100644 index 0000000..7eb462d Binary files /dev/null and b/ext/gd/tests/bug47946_exp.png differ

« previous php.cvs (#96837) next »