国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET中制作圖形

2024-07-10 12:57:05
字體:
來源:轉載
供稿:網友
這個程序經過修改 現在作計數器的話 只能做黑白的 計數器,誰有辦法 能夠做出 復雜的 圖形計數器?

<% @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();

}

%>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 资阳市| 武汉市| 玉树县| 南靖县| 三门峡市| 拜城县| 渝北区| 杭锦旗| 象山县| 潜山县| 大荔县| 绥芬河市| 绥宁县| 临颍县| 桦甸市| 乐亭县| 六盘水市| 怀化市| 乐山市| 祥云县| 建平县| 黄冈市| 丰顺县| 襄樊市| 年辖:市辖区| 仁布县| 花莲县| 保定市| 白沙| 濮阳县| 蚌埠市| 池州市| 崇礼县| 基隆市| 河源市| 犍为县| 驻马店市| 翁源县| 石门县| 姜堰市| 禹城市|