求C#生成图片的源码 通过输入文本动态生成一张图片 要求可以指定文字在图片中的位置要有统一的图片做为背景万分感谢!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 函数代码如下,返回的就是一个包含text字符串和背景图的图片:private Image GetImage(string backgroundImagePath, string text, int x, int y){ Image img = Image.FromFile(backgroundImagePath); Bitmap bmp = new Bitmap(img.Width, img.Height); Graphics g = Graphics.FromImage(bmp); //画图像 g.DrawImage(img, 0, 0); //画字符 SolidBrush brush = new SolidBrush(Color.Black); g.DrawString(text, brush, x, y); // brush.Dispose(); g.Dispose(); img.Dispose(); return bmp as Image;} 赞成2楼的做法,就这样做,使用image对象打开一个图像,如果没有,你自己先创建一个,然后再使用Graphics对象来操作这个image对象就可以了。有没有保存我就不记得了。LZ自己去看看 ClickOne部署如何添加其他资源文件 C# treeview中修改XML文件 如何判断出一个文件正在被另一个线程访问 C# 请推荐一本优秀的C#控件学习教材 请教一个关于窗体透明而控件不透明的问题! 大伙都用什么工具建模,对c#来说好使一些的? 关于加密算法的问题.在线等!!! 鼠标钩子用dll引用就正常,可是把dll的源代码写到主程序中鼠标钩子无效,啥原因啊? 安装请问 服务器提示: C# 流媒体编程,求思路方法? 怎样捕获鼠标滚轮的向上和向下消息
private Image GetImage(string backgroundImagePath, string text, int x, int y)
{
Image img = Image.FromFile(backgroundImagePath); Bitmap bmp = new Bitmap(img.Width, img.Height);
Graphics g = Graphics.FromImage(bmp);
//画图像
g.DrawImage(img, 0, 0);
//画字符
SolidBrush brush = new SolidBrush(Color.Black);
g.DrawString(text, brush, x, y);
//
brush.Dispose();
g.Dispose();
img.Dispose();
return bmp as Image;
}