让Asp.Net输出图形
发表于:2007-06-30来源:作者:点击数:
标签:
%@ Page Language= vb De bug =True % %@ import namespace=system.drawing % %@ import namespace=system.drawing.imaging % %@ import namespace=system.drawing.drawing2d % % @#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@# @#让Asp.Net输出
<%@ Page Language="
vb" De
bug="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
原文转自:http://www.ltesting.net