导航首页 »  技术教程 »  PHP:imagestring()的用法_GD库图像处理函数
PHP:imagestring()的用法_GD库图像处理函数 1141 2023-12-15   

imagestring

(PHP 4, PHP 5)

imagestring — 水平地画一行字符串

说明

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

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

Example #1 imagestring() 例子

<?php
// 建立一幅 100X30 的图像
$im = imagecreate(100, 30);

// 白色背景和蓝色文本
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// 把字符串写在图像左上角
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);

// 输出图像
header("Content-type: image/png");
imagepng($im);
?>

参见 imageloadfont() 和 imagettftext()。



文章评论 (0条)
发表评论
暂无评论,快来抢沙发吧~