Archived

This topic is now archived and is closed to further replies.

Loading images in Java

This topic is 4969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to use a JPG as the introduction screen for a game. I have gotten as far as loading an Image through the Toolkit.createImage(filename) method. However, Image is an abstract class; I don''t quite understand how to convert it to a BufferedImage. Maybe I don''t need this right now, but I''d still like to understand how Java''s image-handling works. Can anyone help me with this? I''ve tried looking through the API specification, but I have not found any Image-to-BufferedImage information. Does Toolkit automatically produce a BufferedImage, so it''s safe to use typecasting? I''m confused!

Share this post


Link to post
Share on other sites
Use ImageIO.read() to load images.

http://wiki.java.net/bin/view/Games/LoadingSpritesWithImageIO

[edited by - nonnus29 on June 9, 2004 8:12:16 PM]

Share this post


Link to post
Share on other sites
Thank you. I had accidentally bookmarked the docs for version 1.3.2, which doesn''t have the javax.imageio package. Oops.

Share this post


Link to post
Share on other sites
Download documentation for offline viewing.
It''s safer and more confy.

Share this post


Link to post
Share on other sites