Annotation of embedaddon/php/ext/gd/tests/imagecolorallocate_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test imagecolorallocate() function : usage variations - passing octal and hexa-decimal values
3: --SKIPIF--
4: <?php
5: if(!extension_loaded('gd')) {
6: die('skip gd extension is not loaded');
7: }
8: if(!function_exists('imagecreatetruecolor')) {
9: die('skip imagecreatetruecolor function is not available');
10: }
11: ?>
12: --FILE--
13: <?php
14: /* Prototype : int imagecolorallocate(resource im, int red, int green, int blue)
15: * Description: Allocate a color for an image
16: * Source code: ext/gd/gd.c
17: */
18: echo "*** Testing imagecolorallocate() : usage variations ***\n";
19:
20: $im = imagecreatetruecolor(200, 200);
21: $red = 10;
22: $green = 10;
23: $blue = 10;
24:
25: $values = array(
26: // octal integer data
27: "Octal 000" => 000,
28: "Octal 012" => 012,
29: "Octal -012" => -012,
30: "Octal 0377" => 0377,
31:
32: // hexa-decimal integer data
33: "Hexa-decimal 0x0" => 0x0,
34: "Hexa-decimal 0xA" => 0xA,
35: "Hexa-decimal -0xA" => -0xA,
36: "Hexa-decimal 0xFF" => 0xFF,
37: );
38:
39: // loop through each element of the array for blue
40: foreach($values as $key => $value) {
41: echo "\n--$key--\n";
42: var_dump( imagecolorallocate($im, $value, $green, $blue) );
43: var_dump( imagecolorallocate($im, $red, $value, $blue) );
44: var_dump( imagecolorallocate($im, $red, $green, $value) );
45: };
46: ?>
47: ===DONE===
48: --EXPECTF--
49: *** Testing imagecolorallocate() : usage variations ***
50:
51: --Octal 000--
52: int(2570)
53: int(655370)
54: int(657920)
55:
56: --Octal 012--
57: int(657930)
58: int(657930)
59: int(657930)
60:
61: --Octal -012--
62: bool(false)
63: int(652810)
64: int(657910)
65:
66: --Octal 0377--
67: int(16714250)
68: int(720650)
69: int(658175)
70:
71: --Hexa-decimal 0x0--
72: int(2570)
73: int(655370)
74: int(657920)
75:
76: --Hexa-decimal 0xA--
77: int(657930)
78: int(657930)
79: int(657930)
80:
81: --Hexa-decimal -0xA--
82: bool(false)
83: int(652810)
84: int(657910)
85:
86: --Hexa-decimal 0xFF--
87: int(16714250)
88: int(720650)
89: int(658175)
90: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>