开发者网络 动网主机 支持论坛 邮局 帮助
当前位置:网络学院.Net专区Asp.Net开发 → 用ASP+制作图形(有了ASP+,不需要扩展图像组件啦!)
用ASP+制作图形(有了ASP+,不需要扩展图像组件啦!)
日期:2000年11月29日 作者: 人气:     [ ]
001 <% @Page Language="C#" %>002 <%
@Import Namespace="System.Drawing" %>003 <% @Import Namespace="System.IO" %>004 <% @Import Namespace="System.Drawing.Imaging" %
>005 <%006 Response.Expires = 0;007 Bitmap newBitmap = null;008 Graphics g = null ;009 010 string str2Render =
Request.QueryString.Get("HitCount");011 if (null == str2Render) str2Render = "no count
specified";012 string strFont = Request.QueryString.Get
("HitFontName");013 if (null ==
strFont) strFont = "Lucida Sans Unicode";014 015 int nFontSize =
12;016 try017 {018 nFontSize = Request.QueryString.Get("HitFontSize").ToInt32();019 }020 catch021 {022 // do nothing, just ignore023 }024 025 string strBackgroundColorname = Request.QueryString.Get("HitBackgroundColor");026 Color
clrBackground = Color.White;027 try028 {029 // Format in the URL: %23xxXXxx030
if (null != strBackgroundColorname)031
clrBackground = ColorTranslator.FromHTML(strBackgroundColorname);032 }033 catch034 {035 }036 037 string strFontColorName =
Request.QueryString.Get("HitFontColor");038 Color clrFont = Color.Black;039 try040 {041 // Format in the URL: %
23xxXXxx042 if (null != strFontColorName)043 clrFont = ColorTranslator.FromHTML
(strFontColorName);044 }045 catch046 {047 }048 049 try 050 {051 Font fontCounter = new Font(strFont, nFontSize);052 053 // calculate size of the string.054
newBitmap = new Bitmap(1,1,PixelFormat.Format32bppARGB);055 g = Graphics.FromImage(newBitmap);056 SizeF stringSize = g.MeasureString(str2Render,
fontCounter);057 int nWidth = (int)
stringSize.Width;058 int nHeight = (int)
stringSize.Height;059 g.Dispose();060 newBitmap.Dispose();061 062 newBitmap =
new Bitmap(nWidth,nHeight,PixelFormat.Format32bppARGB);063 g
= Graphics.FromImage(newBitmap);064 g.FillRectangle(new
SolidBrush(clrBackground), new Rectangle(0,0,nWidth,nHeight));065 066 g.DrawString
(str2Render, fontCounter, new SolidBrush(clrFont), 0, 0);067
068 MemoryStream tempStream = new MemoryStream();069 newBitmap.Save(tempStream,ImageFormat.PNG);070 071
Response.ClearContent();072 Response.ContentType = "image/png";073 Response.BinaryWrite
(tempStream.ToArray());074
Response.End();075 // newBitmap.Save
(Response.OutputStream, ImageFormat.PNG);076 // newBitmap.Save("o:\\TestApps\\TestServer\\test.png", ImageFormat.PNG) ;077 } 078 catch (Exception e)
079 {080
Response.Write(e.ToString());081 }082 finally 083 {084 if (null != g) g.Dispose();085 if (null != newBitmap) newBitmap.Dispose();086 }087 %>

(出处:)

相关文章:
 
·一个不需要第三方组件,可实现华简单图形的类
·如何从ACCESS数据库中读取图形(续)
·图形处理函数库 画饼形图2D 3D
·asp+ 制作图形
·如何解决图形和文字的显示问题
相关软件:
 
·条形码图形统Barcode Image Counter v1.0
·UltimateASP图形计数器
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢
 → 特别推荐
 → 热点TOP10

关于本站 | 诚聘英才 | 业务合作 | 联系我们 | 广告合作 | 收藏本站

海口动网先锋网络科技有限公司版权所有
Copyright ? 2000 - 2003 AspSky.Net
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077