郁闷,用C#生成透明的PNG图片
代码如下:生成的图片用PhotoShop打开是透明的,但在网页上打开则是灰色背景。
//生成文件名
string sIconFileName = Server.MapPath( "test.png" );
//图片文字
string str=DateTime.Now.ToString();
Bitmap image=new Bitmap(200,30);
Graphics g=Graphics.FromImage(image);
//填充透明色
g.Clear(Color.Transparent);
//写文字
g.DrawString(str,new Font("Courier New", 10),new SolidBrush(Color.Red),20,5);
//Graphics 类还有很多绘图方法可以绘制 直线、曲线、圆等等
image.Save( sIconFileName,System.Drawing.Imaging.ImageFormat.Png );