实现:通过GDI+中颜色是ARGB格式的(a,r,g,b)a透明度0-100,100表示不透明,0表示完全透明,r红色,g绿色,b蓝色
new SolidBrush(Color.FromArgb(80,70,140,40))
例子:
图片添加透明文字
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
namespace IPImage
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "image/jpeg";
Font font = new Font("Arial", 22);
string strFileName = @"D:\images\IpImg.bmp";
Image MyImage = Image.FromFile(strFileName);
Bitmap OutPut = new Bitmap(MyImage);
Graphics GImage = Graphics.FromImage(OutPut);
GImage.DrawString("第8工作室.热诚为您服务.", font, new SolidBrush(Color.FromArgb(80,70,140,40)),10,85);
OutPut.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
GImage.Dispose();
OutPut.Dispose();
MyImage.Dispose();
}
}
}
附源码:
下载