怎么用gd库把中文写进图片里?

Blueky 2005-04-22 05:26:55
我只能写英文,中文都乱了,有人说用utf-8能写,可没有思路,盼望指点一下:)
...全文
107 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Blueky 2005-04-25
  • 打赏
  • 举报
回复
谢谢您的回复,您pig.php页的内容是什么,怎么就可以显示中文了呢?我的还是不行,能帮忙看看错哪了么?
我的两个页面是这样的
###gd.php
<?php

Header("Content-type: image/png");
$width = 7.5*(strlen($_GET["text"]))+100;
$text = $_GET["text"];
$height = 21;
$newim = imagecreate($width,$height);
$gray = imagecolorallocate($newim,153,153,153);
$white = ImageColorAllocate($newim,255,255,255);
imagefilledrectangle($newim,1,1,$width-96,19,$white);
$email = imagecreatefrompng('gmail.png');
imagecopy($newim,$email,$width-100,0,1,0,100,21);
imagestring($newim, 3, 7, 3, $text, $gray);
imagepng($newim);
imagedestroy($newim);

?>

###index.php
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<p>请输入你的Gmail地址:</p>
<form action="index.php" method="get" name="email">
<input type="text" name="text" width="100">@gmail.com
<input type="submit" value="创建我的签名">
</form>

<table style="display:<?php if(empty($_GET["text"])) echo "none;";?>"><tr><td>
<img src="gd.php?text=<?php echo $_GET["text"]?>" >
</td></tr></table>

</body>
</html>
caiso 2005-04-25
  • 打赏
  • 举报
回复
顶一下
Blueky 2005-04-25
  • 打赏
  • 举报
回复
to Devil007(夕阳武士)
我把编码改为utf-8,中文是显出来了,可还是有问题,我用的是simhei,总是显示最后一个字出现乱码,我试了你的http://www.veryhd.com/pig/?txt=哈哈
显示的一切正常,能说一下pig.php里做了什么处理吗?
x_999 2005-04-25
  • 打赏
  • 举报
回复
帮顶
fnote 2005-04-22
  • 打赏
  • 举报
回复
http://www.veryhd.com/pig/?txt=哈哈

<?php
header ("Content-type: image/png");
require ("pig.php");
$txt=show_txt();
$txt1=subStr($txt,0,30);
$txt2=subStr($txt,30,30);
$image = @imagecreatefromgif ("pig.gif");
$white = imagecolorallocate ($image, 255, 255, 255);
drawer($image,$txt1,12,12,$white);
drawer($image,$txt2,12,36,$white);
imagepng ($image);
imagedestroy ($image);
function show_txt(){
$bbb = $_GET['txt'];
return($bbb);
}
?>

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧