<%@ page language=”vb” debug=”true” %>
<%@ import namespace=”system.drawing” %>
<%@ import namespace=”system.drawing.imaging” %>
<%@ import namespace=”system.drawing.drawing2d” %>
<%
让asp.net输出图形.
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) 背景色为蓝色
用实例教学,下吧学习频道[http://123.xia8.com]
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()
%>