Tutorials to .com


ASP.NET Development Articles


Can't Find What You're Looking For?

Tutorials to .com » Dotnet » Development » asp + Production Graphics

asp + Production Graphics

Print View , by: iSee ,Total views: 8 ,Word Count: 389 ,Date: Sun, 23 Aug 2009 Time: 10:07 PM

/ *
Bean products are produced
technical points such as tofu http://www.asp888.net reprint information, please retain the copyright
* /
This procedure has been modified to make the counter is now only do the words black and white counters, and who can make complex graphical way to counter?
<% @ 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 = "italics _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 ();
)
%>

Author: tofu ()


Google
 

Rating: Not yet rated

Comments

No comments posted.