用ASP+制作图形
2010-8-17编辑:feimeimei
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;011 ifstr2Render = no count
specified;012 string strFont = Request.QueryString.Get
;013 ifstrFont = Lucida Sans Unicode;014 015 int nFontSize =
12;016 try017 018 nFontSize = Request.QueryString.Get.ToInt32;019 020 catch021 022 // do nothing, just ignore023 024 025 string strBackgroundColorname = Request.QueryString.Get;026 Color
clrBackground = Color.White;027 try028 029 // Format in the URL: %23xxXXxx030
if 031
clrBackground = ColorTranslator.FromHTML;032 033 catch034 035 036 037 string strFontColorName =
Request.QueryString.Get;038 Color clrFont = Color.Black;039 try040 041 // Format in the URL: %
23xxXXxx042 if 043 clrFont = ColorTranslator.FromHTML
;044 045 catch046 047 048 049 try 050 051 Font fontCounter = new Font;052 053 // calculate size of the string.054
newBitmap = new Bitmap;055 g = Graphics.FromImage;056 SizeF stringSize = g.MeasureString;057 int nWidth =
stringSize.Width;058 int nHeight =
stringSize.Height;059 g.Dispose;060 newBitmap.Dispose;061 062 newBitmap =
new Bitmap;063 g
= Graphics.FromImage;064 g.FillRectangle, new Rectangle);065 066 g.DrawString
, 0, 0);067
068 MemoryStream tempStream = new MemoryStream;069 newBitmap.Save;070 071
Response.ClearContent;072 Response.ContentType = image/png;073 Response.BinaryWrite
);074
Response.End;075 // newBitmap.Save
;076 // newBitmap.Save ;077 078 catch