【发布时间】:2015-08-26 02:23:26
【问题描述】:
下面给出了我的代码,我想要做的是,从项目文件夹中获取图像,然后在图像上添加一些文本,然后将其保存到同一个文件夹中。
string firstText = "Hello";
string secondText = "World";
PointF firstLocation = new PointF(10f, 10f);
PointF secondLocation = new PointF(10f, 50f);
var imageFilePath = Server.MapPath("~/Images/" + "a.png");
Bitmap bitmap = (Bitmap)Image.FromFile(imageFilePath);//load the image file
using (Graphics graphics = Graphics.FromImage(bitmap))
{
using (Font arialFont = new Font("Arial", 10))
{
graphics.DrawString(firstText, arialFont, Brushes.Blue, firstLocation);
graphics.DrawString(secondText, arialFont, Brushes.Red, secondLocation);
}
}
bitmap.Save(imageFilePath);//save the image file
【问题讨论】:
-
你遇到了什么错误?
-
我刚刚做了这个和它的工作 bitmap.Save(imageFilePath+".jpg");//保存图像文件
标签: c# bitmap bitmapimage