C#.net 动态生成GIF图背景无法透明????(代码如下)
为什么无法消除黑背景??求助
<%@ Page Language="C#" ContentType = "image/Gif" %>
<<%@ Import Namespace = "System" %>
<%@ Import Namespace = "System.Drawing" %>
<%@ Import Namespace = "System.Drawing.Drawing2D" %>
<%@ Import Namespace = "System.Drawing.Imaging" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head > </head >
<script language ="c#" runat = "server" >
protected void Page_Load(object sender, EventArgs e)
{
Bitmap currentBitmap = new Bitmap(891, 556);
ImageAttributes ia = new ImageAttributes();
Graphics g = Graphics.FromImage(currentBitmap);
float[][] colorMatrix ={
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, 0, 0}, //注意:此处为0,图像为全透明
new float[] {0, 0, 0, 0, 1}};
Font axesFont = new Font("Arial", 10);
Brush blackBrush = new SolidBrush(Color.Blue);
g.DrawString(" -22.3 ", axesFont, blackBrush, 300, 400);
ColorMatrix cm = new ColorMatrix(colorMatrix);
ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(currentBitmap, new Rectangle(0, 0, currentBitmap.Width, currentBitmap.Height), 0, 0, currentBitmap.Width, currentBitmap.Height, GraphicsUnit.Pixel, ia);
// picBox.Image = currentBitmap;
// g.Dispose();
//currentBitmap.Save(Response.OutputStream, ImageFormat.gif);
//currentBitmap.Save(response.outputstream,ImageFormat .Gif);
// g.Clear(Color.Transparent);
// g.Clear(colorMatrix.;
currentBitmap.Save(Response.OutputStream, ImageFormat.Gif);
}
</script >
<body>
</body>
</html>
补充:.NET技术 , C#