如何在 C# 中使用 system.drawing 将文本绘制到 jpg 上并重新保存

发布于 2024-09-26 20:29:26 字数 65 浏览 1 评论 0原文

有人有关于如何在 jpg 图像上写入文本并使用 .NET 中的 System.Drawing 重新保存它的好例子吗?

Anyone have good example of how to write text onto a jpg image and resave it using System.Drawing in .NET?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

却一份温柔 2024-10-03 20:29:26

是的,你可以很容易地做到这一点......

Bitmap bmp = new Bitmap("C:\\test.jpg");
Graphics gra = Graphics.FromImage(bmp);
string text = "Hello\nWorld";

gra.DrawString(text, new Font("Verdana", 24), Brushes.Black, new PointF(0, 0));
bmp.Save("C:\\test_out.jpg");

Yes you can do it fairly easily...

Bitmap bmp = new Bitmap("C:\\test.jpg");
Graphics gra = Graphics.FromImage(bmp);
string text = "Hello\nWorld";

gra.DrawString(text, new Font("Verdana", 24), Brushes.Black, new PointF(0, 0));
bmp.Save("C:\\test_out.jpg");
鲜肉鲜肉永远不皱 2024-10-03 20:29:26

调用 CreateGraphics() 从图像中获取图形,使用其 Graphics.DrawString 方法并根据需要保存。

更多信息:
http://msdn.microsoft.com/en-us /library/system.drawing.graphics.drawstring.aspx

Acquire graphics from image calling CreateGraphics(), use its Graphics.DrawString method and save it as required.

More info:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawstring.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文