The code is as follows:
<%@ Import namespace= "System"%>
<%@ Import namespace= "System.IO"%>
<%@ Import namespace= "System.Drawing"%>
<%@ Page language= "vb"%>
<script runat= "Server" >
Dim FilePath as String = Server.MapPath ("fenger.jpg")
Sub Page_Load (Sender as Object, E as EventArgs)
Dim image as System.Drawing.Image = System.Drawing.Image.FromFile (FilePath)
Dim g as Graphics = graphics.fromimage (image)
G.drawimage (image, 0, 0, image. Width, image. Height)
Dim f as Font = new Font ("XXFarEastFont-Xingkai", 30)
Dim B as Brush = new SolidBrush (color.green)
Dim s as String = Request.QueryString ("Str")
g.DrawString (S, F, B, 20, 290)
Image. Save (Response.outputstream, System.Drawing.Imaging.ImageFormat.Jpeg)
G.dispose ()
Image. Dispose ()
End Sub
</script>
Just save this code as an ASPX file, such as Test.aspx. Then put it in the wwwroot (assuming your virtual directory is the default). To do a test.jpg picture, you can print the text of the font "XXFarEastFont-Xingkai" in this position (20, 290). Calling the method is simple:
Http://localhost/Test.aspx?Str=Dicky ' s blog!
For print locations and fonts and picture files can be set themselves. In addition, if the use of English as a parameter can be normal display, and the Chinese will not be able to display the situation because the ASP.net Web.config settings are incorrect, you need to do the following settings:
<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<system.web>
<globalization requestencoding= "gb2312" responseencoding= "gb2312" culture= "ZH-CN" fileencoding= "gb2312"/>
</system.web>
</configuration>
This way, you can display it normally.