资 源 简 介
C#在图片上添加文字,这个仿PhotoShop的功能,用C#可以轻松实现哦,对象为JPG图像,可在上面添加半透明的文字效果,不能可看作是一种图片添加水印的效果,文字是半透明处理了,可隐约看到文字下层的图像细节。
private void Form1_Load(object sender, EventArgs e)
{//在指定图像上添加半透明文字
string MyFileName = "Forest.jpg";
Image MyImage = Image.FromFile(MyFileName);
Graphics g = Graphics.FromImage(MyImage);
String MyText = "国家";
Font MyFont = new Font("宋体", 150);
SolidBrush MyBrush = new SolidBrush(Color.FromArgb(18, 255, 0, 255));
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.GammaCorrected;
g.DrawString(MyText, MyFont, MyBrush, 10, 10);
this.pictureBox1.Image = MyImage;
}