PHP GD您可以在没有 的情况下分配颜色image resource吗?这应该是可能的,因为分配的颜色实际上是一个数字,对吗?
$im = imagecreatetruecolor(100, 100);
$col = imagecolorallocate($im, 255, 0, 0);
print $col."<br/>";
$col2 = imagecolorallocate($im, 255, 0, 0);
print $col2."<br/>";
$im2 = imagecreatetruecolor(600, 100);
$col3 = imagecolorallocate($im, 255, 0, 0);
print $col3;
Run Code Online (Sandbox Code Playgroud)
这打印出:
16711680
16711680
16711680
我猜真正的问题是255、0、0如何变成16711680。