在图像上添加文字 [英] Add text on an image
本文介绍了在图像上添加文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个像1.png的图像,在图像上有两个字段。如下所示:
I have an image like 1.png, in the image there are two fields on it. like below:
Name:
Date:
i有一个应用程序可以接收名称和来自用户的日期,然后将值放在图像上
i have an app to receive the name and date from user, then put the values on the image
Name: John
Date: 2018-10-01
并保存它作为john.png。
如何使用C#实现这个?
谢谢!
我尝试过:
i需要使用1.png作为模板。
i没有解决方案。
谢谢!
and save it as john.png.
how to implement this using C#?
Thank you!
What I have tried:
i need to use 1.png as a template.
i don't have a solution.
Thank you!
推荐答案
假设你的图像每次都在同一个地方有名称和日期区域,那就不难了:
Assuming your image has the name and date areas in the same place each time, then it's not too difficult:
using (Image i = Image.FromFile(inputPath))
{
using (Graphics g = Graphics.FromImage(i))
{
g.DrawString("John", Font, Brushes.Black, new PointF(fX, fY1));
g.DrawString("2018-10-01", Font, Brushes.Black, new PointF(fX, fY2));
}
i.Save(outputPath, ImageFormat.Png);
}
这篇关于在图像上添加文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文