Yet Another Image Question...

Yes… I’m one of many java newbies who just can’t seem to be able to load an image right.

So on to the Question:
I was using Toolkit.getDefaultToolkit().getImage(…) to
load an image until one day i discovered it had asynchronous loading and so the drawing of a 1024x768 image wasn’t exactly a great spectacle.

I tried to slip past this little glitch by drawing the acquired image to a BufferedImage and the on to the graphics object…
Darkness…The output was a (completely) black image.

But this could not daunt me (yet…). So i tried ImageIO.read(…). And yes ,the loading was synchronous. But the image had transparent spots (.gif) which were black…(using the previous method no such problem occured) .

I know i’m doing something wrong in both of these methods…so if it’s obvious by the above storytelling ,tell me. If not, say which code segment i should post.

Thanks guys

for the toolkit.getImage() asyncronous loading,
are you waiting for the loading to complete before drawing the image?

as for ImageIO.read()

I believe there is a bug with ImageIO.read() and the bitmask transparency of gifs.

The transparency will only be maintained, if the color marked as transparent is index 0 in the palette.

If i’m not mistaken (not a very possible scenario…) Toolkit.getDefaultToolkit().getImage() starts loading
the image when you call graphics.drawImage(). So even if i draw it in a BufferedImage or a JComponent the procedure of loading is pretty much automated.

(love that wako guy… )