tags:

views:

35

answers:

1

How would you get the colors from an allocated color something like...

$col = imagecolorallocate($im, 255, 50, 5);
//A fake function - rgbfromallocate (that I wish I knew)

$rgb = rgbfromallocate($col);
print $rgb['r'];//255
print $rgb['g'];//50
print $rgb['b'];//5
+2  A: 

Maybe imagecolorsforindex() is what you're looking for?

For example:

// $img is an image
$color = imagecolorallocate($img, 255, 50, 5);

$rgb = imagecolorsforindex($img, $color);
print $rgb['red']; // 255
print $rgb['green']; // 50
print $rgb['blue']; // 5
print $rgb['alpha']; // 0, but if the image uses the alpha channel,
// this would have a value of up to 127, which is fully transparent
Frxstrem
Works perfect, I had thought that function only worked in use with imagecolorat but that was exactly it.
Mark