讓Asp.Net輸出圖形

來源:互聯網
上載者:User
asp.net|圖形 <%@ 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:loved@vip.sina.com
'MSN:xzskyweb@hotmail.com
'歡迎大家聯絡我交流技術
'''''''''''''''''''''''''''''



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


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.