Results 1 to 1 of 1
Thread: Rambling about image loading...
- 04-14-2009, 03:55 PM #1Member
- Join Date
- Feb 2009
- Rep Power
Rambling about image loading...
In my quest to find a reasonably reliable way to load image files into an applet I have come up with yet another tremendously annoying problem and am once again seeking for better options. I'm wondering if anyone else in here would have any fresh ideas for this.
Firstly, some background: I'm working on a multiplayer game client applet. The applet loads image data from a) the jar file containing the applet itself, b) from user-specific jar files generated by the server application and c) occsaionally from separate files located in the server.
The main issue with this equation are the resource jar files. They are essential because they contain hundreds of small images that are necessary for running the application as it is and loading those images one at a time is really slow. The problem is that if for some reason any of these jar files don't contain some file they are supposed to Java registers the zip file as closed and refuses to do further reads into this file.
Now, the methods I've gone with so far are:
- Toolkit.getImage(): Most reliable so far but lacks the possibility to track progress or really catch errors. If the archive file is broken the errors are printed into the java console but the application does not register that and keeps running happily without graphics.
- Toolkit.getImage() with MediaTracker: Adds progress tracking to above. However, a broken jar file causes mt's wait method to lock completely and at least with Mozilla Firefox also locks the whole browser up(I can only close it through task manager in Windows). Needless to say, not what I'd call optimal solution...
- ImageIO: Not supported by Opera Java VM (not sure if it's in general or version specific). Also, on some java versions does not work with PNG files that have small palettes (the graphics resources in our application are shared with mobile clients which means there are plenty of these).
So, that's what I've learned so far after plenty of trial, error and frustration. I'm aware of the fact that the most obvious solution would be to make sure there are no broken resource files, but as I tend to always assume things are going to break down sooner or later (especially if made by me :o ) I'd prefer having something that will at least break with some grace.
- By ramakrishna k m in forum JavaServer Pages (JSP) and JSTLReplies: 5Last Post: 10-10-2011, 06:08 AM
- By lolshooter in forum New To JavaReplies: 3Last Post: 01-06-2009, 08:14 AM
- By balaram in forum Java AppletsReplies: 1Last Post: 11-06-2008, 03:13 PM
- By shaungoater in forum Java 2DReplies: 2Last Post: 01-09-2008, 09:14 AM
- By oregon in forum Java ServletReplies: 1Last Post: 08-05-2007, 06:02 PM