我在PHP中向动态图像添加图像时遇到问题: 这是我的代码:
<?php
$my_img = imagecreate( 500, 70 );
$background = imagecolorallocate( $my_img, 0, 0, 255 );
$text_colour = imagecolorallocate( $my_img, 255, 255, 0 );
$line_colour = imagecolorallocate( $my_img, 128, 255, 0 );
imagestring( $my_img, 4, 30, 25, getStatus(), $text_colour );
imagesetthickness ( $my_img, 5 );
header( "Content-type: image/png" );
imagepng( $my_img);
imagecolordeallocate( $line_color );
imagecolordeallocate( $text_color );
imagecolordeallocate( $background );
imagedestroy( $my_img );
function getStatus(){
include_once 'status.php'; //include the class
$status = new MinecraftServerStatus(); // call the class
$response = $status->getStatus('XXX'); // call the function
if(!$response) {
return "Offline :(";
} else {
return ("Online: " . $response['players']);
}
}
?>
结果是:http://kukubaczek.cf/s/sign.php我要添加背景图片:http://kukubaczek.cf/s/tlo.png如何做到这一点?