这是我到目前为止所拥有的类:
<?php
class txt2img {
var $image;
var $headertype;
var $forecolor;
var $fontsize;
var $fontangle;
var $font;
var $string;
//font size
function fontsize($fontsize) {
return $this->fontsize;
}
//forecolor
function forecolor($forecolor) {
return this->imagecolorallocate($this->img(),$this->forecolor);
}
//image file
function img($image) {
return imagecreatefrompng($this->img);
}
function display($string,$font) {
//display all errors
ini_set("display_errors", "1");
error_reporting(E_ALL);
header('content-type: image/png');
$fcolor = $this->forecolor();
imagettftext($this->img(),$this->fontsize(),0,0,$this->forecolor(),$this->font,$this->string);
imagejpg($this->img());
imagedestroy($this->img());
}
}
?>有谁知道吗?要么是太晚了,要么是我不知道,因为某些原因,我在写这篇文章的时候感到一片空白。
我希望能够首先编写属性,比如
$gd = new gd;
$gd->fontsize('12');
//..etc那么实际的输出就会写成这样
$gd->display('this is my string','myfont.ttf');发布于 2009-07-15 07:28:13
我觉得这条线不好
imagettftext($this->img(),$this->fontsize(),0,0,$this->forecolor(),$this->font,$this->string);因为您使用$this->fontsize()等方法设置了空值。
应该是这样的
imagettftext($this->imgage,$this->fontsize,0,0,$this->forecolor,$this->font,$this->string)我认为这很有帮助:)
发布于 2009-07-15 07:29:22
你有$this->img,$this->image,$this->img()和$image的混合……
https://stackoverflow.com/questions/1129899
复制相似问题