mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Merge branch 'PHP-5.6'
* PHP-5.6: updated NEWS revised bug53156.phpt Fix #53156: imagerectangle problem with point ordering
This commit is contained in:
commit
16d6a93f09
2 changed files with 60 additions and 1 deletions
|
@ -2046,7 +2046,9 @@ void gdImageRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||||
t=y1;
|
t=y1;
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
y2 = t;
|
y2 = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x2 < x1) {
|
||||||
t = x1;
|
t = x1;
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
x2 = t;
|
x2 = t;
|
||||||
|
|
57
ext/gd/tests/bug53156.phpt
Normal file
57
ext/gd/tests/bug53156.phpt
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #53156 (imagerectangle problem with point ordering)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
function draw_and_check_pixel($x, $y)
|
||||||
|
{
|
||||||
|
global $img, $black, $red;
|
||||||
|
|
||||||
|
echo (imagecolorat($img, $x, $y) === $black) ? '+' : '-';
|
||||||
|
imagesetpixel($img, $x, $y, $red);
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw_and_check_rectangle($x1, $y1, $x2, $y2)
|
||||||
|
{
|
||||||
|
global $img, $black;
|
||||||
|
|
||||||
|
echo 'Rectangle: ';
|
||||||
|
imagerectangle($img, $x1, $y1, $x2, $y2, $black);
|
||||||
|
$x = ($x1 + $x2) / 2;
|
||||||
|
$y = ($y1 + $y2) / 2;
|
||||||
|
draw_and_check_pixel($x, $y1);
|
||||||
|
draw_and_check_pixel($x1, $y);
|
||||||
|
draw_and_check_pixel($x, $y2);
|
||||||
|
draw_and_check_pixel($x2, $y);
|
||||||
|
echo PHP_EOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
$img = imagecreate(110, 210);
|
||||||
|
$bgnd = imagecolorallocate($img, 255, 255, 255);
|
||||||
|
$black = imagecolorallocate($img, 0, 0, 0);
|
||||||
|
$red = imagecolorallocate($img, 255, 0, 0);
|
||||||
|
|
||||||
|
draw_and_check_rectangle( 10, 10, 50, 50);
|
||||||
|
draw_and_check_rectangle( 50, 60, 10, 100);
|
||||||
|
draw_and_check_rectangle( 50, 150, 10, 110);
|
||||||
|
draw_and_check_rectangle( 10, 200, 50, 160);
|
||||||
|
imagesetthickness($img, 4);
|
||||||
|
draw_and_check_rectangle( 60, 10, 100, 50);
|
||||||
|
draw_and_check_rectangle(100, 60, 60, 100);
|
||||||
|
draw_and_check_rectangle(100, 150, 60, 110);
|
||||||
|
draw_and_check_rectangle( 60, 200, 100, 160);
|
||||||
|
|
||||||
|
//imagepng($img, __DIR__ . '/bug53156.png'); // debug
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
Rectangle: ++++
|
||||||
|
Rectangle: ++++
|
||||||
|
Rectangle: ++++
|
||||||
|
Rectangle: ++++
|
||||||
|
Rectangle: ++++
|
||||||
|
Rectangle: ++++
|
||||||
|
Rectangle: ++++
|
||||||
|
Rectangle: ++++
|
Loading…
Add table
Add a link
Reference in a new issue