How should Java’s drawImage() be used? I do not find the JDK documentation very forthcoming. For example all drawImage signatures require an ImageObserver but the documentation for this is not very helpful for new users.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can get away with
Graphics.drawImage(img, x, y, null)[or similar]. TheImageObserverparameter is a callback to inform you of the progress of the draw operation; and is really only useful if you’re fetching the Image parameter asynchronously.To be clearer, if you call
drawImagewith an incompletely loaded Image it will:Imageas possible (all that is loaded)ImageObserverwhen more of the Image is availableBasically, if you’re working with in memory
Images (either loaded from the file system, or constructed by your program) don’t worry about theImageObserverparameter. If you’re loadingImages across the network and not explicitly waiting for them to load, you’ll need to employ anImageObserverto make sure “completely” draw anImage.