Let asp.net output graphics

Source: Internet
Author: User
asp.net| Graphics <%@ Page language= "vb" debug= "True"%>
<%@ import namespace= "System.Drawing"%>
<%@ import namespace= "System.Drawing.Imaging"%>
<%@ import namespace= "System.Drawing.Drawing2D"%>
"<%" "" "" "" "" "" "" "" "
' Let asp.net output graphics.
' Ouyangdongjie (OYDJ) original.
' qq:2596812
' E-mail:loved@vip.sina.com
' Msn:xzskyweb@hotmail.com
' Welcome to contact me Communication technology
'''''''''''''''''''''''''''''



Dim strFileName As String ' Declare variable, for picture path
Dim i as System.Drawing.Image ' create. NET Framework image Processing object instance
Dim imgg1 As Integer =cint (Int ((6 * RND ()) + 1) ' generates a random number of 1-6
Dim oydj As String=imgg1

strFileName = "d:\o123\" +oydj+ ". jpg" ' Loaded picture path, where the OYDJ represent randomly generated variables for generating random pictures

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) ' Background color is blue


Dim Sss=request.servervariables ("Remote_addr")
G.drawimage (i,new Point (0,0))
' Here represents the generation of a character, # 9th Bold White, PointF (160,50) for the coordinates on the screen
g.DrawString (SSS, New Font ("XXFarEastFont-Arial", 9,fontstyle.bold), New SolidBrush (Color.White), New PointF (160,50))
g.DrawString (SSS, New Font ("XXFarEastFont-Arial", 9,fontstyle.bold), New SolidBrush (Color.White), New PointF (161,51))



Response.contenttype= ' image/jpeg ' specifies the output format as a graphic

B.save (Response.outputstream, Imageformat.jpeg)

B.dispose ()

%>



Code Demo

Http://www.ift99.com/pic3.aspx


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.