动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   Jsp → 阅读文章

 JSP技巧:发送动态图像(3)

作者:郁郁小蝎 来源:中国站长学院 
阅读 1904 人次 , 2006-2-15 14:24:00 

  <%@ page contentType="image/jpeg"
  import="java.awt.*,java.awt.image.*,
  com.sun.image.codec.jpeg.*,java.util.*"
  %>  
  <%
  // Create image
  int width=200, height=200;
  BufferedImage image = new BufferedImage(width,
  height, BufferedImage.TYPE_INT_RGB);
  // Get drawing context  (代码实验室)
  Graphics g = image.getGraphics();
  // Fill background
  g.setColor(Color.white);
  g.fillRect(0, 0, width, height);
  // Create random polygon
  Polygon poly = new Polygon();
  Random random = new Random();
  for (int i=0; i < 5; i++) {
  poly.addPoint(random.nextInt(width),
  random.nextInt(height));
  }
  // Fill polygon
  g.setColor(Color.cyan);
  g.fillPolygon(poly);
  // Dispose context
  g.dispose();
  // Send back image
  ServletOutputStream sos = response.getOutputStream();
  JPEGImageEncoder encoder =
  JPEGCodec.createJPEGEncoder(sos);
  encoder.encode(image);
  %> (代码实验室)


  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:
· 下一篇:JSP连接各类数据库大全(1)
· 五、读取HTTP请求头
· JSP由浅入深(8)—— JSP Tags
· jsp计数器制作手册
· JSP技术生成动态web页面
· JSP编程进度条设计实例(3)


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077