编程语言

img pbMaster

可以动态画图输出的JSP例子

发表于2004/9/30 14:57:00  1374人阅读

<%@ page autoFlush="false"
             import="java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*"

%>
<%
out.clear();
response.setContentType("image/jpeg");
response.addHeader("pragma","NO-cache");
response.addHeader("Cache-Control","no-cache");
response.addDateHeader("Expries",0);

int width=640,height=480;
BufferedImage image= new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
Graphics g = image.getGraphics();

g.setColor(Color.white);
g.fillRect(0,0,width,height);

g.setColor(Color.red);
g.drawString("OK",270,220);

g.drawOval(10,10,100,100);

g.dispose();
ServletOutputStream sos = response.getOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
encoder.encode(image);
sos.close();
%>

阅读全文
0 0

相关文章推荐

img
取 消
img