mirror of
https://github.com/php/php-src.git
synced 2026-03-28 02:02:32 +01:00
- MFB: #40764, line thickness not respected for horizontal and vertical
lines
This commit is contained in:
@@ -1032,25 +1032,37 @@ void gdImageLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color)
|
||||
|
||||
/* Vertical */
|
||||
if (x1==x2) {
|
||||
if (y2 < y1) {
|
||||
t = y2;
|
||||
y2 = y1;
|
||||
y1 = t;
|
||||
}
|
||||
if (thick > 1) {
|
||||
int thickhalf = thick >> 1;
|
||||
thickhalf = thick >> 1;
|
||||
gdImageFilledRectangle(im, x1 - thickhalf, y1, x1 + thick - thickhalf - 1, y2, color);
|
||||
} else {
|
||||
if (y2 < y1) {
|
||||
t = y2;
|
||||
y2 = y1;
|
||||
y1 = t;
|
||||
}
|
||||
|
||||
for (;y1 <= y2; y1++) {
|
||||
gdImageSetPixel(im, x1,y1, color);
|
||||
for (;y1 <= y2; y1++) {
|
||||
gdImageSetPixel(im, x1,y1, color);
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (y1==y2) { /* Horizontal */
|
||||
if (x2 < x1) {
|
||||
t = x2;
|
||||
x2 = x1;
|
||||
x1 = t;
|
||||
}
|
||||
} else if (y1==y2) { /* Horizontal */
|
||||
if (thick > 1) {
|
||||
int thickhalf = thick >> 1;
|
||||
thickhalf = thick >> 1;
|
||||
gdImageFilledRectangle(im, x1, y1 - thickhalf, x2, y2 + thick - thickhalf - 1, color);
|
||||
} else {
|
||||
if (x2 < x1) {
|
||||
t = x2;
|
||||
x2 = x1;
|
||||
x1 = t;
|
||||
}
|
||||
|
||||
for (;x1 <= x2; x1++) {
|
||||
gdImageSetPixel(im, x1,y1, color);
|
||||
for (;x1 <= x2; x1++) {
|
||||
gdImageSetPixel(im, x1,y1, color);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
31
ext/gd/tests/bug40764.phpt
Normal file
31
ext/gd/tests/bug40764.phpt
Normal file
@@ -0,0 +1,31 @@
|
||||
--TEST--
|
||||
Bug #40764 (line thickness not respected for horizontal and vertical lines)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die("skip gd extension not available\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$image=imagecreatetruecolor(400, 400);
|
||||
$white = imagecolorallocate($image, 255, 255, 255);
|
||||
$black = imagecolorallocate($image, 0, 0, 0);
|
||||
$red = imagecolorallocate($image, 255, 0, 0);
|
||||
|
||||
imagefill($image, 0, 0, $white);
|
||||
imagesetthickness($image, 10);
|
||||
|
||||
imageline($image, 200, 0, 200, 400, $black);
|
||||
imageline($image, 0, 200, 400, 200, $black);
|
||||
imageline($image, 0, 0, 392, 392, $black);
|
||||
|
||||
imagesetthickness($image, 1);
|
||||
|
||||
imageline($image, 200, 0, 200, 400, $red);
|
||||
imageline($image, 0, 200, 400, 200, $red);
|
||||
imageline($image, 0, 0, 392, 392, $red);
|
||||
print_r(imagecolorat($image, 195, 0));
|
||||
print_r(imagecolorat($image, 0, 195));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
00
|
||||
Reference in New Issue
Block a user