1--TEST-- 2Test imagecolorallocate() function : usage variations - passing RED, GREEN, BLUE values more than 255 3--SKIPIF-- 4<?php 5if(!extension_loaded('gd')) { 6 die('skip gd extension is not loaded'); 7} 8if(!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 */ 18echo "*** Testing imagecolorallocate() : usage variations ***\n"; 19 20$values = array( 21 //Decimal integera data 22 "Decimal 256" => 256, 23 24 // octal integer data 25 "Octal 0400" => 0400, 26 27 // hexa-decimal integer data 28 "Hexa-decimal 0x100" => 0x100 29); 30 31// loop through each element of the array for blue 32foreach($values as $key => $value) { 33 echo "\n--$key--\n"; 34 //Need to be created every time to get expected return value 35 $im_palette = imagecreate(200, 200); 36 $im_true_color = imagecreatetruecolor(200, 200); 37 var_dump( imagecolorallocate($im_palette, $value, 0, 0) ); 38 var_dump( imagecolorallocate($im_true_color, $value, 0, 0) ); 39 var_dump( imagecolorallocate($im_palette, 0, $value, 0) ); 40 var_dump( imagecolorallocate($im_true_color, 0, $value, 0) ); 41 var_dump( imagecolorallocate($im_palette, 0, 0, $value) ); 42 var_dump( imagecolorallocate($im_true_color, 0, 0, $value) ); 43}; 44?> 45===DONE=== 46--EXPECTF-- 47*** Testing imagecolorallocate() : usage variations *** 48 49--Decimal 256-- 50 51Warning: imagecolorallocate(): Red component is out of range in %s on line %d 52bool(false) 53 54Warning: imagecolorallocate(): Red component is out of range in %s on line %d 55bool(false) 56 57Warning: imagecolorallocate(): Green component is out of range in %s on line %d 58bool(false) 59 60Warning: imagecolorallocate(): Green component is out of range in %s on line %d 61bool(false) 62 63Warning: imagecolorallocate(): Blue component is out of range in %s on line %d 64bool(false) 65 66Warning: imagecolorallocate(): Blue component is out of range in %s on line %d 67bool(false) 68 69--Octal 0400-- 70 71Warning: imagecolorallocate(): Red component is out of range in %s on line %d 72bool(false) 73 74Warning: imagecolorallocate(): Red component is out of range in %s on line %d 75bool(false) 76 77Warning: imagecolorallocate(): Green component is out of range in %s on line %d 78bool(false) 79 80Warning: imagecolorallocate(): Green component is out of range in %s on line %d 81bool(false) 82 83Warning: imagecolorallocate(): Blue component is out of range in %s on line %d 84bool(false) 85 86Warning: imagecolorallocate(): Blue component is out of range in %s on line %d 87bool(false) 88 89--Hexa-decimal 0x100-- 90 91Warning: imagecolorallocate(): Red component is out of range in %s on line %d 92bool(false) 93 94Warning: imagecolorallocate(): Red component is out of range in %s on line %d 95bool(false) 96 97Warning: imagecolorallocate(): Green component is out of range in %s on line %d 98bool(false) 99 100Warning: imagecolorallocate(): Green component is out of range in %s on line %d 101bool(false) 102 103Warning: imagecolorallocate(): Blue component is out of range in %s on line %d 104bool(false) 105 106Warning: imagecolorallocate(): Blue component is out of range in %s on line %d 107bool(false) 108===DONE=== 109