以下是引用hxfly在2005-11-18 13:29:00的发言:
<%@ Page Language="VB" ContentType ="image/jpeg" %>
<%@ Import Namespace =Namespace ="System.Drawing" %>
<%@ Import Namespace =Namespace ="System.Drawing.Imaging" %>
<%@ Import Namespace =Namespace ="System.Drawing.Drawing2D" %>
<%
Dim StrIP As String, StrName As String
Dim address As System.Net.IPAddress
StrIP = Request.ServerVariables("REMOTE_ADDR")
address = System.Net.IPAddress.Parse(StrIP)
Response.Clear()
Dim height As Integer = 30
Dim width As Integer = 210
Dim bmp As New Bitmap(width, height, PixelFormat.Format24bppRgb)
Dim g As Graphics = Graphics.FromImage(bmp)
g.SmoothingMode = SmoothingMode.AntiAlias
g.Clear(Color.LightGray)
g.DrawRectangle(Pens.White, 1, 1, width - 3, height - 3)
g.DrawString("你電腦的IP是:" + StrIP, New Font("Arial", 10, FontStyle.Bold), SystemBrushes.WindowText, New PointF(10, 8))
bmp.Save(Response.OutputStream, ImageFormat.Jpeg)
g.Dispose()
bmp.Dispose()
Response.End()
%>
大体原理是当你访问这个页面的时候
服务器记录你的信息
然后从数据库里读出相应的信息
然后生成图片并反馈
我试了,我将你的那段代码存为ASP格式,再用<img>输出,每法显示,单独运行保存的ASP文件,提示以下错误:
Active Server Pages 错误 'ASP 0221'
无效 @ Command 原语
/weather/img.asp,行1
指定的 'Page Language="VB" ContentType ="image/jpeg" ' 选项未知或无效。