hiphop-php /hphp/test/zend/good/ext/gd/tests/colorclosest.php

Language PHP Lines 72
MD5 Hash dac946009efd1096cde6b2a34de5e9ce Estimated Cost $1,261 (why?)
Repository git://github.com/facebook/hiphop-php.git View Raw File View Project SPDX
 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php

$im = imagecreatetruecolor(5,5);
$c = imagecolorclosest($im, 255,0,255);
printf("%X\n", $c);
imagedestroy($im);

$im = imagecreate(5,5);
$c = imagecolorclosest($im, 255,0,255);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);

$im = imagecreate(5,5);
imagecolorallocate($im, 255, 0, 255);
$c = imagecolorclosest($im, 255,0,255);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);

$im = imagecreate(5,5);
for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0);
$c = imagecolorclosest($im, 255,0,0);
print_r(imagecolorsforindex($im, $c));


$im = imagecreate(5,5);
for ($i=0; $i<256; $i++) {
	if ($i == 246) {
		imagecolorallocate($im, $i,10,10);
	} else {
		imagecolorallocate($im, $i,0,0);
	}
}
$c = imagecolorclosest($im, 255,10,10);
print_r(imagecolorsforindex($im, $c));

// with alpha
$im = imagecreatetruecolor(5,5);
$c = imagecolorclosestalpha($im, 255,0,255,100);
printf("%X\n", $c);
imagedestroy($im);

$im = imagecreate(5,5);
$c = imagecolorclosestalpha($im, 255,0,255,100);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);

$im = imagecreate(5,5);
imagecolorallocatealpha($im, 255, 0, 255, 1);
$c = imagecolorclosestalpha($im, 255,0,255,1);
print_r(imagecolorsforindex($im, $c));
imagedestroy($im);

$im = imagecreate(5,5);
for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1);
$c = imagecolorclosestalpha($im, 255,0,0,1);
print_r(imagecolorsforindex($im, $c));


$im = imagecreate(5,5);
for ($i=0; $i<256; $i++) {
	if ($i == 246) {
		imagecolorallocatealpha($im, $i,10,10,1);
	} else {
		imagecolorallocatealpha($im, $i,0,0,100);
	}
}
$c = imagecolorclosestalpha($im, 255,10,10,1);
print_r(imagecolorsforindex($im, $c));


?>
Back to Top