Results 1 to 3 of 3
Thread: Double Buffered
- 01-31-2012, 07:38 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 27
- Rep Power
- 0
Double Buffered
To speed up image manipulation, we use double buffered processing. In Java there is a class which name is BUfferedImages for this purpose. But, I have read on other source and there is another example not use bufferdImages. And I don't know what different about this two solution:
solution 1:
Java Code:Graphics bufferGraphics; Image offScreen; public void init(){ bufferGraphics=offScreen.getGraphics(); } public void paint(g){ //paint Event { bufferGraphics.setClor(Color.red); //other stuff here to draw on bufferGraphics g.drawImage(offScreen,0,0,this); }
Java Code:Graphics2D g2d; BufferedImage backbuffer; public void init(){ g2d=backbuffer.createGraphics(); } public voi paint(g){ g2d.setColor(Color.red); //other stuff here to draw on backbuffer g.drawImage(backbuffer,0,0,this); }
thanks :)
- 01-31-2012, 08:46 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,638
- Rep Power
- 13
Re: Double Buffered
Swing already has - by default - double buffering support: Painting in AWT and Swing Any reason you want to reinvent the wheel? If your drawing to the image takes a while, use a SwingWorker or a separate thread to draw then use the paintComponent to solely draw the image
- 02-02-2012, 05:14 AM #3
Member
- Join Date
- Nov 2011
- Posts
- 27
- Rep Power
- 0
Similar Threads
-
Buffered Images
By sgthale in forum New To JavaReplies: 2Last Post: 08-01-2011, 08:15 AM -
double a * double b = weird output
By GPB in forum New To JavaReplies: 3Last Post: 03-26-2010, 11:40 AM -
Buffered Reader
By ilovepolluting in forum New To JavaReplies: 2Last Post: 02-04-2010, 10:16 AM -
Double.valueOf() vs Double.parseDouble()
By greenbean in forum New To JavaReplies: 10Last Post: 01-12-2009, 09:39 AM
Bookmarks