mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
- #45905, imagefilledrectangle() clipping error
This commit is contained in:
parent
4f0c8ef124
commit
b38fde4694
1 changed files with 22 additions and 15 deletions
|
@ -2114,33 +2114,40 @@ void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
/* Nick Atty: limit the points at the edge. Note that this also
|
|
||||||
* nicely kills any plotting for rectangles completely outside the
|
if (x1 == x2 && y1 == y2) {
|
||||||
* window as it makes the tests in the for loops fail
|
gdImageSetPixel(im, x1, y1, color);
|
||||||
*/
|
return;
|
||||||
if (x1 < 0) {
|
|
||||||
x1 = 0;
|
|
||||||
}
|
|
||||||
if (x1 > gdImageSX(im)) {
|
|
||||||
x1 = gdImageSX(im);
|
|
||||||
}
|
|
||||||
if(y1 < 0) {
|
|
||||||
y1 = 0;
|
|
||||||
}
|
|
||||||
if (y1 > gdImageSY(im)) {
|
|
||||||
y1 = gdImageSY(im);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x1 > x2) {
|
if (x1 > x2) {
|
||||||
x = x1;
|
x = x1;
|
||||||
x1 = x2;
|
x1 = x2;
|
||||||
x2 = x;
|
x2 = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y1 > y2) {
|
if (y1 > y2) {
|
||||||
y = y1;
|
y = y1;
|
||||||
y1 = y2;
|
y1 = y2;
|
||||||
y2 = y;
|
y2 = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (x1 < 0) {
|
||||||
|
x1 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x2 >= gdImageSX(im)) {
|
||||||
|
x2 = gdImageSX(im) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y1 < 0) {
|
||||||
|
y1 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y2 >= gdImageSY(im)) {
|
||||||
|
y2 = gdImageSY(im) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
for (y = y1; (y <= y2); y++) {
|
for (y = y1; (y <= y2); y++) {
|
||||||
for (x = x1; (x <= x2); x++) {
|
for (x = x1; (x <= x2); x++) {
|
||||||
gdImageSetPixel (im, x, y, color);
|
gdImageSetPixel (im, x, y, color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue