This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Image Observer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Image Observer" Watch "Image Observer" New topic
Author

Image Observer

liliya woland
Ranch Hand

Joined: Apr 11, 2006
Posts: 134
Hello,
I'm implementing/attempting to implement Image Observer in a servlet to draw an image


and have implementation for the method imageUpdate( java.awt.Image image, int flags, int x, int y, int width, int height).
The method does get called and executed. In log, I can see it attempting to wait for the .drawImage call to finish, but the image never gets drawn.
Does anyone know anything about this? Thanks in advance.
Here is the imageUpdate - The lines that show up in the log are 0,4 and 7 - AND NOTHING ELSE!
Romain Guy
author
Ranch Hand

Joined: Sep 18, 2007
Posts: 47
Instead of using an ImageObserver you can make sure that all of your image instances are instances of BuffereImage. A BufferedImage, contrary to the ToolkitImage, is guaranteed to be loaded synchronously.
Chet Haase
author
Ranch Hand

Joined: Aug 16, 2007
Posts: 32
Also note: when you do use a BufferedImage (which, for instance, is created for you if you load images via ImageIO, or which you can create from scratch in various ways), then you should pass null as the ImageObserver argument to drawImage:



Chet.


Book: <a href="http://filthyrichclients.org" target="_blank" rel="nofollow">http://filthyrichclients.org</a> <br />Java: <a href="http://weblogs.java.net/blog/chet" target="_blank" rel="nofollow">http://weblogs.java.net/blog/chet</a> <br />Humor: <a href="http://chetchat.blogspot.com" target="_blank" rel="nofollow">http://chetchat.blogspot.com</a>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Image Observer
 
Similar Threads
Image Dimensions
problem while displaying multipage tiff image in applet
Resizing Large JPG Problem
Java- Image height required
why is an interface's varable static, and a method not allowed to be static?