Image Array Issue..... Any ideas???

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: May 2007
Posts: 4,490
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 517
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Image Array Issue..... Any ideas???

 
0
  #31
Mar 5th, 2008
The BufferedImage is just an image in memory - it doesn't have a location. It's the paintComponent() calls that render that image to the graphics context. So yes, if you have a reference to the graphics context you can draw that BufferedImage to it.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 41
Reputation: CaffeineCoder is an unknown quantity at this point 
Solved Threads: 0
CaffeineCoder CaffeineCoder is offline Offline
Light Poster

Re: Image Array Issue..... Any ideas???

 
0
  #32
Mar 5th, 2008
Originally Posted by Ezzaral View Post
The BufferedImage is just an image in memory - it doesn't have a location. It's the paintComponent() calls that render that image to the graphics context. So yes, if you have a reference to the graphics context you can draw that BufferedImage to it.

Good to know. Will this allow me to create an image without any flickering when updating?

Thanks!
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,490
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 517
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Image Array Issue..... Any ideas???

 
0
  #33
Mar 5th, 2008
Yes, an off-screen buffer image can be used for such things. If you are actually recreating the image each display cycle it won't really help much, but if the image is only changed occasionally, or you only need to redraw parts of it, it can help quite a bit.

They can be very helpful when you have a constant "background" image (like a game board perhaps) that you draw other things on top of a lot, as the background image only needs to be created from scratch once.

As a general guideline, try to keep the code in paintComponent() as minimal as possible, since repaints occur frequently due to other events besides your own repaint() calls. If your drawing routines are math intensive, try to perform those as infrequently as possible in a separate method and let the painting code just use the results of those calculations.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC