/// <summary>
/// 给导出的图片加上文字描述
/// </summary>
/// <param name="filePath"></param>
protected void SetPicDescription(string filePath)
{
if (System.IO.File.Exists(filePath))//看该路径下图片是否存在
{
string strDescription = "";//文字描述
System.IO.MemoryStream ms = new System.IO.MemoryStream(System.IO.File.ReadAllBytes(filePath));
Image image = Image.FromStream(ms);
Graphics g = Graphics.FromImage(image);
//Brush drawBrush = new SolidBrush(System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(243)), ((System.Byte)(255)))); //自定义字体颜色
g.DrawString(strDescription, new Font("宋体", 9), Brushes.Black, new PointF(230, 30));
System.IO.File.Delete(filePath);
image.Save(filePath);
}
}
C# 图片添加文字描述
最新推荐文章于 2024-01-25 11:22:05 发布