xref: /php-src/ext/gd/tests/bug53580.phpt (revision c95e0368)
1--TEST--
2Bug #53580 (During resize gdImageCopyResampled cause colors change)
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7if (!GD_BUNDLED && version_compare(GD_VERSION, "2.3.2") <= 0) {
8    die("skip test requires GD > 2.3.2");
9}
10?>
11--FILE--
12<?php
13$w0 = 100;
14$h0 = 100;
15$w1 = 150;
16$h1 = 150;
17$c0 = 0xffffff;
18
19$im0 = imagecreatetruecolor($w0, $h0);
20imagefilledrectangle($im0, 0, 0, $w0 - 1, $h0 - 1, $c0);
21
22$im1 = imagecreatetruecolor($w1, $h1);
23imagecopyresampled($im1, $im0, 0, 0, 0, 0, $w1, $h1, $w0, $h0);
24
25for ($i = 0; $i < $w1; $i++) {
26    for ($j = 0; $j < $h1; $j++) {
27        if (($c1 = imagecolorat($im1, $i, $j)) !== $c0) {
28            printf("%d,%d = %d\n", $i, $j, $c1);
29        }
30    }
31}
32?>
33--EXPECT--
34