GDI+绘制文本
2024-10-18 22:27:56
这是在论坛中有人提出的一个问题,原贴见:Graphics DrawString参数无效。这里给出方法,读者可以自行修改以适应自己的项目需求。
先上代码:
if (!Page.IsPostBack)
{
try
{
string str = Server.MapPath("~/upload/test.jpg");
System.Drawing.Image myImage = System.Drawing.Image.FromFile(str);
Bitmap map = new Bitmap(myImage);
myImage.Dispose();
Graphics graphics = Graphics.FromImage(map);
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
SolidBrush brush = new SolidBrush(Color.Red);
PointF P = new PointF(, );
Font font = new Font("宋体", );
graphics.DrawString("guwei4037", font, brush, P);
map.Save(str.Substring(, str.LastIndexOf("\\") + ) + "new" + str.Substring(str.LastIndexOf("\\") + , str.LastIndexOf(".") - str.LastIndexOf("\\") - ) + str.Substring(str.LastIndexOf("."), str.Length - str.LastIndexOf(".")), ImageFormat.Jpeg);
font.Dispose();
graphics.Dispose();
}
catch { }
}
最新文章
- Keepalived双机热备
- 转自知乎:GitHub基本功能
- 30天,O2O速成攻略【8.22北京站】
- Eclipse中没有andriod问题解决方法
- outlook新邮件到达提醒设置以及outlook最小化到托盘设置
- env1
- C++ 中类的构造函数理解(二)
- iOS 开发--github的demo
- 基于CodeBlocks上的wxWidgets开发环境配置
- sql server 发布时提示'dbo.sysmergepublications'无效的解决办法
- Linux C 调用MYSQL API 函数mysql_escape_string()转义插入数据
- [问题解决] ";Nautilus could not create the required folder ";/home/kenneth/.config/nautilus";
- 在VirtualBox虚拟机上采集Fedora15系统
- matlab中使用elseif和if嵌套的对比
- C#编写一个大字母游戏,详细代码,不懂问博主。。。。
- SLAM+语音机器人DIY系列:(二)ROS入门——4.如何编写ROS的第一个程序hello_world
- A页面跳转到B页面后打开指定tabs标签
- jpa 联合查询方法
- lombok @EqualsAndHashCode 注解的影响
- Postgres安装
热门文章
- C#多线程的介绍(园子里比较全的一篇)
- SQL Server压缩日志及数据库文件大小
- Asp.Net 之 通过调用 WScript.Shell 启动本地 exe 程序时产生“ automation服务器不能创建对象 ”的错误
- Android 高级UI设计笔记08:Android开发者常用的7款Android UI组件(转载)
- Debian 7 安装 Docker
- hdu 1195 广度搜索
- Nginx - Additional Modules, SSL and Security
- 第六节 ADO.NET
- 和阿文一起学H5-- H5排版八大套路
- jquery学习--选择器