color3

For Truecolor images the colors are simple 31-bit longs. Or,it is composed of 4 bytes .

The highest or leftmost bit in the alpha channel is not used which means the alpha channel can onlyhave values from 0 to 127.  You can use the ImageColorAllocate() as with paletted images, but you can also specify the color
directly.

<?php

$im  = ImageCreateTruecolor(300,256);

for($r=0; $r<256; $r++)

{

$col = ImageColorAllocate($im,$r,0,0);

ImageLine($im, 0,$r, 100, $r, $col);

}

for($g=0; $g<256; $g++)

{

$col = ImageColorAllocate($im,0,$g,0);

ImageLine($im, 100,255-$g, 200, 255-$g,
$col);

}

for($b=0; $b<256; $b++)

{

$col = ImageColorAllocate($im,0,0,$b);

ImageLine($im, 200,$b, 300, $b, $col);

}

Header('Content-Type: image/png');ImagePNG($im);

?>

output:

<?

$im = ImageCreateTrueColor(256,60);

for($x=0; $x<256; $x++)

{

ImageLine($im, $x, 0, $x, 19, $x);

ImageLine($im, 255-$x, 20, 255-$x, 39, $x<<8);

ImageLine($im, $x, 40, $x, 59, $x<<16);

}

Header('Content-Type: image/png');ImagePNG($im);

?>

output: