The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 The Perils of Image.getScaledInstance()
Subject:  g.drawImage's asynch behaviour and ImageObserver
Date:  2007-08-28 08:44:23
From:  stolsvik


Quoting from the javadoc (for all versions of the method):
" This method returns immediately in all cases, even if the complete image has not yet been loaded, and it has not been dithered and converted for the current output device. "

I see you always send null as ImageObserver. However, there is no place in the javadoc (jdk 6) that states that sending null will make this synchronous, as opposed to the asynchronous "Image", ImageProducer, ImageConsumer, ImageObserver BS from java 1. Also, the quoted drawImage methods are all on the Graphics class, whatever that hints at.

So, to me it seems much more likable to use the Graphics2D.drawRenderedImage(RenderedImage image, AffineTransform transform), which at least seems to be synchronous (although as normal the javadoc just doesn't state such highly important stuff properly)..

Comments here? Will sending null to the ImageObserver actually make the method behave synchronous? Is the javadoc lying?

 Feed java.net RSS Feeds