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);
开发者_StackOverflow中文版print $rgb['r'];//255
print $rgb['g'];//50
print $rgb['b'];//5
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
精彩评论