943,660 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 7198
  • Java RSS
You are currently viewing page 4 of this multi-page discussion thread; Jump to the first page
Mar 5th, 2008
0

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

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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,756 posts
since May 2007
Mar 5th, 2008
0

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

Click to Expand / Collapse  Quote originally posted by Ezzaral ...
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!
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
CaffeineCoder is offline Offline
54 posts
since Feb 2008
Mar 5th, 2008
0

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

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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,756 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: cohort class compile errors
Next Thread in Java Forum Timeline: can you help, please





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC