Often see someone on the mop of that dynamic picture, is a string as parameters to a Dynamic Web page, you will generate a picture with this string, called a text watermark. Like what the original Panda series, as well as the later trees and gold bars, are very interesting. This thing looks very fun, want to do a play. Check the data, found that using. NET to do this is very easy, with ASP.net wrote a very simple. All 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 ("talk.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")
Dim b As Brush = new SolidBrush (color.black)
Dim s As String = Left (Request.QueryString ("str"), 7)
g.drawstring (S, F, B, 190)
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 talk.jpg picture, you can print the text of the font "XXFarEastFont-Xingkai" in this place (20, 190). Calling the method is simple:
Http://localhost/Test.aspx?str= Test the next!
For print locations and fonts and picture files can be set themselves. In addition, if the appearance of e-text 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. It's fun to play.