快精灵印艺坊 您身边的文印专家
广州名片 深圳名片 会员卡 贵宾卡 印刷 设计教程
产品展示 在线订购 会员中心 产品模板 设计指南 在线编辑
 首页 名片设计   CorelDRAW   Illustrator   AuotoCAD   Painter   其他软件   Photoshop   Fireworks   Flash  

 » 彩色名片
 » PVC卡
 » 彩色磁性卡
 » 彩页/画册
 » 个性印务
 » 彩色不干胶
 » 明信片
   » 明信片
   » 彩色书签
   » 门挂
 » 其他产品与服务
   » 创业锦囊
   » 办公用品
     » 信封、信纸
     » 便签纸、斜面纸砖
     » 无碳复印纸
   » 海报
   » 大篇幅印刷
     » KT板
     » 海报
     » 横幅

asp+ 制作图形

/*
豆腐制作 都是精品
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();
}
%>

作者:豆腐


返回类别: 教程
上一教程: Mono 计划―Linux版.NET平台 cashcho(原作)
下一教程: 在 ASp+ 中的一些可能会用到的 小函数

您可以阅读与"asp+ 制作图形"相关的教程:
· 使用纯粹的asp+语言制作的栏目治理(一)
· 使用纯粹的asp+语言制作的栏目治理(二)
· 使用纯粹的asp+语言制作的栏目治理(三)
· asp+版本简朴的留言板的制作(三)
· asp+版本简朴的留言板的制作(一)
    微笑服务 优质保证 索取样品