我正在使用 imagesetpixel() 为字母“x”绘制一个灰色像素,为字母“o”绘制一个黑色像素。如果您只输入约 250 个或更少的 X 和 O,它工作正常,但如果您输入更多,出于某种奇怪的原因,只会绘制前约 250 个 X 和 O,其余的则不会。有谁知道我该如何解决这个问题?
作为旁注,在未来,我可能希望能够用其他字母替换我选择的自己的颜色,所以请记住这一点(例如 a = 红色,b = 蓝色,c = 绿色,d = 橙色等)。
...
$image = imagecreate($xdim, $ydim);
for(...){
if( $string{$i} == "o" ){
$color = 0;
} else if( $string{$i} == "x" ){
$color = 170;
}
imagesetpixel($image, $x, $y, imagecolorallocate($image, $color, $color, $color));
...
}