xref: /PHP-8.1/ext/gd/tests/bug73281.phpt (revision a375d547)
1--TEST--
2Bug #73281 (imagescale(…, IMG_BILINEAR_FIXED) can cause black border)
3--EXTENSIONS--
4gd
5--SKIPIF--
6<?php
7if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.3', '<=')) die('skip upstream fix not yet released');
8?>
9--FILE--
10<?php
11$coordinates = [[0, 0], [0, 199], [199, 199], [199, 0]];
12
13$src = imagecreatetruecolor(100, 100);
14$white = imagecolorallocate($src, 255, 255, 255);
15imagefilledrectangle($src, 0,0, 99,99, $white);
16$dst = imagescale($src, 200, 200, IMG_BILINEAR_FIXED);
17echo "truecolor source\n";
18foreach ($coordinates as $coordinate) {
19    list($x, $y) = $coordinate;
20    printf("%3d, %3d: %x\n", $x, $y, imagecolorat($dst, $x, $y));
21}
22
23$src = imagecreate(100, 100);
24$white = imagecolorallocate($src, 255, 255, 255);
25imagefilledrectangle($src, 0,0, 99,99, $white);
26$dst = imagescale($src, 200, 200, IMG_BILINEAR_FIXED);
27echo "\npalette source\n";
28foreach ($coordinates as $coordinate) {
29    list($x, $y) = $coordinate;
30    printf("%3d, %3d: %x\n", $x, $y, imagecolorat($dst, $x, $y));
31}
32?>
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