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