forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolorat.phpt
42 lines (36 loc) · 846 Bytes
/
colorat.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--TEST--
imagecolorat
--SKIPIF--
<?php
if (!function_exists('imagecolorat')) die("skip gd extension not available\n");
?>
--FILE--
<?php
$file = dirname(__FILE__) . '/im.wbmp';
$im = imagecreatetruecolor(6,6);
imagefill($im, 0,0, 0xffffff);
imagesetpixel($im, 3,3, 0x0);
echo 'test colorat truecolor: ';
$c = imagecolorat($im, 3,3);
echo $c == 0x0 ? 'ok' : 'failed';
echo "\n";
imagedestroy($im);
$im = imagecreate(6,6);
$c1 = imagecolorallocate($im, 255,255,255);
$c2 = imagecolorallocate($im, 0,0,0);
imagefill($im, 0,0, $c1);
imagesetpixel($im, 3,3, $c2);
echo 'test colorat palette: ';
$c = imagecolorsforindex($im, imagecolorat($im, 3,3));
$failed = false;
foreach ($c as $v) {
if ($v != 0) {
$failed = true;
}
}
echo !$failed ? 'ok' : 'failed';
echo "\n";
?>
--EXPECT--
test colorat truecolor: ok
test colorat palette: ok