SolidBrush为什么创建出不出纯色的画刷?
aix5 2005-04-30 10:28:59 private void Page_Load(object sender, System.EventArgs e)
{
DrawPicture dr = new DrawPicture();
dr.FillRect(200,200,Color.FromArgb(0xe8,0xf4,0xff));
}
public void FillRect(int width, int height,Color clrBackground)
{
Bitmap newBitmap = new Bitmap(width,height,PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(newBitmap);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.FillRectangle(new SolidBrush(clrBackground), new Rectangle(0,0,width,height));
g.Dispose();
System.Web.HttpContext.Current.Response.ClearContent();
System.Web.HttpContext.Current.Response.ContentType = "image/Gif";
newBitmap.Save (System.Web.HttpContext.Current.Response.OutputStream,System.Drawing.Imaging.ImageFormat.Gif);
System.Web.HttpContext.Current.Response.End();
}
如果用GIF格式输出的图片就带有细小的网格,网格的样式与随颜色一同而有差别.只是在每个颜色分量高4位=低4位的时候,就没有网格。
用JPEG格式无论用什么颜色输出的图片都是纯色,但我不希望用JPEG。