如何从分配的颜色中获取颜色 类似......
$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
答案 0 :(得分:5)
也许imagecolorsforindex()
正是您要找的?
例如:
// $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