我尝试使用imagecolorat()从每个像素获取rgb颜色信息,但我不确定将RGB值保存到$xy()中的语法是否正确。我正在看文档,但我仍然不明白哪里出了问题。
我的错误显示: Parse error:语法错误,在/sites/uploadresults.php ts.php的第69行出现意外的',‘
#loop to populate rgb values and save to array: $xy
$imagew = imagesx($img);
$imageh = imagesy($img);
$xy = array(i);
echo "Image (w,h): ($imagew, $imageh)<br/>";
$x = 0;
$y = 0;
for ($x = 0; $x <= $imagew; $x++) {
for ($y = 0;$y <= $imageh; $y++ ) {
$rgb = imagecolorat($img, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
#loop to save ($r,$g,$b) into $xy
for ($i = 0; $i <= $xytotal; $i++) {
$xy[i] = ($r, $g, $b);
}
echo "xy: $xy x: $x, y: $y <br/>";
var_dump($r, $g, $b);
}
}完整的代码在这里:http://pastebin.com/ZNDEzXFK
提前感谢!
发布于 2011-08-06 04:56:10
我想应该是
$xy[i] = array($r, $g, $b);IOW是由数组组成的数组,每个子数组$xy是三倍?
顺便说一下,开头的行$xy = array(i);看起来很可疑,我想应该只是$xy = array();,即你把它初始化为空数组。
https://stackoverflow.com/questions/6962481
复制相似问题