当前位置: 技术问答>java相关
double buffer 问题
来源: 互联网 发布时间:2015-01-19
本文导语: class myapplet extends Applet{ Image off_screen_buffer; Graphics off_screen; Image image1; public void init(){ off_screen_buffer=createImage(400,350); off_screen=off_screen_buffer.getGraphics(); ...
class myapplet extends Applet{
Image off_screen_buffer;
Graphics off_screen;
Image image1;
public void init(){
off_screen_buffer=createImage(400,350);
off_screen=off_screen_buffer.getGraphics();
image1 = getImage(applet.getCodeBase(),"aaa.gif");
off_screen.drawImage(image1,10,10,this);
}
public paint(Graphics g){
g.drawImage(off_screen_buffer);
}
为什么画不图象?请指点!!
Image off_screen_buffer;
Graphics off_screen;
Image image1;
public void init(){
off_screen_buffer=createImage(400,350);
off_screen=off_screen_buffer.getGraphics();
image1 = getImage(applet.getCodeBase(),"aaa.gif");
off_screen.drawImage(image1,10,10,this);
}
public paint(Graphics g){
g.drawImage(off_screen_buffer);
}
为什么画不图象?请指点!!
|
int width =100;
int height =100;
BufferedImage bimg=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
Image imgBuffer = (Image)bimg;
Graphics gimg= imgBuffer.getGraphics();
gimg.setColor(Color.lightGray);
gimg.clearRect(0,0,thumbSize.width,thumbSize.height);
gimg.setColor(Color.red);
gimg.drawString(statusString,0,10);
gimg.dispose();
//draw imgBuffer in paint()
g.drawImage(imgBuffer,0,0,this.getWidth(),this.getHeight(),null);
int height =100;
BufferedImage bimg=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
Image imgBuffer = (Image)bimg;
Graphics gimg= imgBuffer.getGraphics();
gimg.setColor(Color.lightGray);
gimg.clearRect(0,0,thumbSize.width,thumbSize.height);
gimg.setColor(Color.red);
gimg.drawString(statusString,0,10);
gimg.dispose();
//draw imgBuffer in paint()
g.drawImage(imgBuffer,0,0,this.getWidth(),this.getHeight(),null);