-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #53580: During resize gdImageCopyResampled cause colors change
We port the upstream fix[1], and also revert commit a3383ac[2] which is now obsolete, and also not part of libgd. Especially the change to gd.png.c was at best a half-baked optimization. [1] <libgd/libgd@a24e96f> [2] <a3383ac> Closes GH-7402.
- Loading branch information
Showing
4 changed files
with
43 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
Bug #53580 (During resize gdImageCopyResampled cause colors change) | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('gd')) die("skip gd extension not available"); | ||
if (!GD_BUNDLED && version_compare(GD_VERSION, "2.3.2") <= 0) { | ||
die("skip test requires GD > 2.3.2"); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
$w0 = 100; | ||
$h0 = 100; | ||
$w1 = 150; | ||
$h1 = 150; | ||
$c0 = 0xffffff; | ||
|
||
$im0 = imagecreatetruecolor($w0, $h0); | ||
imagefilledrectangle($im0, 0, 0, $w0 - 1, $h0 - 1, $c0); | ||
|
||
$im1 = imagecreatetruecolor($w1, $h1); | ||
imagecopyresampled($im1, $im0, 0, 0, 0, 0, $w1, $h1, $w0, $h0); | ||
|
||
for ($i = 0; $i < $w1; $i++) { | ||
for ($j = 0; $j < $h1; $j++) { | ||
if (($c1 = imagecolorat($im1, $i, $j)) !== $c0) { | ||
printf("%d,%d = %d\n", $i, $j, $c1); | ||
} | ||
} | ||
} | ||
?> | ||
--EXPECT-- |