我希望在使用imagefilledrectangle
创建图像后增加图像的宽度。
这是我的代码。
$image = imagecreate($img_width+10, $img_height + $text_height);
$black = imagecolorallocate ($image, 0, 0, 0);
$white = imagecolorallocate ($image, 255, 255, 255);
imagefill( $image, 0, 0, $white );
if ( $print ) {
imagestring($image, 10, 50, $img_height+2, $text, $black );
}
$location = 10;
for ( $position = 1 ; $position <= strlen($code_string); $position++ ) {
$cur_size = $location + ( substr($code_string, ($position-1), 1) );
if ( strtolower($orientation) == "horizontal" )
imagefilledrectangle( $image, $location, 0, $cur_size, $img_height, ($position % 2 == 0 ? $white : $black) );
else
imagefilledrectangle( $image, 0, $location, $img_width, $cur_size, ($position % 2 == 0 ? $white : $black) );
$location = $cur_size;
}
return $image;