Skip to main content

ImageObserver.imageUpdate can no more determine which image is ready.

2 replies [Last post]
25or6to4
Offline
Joined: 2008-09-07

Applet.getImage returns an Image class, ImageObserver.imageUpdate
receives an Image class as parameter.

In Java Plug-in 1.6.0_07 getImage returned a
sun.awt.image.ToolkitImage and imageUpdate received also a
sun.awt.image.ToolkitImage as parameter.
By testing for Image equality, imageUpdate could determine
which previously prepared image was currently ready.

In Java Plug-in 1.6.0_10-rc getImage now returns
a sun.plugin.util.ToolkitImageWrapper and imageUpdate still receives a
sun.awt.image.ToolkitImage as parameter.
This is a problem since imageUpdate cannot make an equality test to
determine which previously prepared image is currently ready.

This is is illustrated in the applet below.

With Java Plug-in 1.6.0_07 the output of the applet is:
Preparing image1.jpg (sun.awt.image.ToolkitImage@1820dda)
Preparing image2.jpg (sun.awt.image.ToolkitImage@112f614)
image2.jpg is ready
image1.jpg is ready

Java Plug-in 1.6.0_10-rc the output of the applet is:
Preparing image1.jpg (sun.plugin.util.ToolkitImageWrapper@176c74b)
Preparing image2.jpg (sun.plugin.util.ToolkitImageWrapper@1ee3914)
sun.awt.image.ToolkitImage@1f14ceb is ready but it does not match any of the prepared images
sun.awt.image.ToolkitImage@f0eed6 is ready but it does not match any of the prepared images

// ---------------------------------------------------------------------
import java.applet.*;
import java.awt.*;
import java.awt.image.*;

public class Java6Bug extends Applet implements ImageObserver
{
Image image1, image2;
String image1Name = "image1.jpg";
String image2Name = "image2.jpg";

public void init()
{
image1 = getImage(getCodeBase(), image1Name);
image2 = getImage(getCodeBase(), image2Name);
System.out.println("Preparing " + image1Name + " (" + image1 + ")");
prepareImage(image1, this);
System.out.println("Preparing " + image2Name + " (" + image2 + ")");
prepareImage(image2, this);
}

public boolean imageUpdate(Image img, int infoflags,
int x, int y, int width, int height)
{
if ( (infoflags & ImageObserver.ALLBITS) != 0 )
{
if ( img == image1 )
System.out.println(image1Name + " is ready");
else
if ( img == image2 )
System.out.println(image2Name + " is ready");
else
System.out.println(img + " is ready but it does not match any of the prepared images");
}
return true;
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
masterzen
Offline
Joined: 2005-07-01

I also encountered this issue, and there is no workaround.

I didn't know if you reported the issue bugs.sun.com, so I took the liberty to do so.
Please vote for it, when it'll be publicly visible, that'll give us more chance to see it fixed.

Thanks,
Masterzen

trembovetski
Offline
Joined: 2003-12-31

please file a bug against java plugin (since it appears to be them who broke this).