xref: /PHP-7.3/ext/gd/tests/colorresolve.phpt (revision ded3d984)
1--TEST--
2imagecolorresolve
3--SKIPIF--
4<?php
5        if (!function_exists('imagecolorresolve')) die("skip gd extension not available\n");
6?>
7--FILE--
8<?php
9
10$im = imagecreatetruecolor(5,5);
11$c = imagecolorresolve($im, 255,0,255);
12printf("%X\n", $c);
13imagedestroy($im);
14
15$im = imagecreate(5,5);
16$c = imagecolorresolve($im, 255,0,255);
17print_r(imagecolorsforindex($im, $c));
18imagedestroy($im);
19
20$im = imagecreate(5,5);
21for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0);
22$c = imagecolorresolve($im, 255,0,0);
23print_r(imagecolorsforindex($im, $c));
24
25
26$im = imagecreate(5,5);
27for ($i=0; $i<256; $i++) {
28	if ($i == 246) {
29		imagecolorresolve($im, $i,10,10);
30	} else {
31		imagecolorresolve($im, $i,0,0);
32	}
33}
34$c = imagecolorresolve($im, 255,10,10);
35print_r(imagecolorsforindex($im, $c));
36
37
38
39// with alpha
40$im = imagecreatetruecolor(5,5);
41$c = imagecolorresolvealpha($im, 255,0,255, 100);
42printf("%X\n", $c);
43imagedestroy($im);
44
45$im = imagecreate(5,5);
46$c = imagecolorresolvealpha($im, 255,0,255,100);
47print_r(imagecolorsforindex($im, $c));
48imagedestroy($im);
49
50$im = imagecreate(5,5);
51for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1);
52$c = imagecolorresolvealpha($im, 255,0,0,1);
53print_r(imagecolorsforindex($im, $c));
54
55
56$im = imagecreate(5,5);
57for ($i=0; $i<256; $i++) {
58	if ($i == 246) {
59		imagecolorresolvealpha($im, $i,10,10,1);
60	} else {
61		imagecolorresolvealpha($im, $i,0,0,100);
62	}
63}
64$c = imagecolorresolvealpha($im, 255,10,10,0);
65print_r(imagecolorsforindex($im, $c));
66
67
68?>
69--EXPECT--
70FF00FF
71Array
72(
73    [red] => 255
74    [green] => 0
75    [blue] => 255
76    [alpha] => 0
77)
78Array
79(
80    [red] => 255
81    [green] => 0
82    [blue] => 0
83    [alpha] => 0
84)
85Array
86(
87    [red] => 246
88    [green] => 10
89    [blue] => 10
90    [alpha] => 0
91)
9264FF00FF
93Array
94(
95    [red] => 255
96    [green] => 0
97    [blue] => 255
98    [alpha] => 100
99)
100Array
101(
102    [red] => 255
103    [green] => 0
104    [blue] => 0
105    [alpha] => 1
106)
107Array
108(
109    [red] => 246
110    [green] => 10
111    [blue] => 10
112    [alpha] => 1
113)
114