<%@ page language="vb" debug="true" %> 
 <%@ import namespace="system.drawing" %> 
 <%@ import namespace="system.drawing.imaging" %> 
 <%@ import namespace="system.drawing.drawing2d" %> 
 <% ''''''''''''''''''''''''''''
 '讓asp.net輸出圖形.
 '歐陽東杰(oydj)原創.
 'qq:2596812
 'e-mail:[email protected]
 'msn:[email protected]
 '歡迎大家聯系我交流技術
 '''''''''''''''''''''''''''''
 
 dim strfilename as string '聲明變量,用于圖片路徑
 dim i as system.drawing.image '創建.net框架圖像處理對象實例
dim imgg1 as integer =cint(int((6 * rnd()) + 1)) '生成1-6的隨機數
dim oydj as string=imgg1
 strfilename ="d:/o123/"+oydj+".jpg" '載入的圖片路徑,這里的oydj代表隨機生成的變量,用于生成隨機圖片
 
 i = system.drawing.image.fromfile(strfilename)
 
 dim b as new system.drawing.bitmap(i.width, i.height, pixelformat.format24bpprgb) 
 dim g as graphics = graphics.fromimage(b) 
 
 g.clear(color.blue) '背景色為藍色
 
dim sss=request.servervariables("remote_addr")
 g.drawimage(i,new point(0,0)) 
 '這里表示生成一個字符,9號宋體加粗白色,pointf(160,50)為在屏幕的坐標
g.drawstring(sss, new font("宋體",9,fontstyle.bold),new solidbrush(color.white),new pointf(160,50))
g.drawstring(sss, new font("宋體",9,fontstyle.bold),new solidbrush(color.white),new pointf(161,51)) 
 
 
 response.contenttype="image/jpeg" '指定輸出格式為圖形
 
 b.save(response.outputstream, imageformat.jpeg) 
 
 b.dispose() 
 
 %> 
 
代碼演示
http://www.ift99.com/pic3.aspx