php-src/ext/gd/tests/bug53580.phpt
Christoph M. Becker 526407ca35
Fix #53580: During resize gdImageCopyResampled cause colors change
We port the upstream fix[1], and also revert commit a3383ac3d7[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] <a24e96f019>
[2] <a3383ac3d7>

Closes GH-7402.
2021-08-26 18:38:17 +02:00

33 lines
756 B
PHP

--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--