xref: /PHP-7.3/ext/gd/tests/bug73281.phpt (revision 6b4cdbaa)
1--TEST--
2Bug #73281 (imagescale(…, IMG_BILINEAR_FIXED) can cause black border)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.3', '<=')) die('skip upstream fix not yet released');
7?>
8--FILE--
9<?php
10$coordinates = [[0, 0], [0, 199], [199, 199], [199, 0]];
11
12$src = imagecreatetruecolor(100, 100);
13$white = imagecolorallocate($src, 255, 255, 255);
14imagefilledrectangle($src, 0,0, 99,99, $white);
15$dst = imagescale($src, 200, 200, IMG_BILINEAR_FIXED);
16echo "truecolor source\n";
17foreach ($coordinates as $coordinate) {
18    list($x, $y) = $coordinate;
19    printf("%3d, %3d: %x\n", $x, $y, imagecolorat($dst, $x, $y));
20}
21
22$src = imagecreate(100, 100);
23$white = imagecolorallocate($src, 255, 255, 255);
24imagefilledrectangle($src, 0,0, 99,99, $white);
25$dst = imagescale($src, 200, 200, IMG_BILINEAR_FIXED);
26echo "\npalette source\n";
27foreach ($coordinates as $coordinate) {
28    list($x, $y) = $coordinate;
29    printf("%3d, %3d: %x\n", $x, $y, imagecolorat($dst, $x, $y));
30}
31?>
32===DONE===
33--EXPECT--
34truecolor source
35  0,   0: ffffff
36  0, 199: ffffff
37199, 199: ffffff
38199,   0: ffffff
39
40palette source
41  0,   0: ffffff
42  0, 199: ffffff
43199, 199: ffffff
44199,   0: ffffff
45===DONE===
46