Make Www.Edu-cn.Com Your Home Page!
用户名: 密码: 验证码: 注册
  当前位置: > 中国教程网>网站建设>jsp> JSP技巧:发送动态图像(3)

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

作者:   来源:中国教程网   点击:   日期:2007-04-02

  <%@ 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);
  %> (代码实验室) 漂亮MM女性网


中国论文网



文章评论】 【收藏本文】 【推荐好友】 【打印本文】 【论坛讨论

   最新文章:
·JSP技术简介(04-02)
·JSP编程进度条设计实例(1)(04-02)
·JSP连接各类数据库大全(7)(04-02)
·JSP连接各类数据库大全(4)(04-02)
·JSP连接各类数据库大全(5)(04-02)
·用JSP操作Cookie(1)(04-02)
·JSP连接各类数据库大全(6)(04-02)
·JSP连接各类数据库大全(3)(04-02)
·十一、JSP及语法概要(04-02)
·JSP连接各类数据库大全(1)(04-02)
   相关文章:
·用JSP操作Cookie(2) ·JSP连接各类数据库大全(1)
·用JSP操作Cookie(1) ·JSP连接各类数据库大全(2)
·ASP与JSP的比较(2) ·JSP连接各类数据库大全(3)
·ASP与JSP的比较(1) ·JSP连接各类数据库大全(4)
·jsp计数器制作手册(2) ·JSP连接各类数据库大全(5)

   文章评论:(0条)
  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。

 §最新评论:

  责任编辑:中国教程网  

© 2007 Copyright 中国教育网
DesignBy:AOE3 STUDIO & ROCOCO