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" % % @#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@# @#让
 

<%@ 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()
 
   %>

原文转自:http://www.ltesting.net