php在图片上写指定字体颜色的文字函数

来源:百度知道 编辑:UC知道 时间:2024/06/23 20:09:04
我用的是imagestring函数,怎么写出来的字都是黑色的呢?
$im = imagecreate(100, 30);
// 白色背景和蓝色文本
$bg = imagecolorallocate($im, 255, 235, 235);
$textcolor = imagecolorallocate($im, 255, 255, 255);

我用的是bool imagestring ( resource $image, int $font, int $x, int $y, string $s, int $col )这个函数,col的值是textcolor

bool imagestring ( resource $image, int $font, int $x, int $y, string $s, int $col )

imagestring() 用 col 颜色将字符串 s 画到 image 所代表的图像的 x,y 坐标处(这是字符串左上角坐标,整幅图像的左上角为 0,0)。如果 font 是 1,2,3,4 或 5,则使用内置字体。
最后一个参数,表示颜色.
$black = ImageColorAllocate($im, 0,0,0);
imagestring(........,black)

就是这个函数,你参数没带够,函数格式如下:

bool imagestring ( resource $image, int $font, int $x, int $y, string $s, int $col )

imagestring() 用 col 颜色将字符串 s 画到 image 所代表的图像的 x,y 坐标处(这是字符串左上角坐标,整幅图像的左上角为 0,0)。如果 font 是 1,2,3,4 或 5,则使用内置字体。