当前位置:首页 > 网络编程 > WEB编程 > ASP.net > asp+ 制作图形

asp+ 制作图形

点击次数:19 次 发布日期:2008-11-26 23:35:43 作者:源代码网
源代码网推荐 /*
源代码网推荐豆腐制作 都是精品
源代码网推荐http://www.asp888.net 豆腐技术站
源代码网推荐如转载 请保留版权信息
源代码网推荐*/
源代码网推荐这个程序经过修改 现在作计数器的话 只能做黑白的 计数器,谁有办法 能够做出 复杂的 图形计数器?
源代码网推荐<% @Page Language="C#" %>
源代码网推荐<% @Import Namespace="System.Drawing" %>
源代码网推荐<% @Import Namespace="System.IO" %>
源代码网推荐<% @Import Namespace="System.Drawing.Imaging" %>
源代码网推荐<%
源代码网推荐Response.Expires = 0;
源代码网推荐Bitmap newBitmap = null;
源代码网推荐Graphics g = null ;
源代码网推荐string str2Render = Request.QueryString.Get("HitCount");
源代码网推荐if (null == str2Render) str2Render = "12345";
源代码网推荐string strFont = Request.QueryString.Get("HitFontName");
源代码网推荐if (null == strFont) strFont = "楷体_GB2312";
源代码网推荐int nFontSize = 12;
源代码网推荐try
源代码网推荐{
源代码网推荐nFontSize = Request.QueryString.Get("HitFontSize").ToInt32();
源代码网推荐}
源代码网推荐catch
源代码网推荐{
源代码网推荐// do nothing, just ignore
源代码网推荐}

string strBackgroundColorname = Request.QueryString.Get("HitBackgroundColor");
源代码网推荐Color clrBackground = Color.White;
源代码网推荐try
源代码网推荐{
源代码网推荐if (null != strBackgroundColorname)
源代码网推荐clrBackground = ColorTranslator.FromHTML(strBackgroundColorname);
源代码网推荐}
源代码网推荐catch
源代码网推荐{
源代码网推荐}

string strFontColorName = Request.QueryString.Get("HitFontColor");
源代码网推荐Color clrFont = Color.Black;
源代码网推荐try
源代码网推荐{
源代码网推荐// Format in the URL: %23xxXXxx
源代码网推荐if (null != strFontColorName)
源代码网推荐clrFont = ColorTranslator.FromHTML(strFontColorName);
源代码网推荐}
源代码网推荐catch
源代码网推荐{
源代码网推荐}

try
源代码网推荐{
源代码网推荐Font fontCounter = new Font(strFont, nFontSize);
源代码网推荐newBitmap = new Bitmap(1,1,PixelFormat.Format32bppARGB);
源代码网推荐g = Graphics.FromImage(newBitmap);
源代码网推荐SizeF stringSize = g.MeasureString(str2Render, fontCounter);
源代码网推荐int nWidth = (int)stringSize.Width;
源代码网推荐int nHeight = (int)stringSize.Height;
源代码网推荐g.Dispose();
源代码网推荐newBitmap.Dispose();
源代码网推荐newBitmap = new Bitmap(nWidth,nHeight,PixelFormat.Format32bppARGB);
源代码网推荐g = Graphics.FromImage(newBitmap);
源代码网推荐g.FillRectangle(new SolidBrush(clrBackground), new Rectangle(0,0,nWidth,nHeight));
源代码网推荐g.DrawString(str2Render, fontCounter, new SolidBrush(clrFont), 0, 0);
源代码网推荐MemoryStream tempStream = new MemoryStream();
源代码网推荐newBitmap.Save(tempStream,ImageFormat.GIF);
源代码网推荐Response.ClearContent();
源代码网推荐Response.ContentType = "image/GIF";
源代码网推荐Response.BinaryWrite(tempStream.ToArray());
源代码网推荐Response.End();
源代码网推荐}
源代码网推荐catch (Exception e)
源代码网推荐{
源代码网推荐Response.Write(e.ToString());
源代码网推荐}
源代码网推荐finally
源代码网推荐{
源代码网推荐if (null != g) g.Dispose();
源代码网推荐if (null != newBitmap) newBitmap.Dispose();
源代码网推荐}
源代码网推荐%>

作者:豆腐


源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华