使用imagettftext创建的文本确实具有完全不同的颜色,因为它应该具有(主要是 insertet png 图的颜色)。为什么不上色?它必须是函数resizePictureAndPlaceOnSign中的某些内容,因为如果我将其注释掉,那就完美了。
public function resizePictureAndPlaceOnSign($filename, $new_width, $dst_x, $dst_y){
// create figure in memory
$figure = imagecreatefrompng($filename);
/*
CALC RATIO
*/
list($width, $height) = getimagesize($filename);
$vh = ($height/$width);
$new_height = $vh*$new_width;
$rnd_new_height = round($new_height, 0);
/*
*/
// make the figure smaller
imagecopyresampled($this->picture, $figure, $dst_x, $dst_y, 0, 0, $new_width, $new_height, $width, $height);
imagedestroy($figure);
}
public function drawPicture()
{
// $zufall = rand(1,999);
// create picture
$schild_leere_vorlage = imagecreatefrompng("schild_vorlage.png");
$this->picture = imagecreate(600,192);
// copy the image into the other image
# int ImageCopy ( resource $dst_im , resource $src_im , int $dst_x , int $dst_y , int $src_x , int $src_y , int $src_w , int $src_h )
imagecopy($this->picture, $schild_leere_vorlage, 0, 0, 0, 0, 600, 192);
$filename = "figures/" . $_GET['figure'] . ".png";
/*********************/
$this->resizePictureAndPlaceOnSign($filename, 100, 25, 25);
// create colors
$color = 0x00000000FF;
$color = imagecolorallocate ($this->picture, 0, 0, 255);
// create text
imagettftext($this->picture, $this->fontSize , 0, 125, 100,$color , "cooperm.TTF", $this->name);
// header("Content-Type: image/jpeg");
imagepng($this->picture);
//$this->checkFontSize();
imagedestroy($this->picture);
}
}