注册 登录
编程论坛 J2EE论坛

jsp画图

yx880502 发布于 2008-10-15 02:00, 1950 次点击
<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="gbk" import="javax.imageio.*,java.awt.*,java.awt.image.*"%>
<%
    int width=400;
    int height=400;
    BufferedImage image=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
    
    Graphics g=image.getGraphics();
    g.setColor(Color.red);
    g.drawLine(20,20,220,20);
    g.setColor(Color.white);
    g.dispose();
    ImageIO.write(image,"jpg",response.getOutputStream());
    out.clear();
    out = pageContext.pushBody();     
%>

背景色是漆黑的,怎么设置背景色
1 回复
#2
yx8805022008-10-16 18:17
解决了

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