I have around 150 gifs (all rather small = 1KB) in a static class and in statements like these
public final static ImageIcon I_ADDFAV = new ImageIcon("icons/addfavorite.gif");
public final static ImageIcon I_AUTO_LOAD = new ImageIcon("icons/auto_load.gif");
...
I use them to display JButtons with icons. During Application start I noticed an increased loading time associated to these statements of approximately 2seconds. I would like to know if somebody knows a faster way to load these gifs. I was thinking that boundly all of them in a single file could be a way as I suspect that reading 150 small files from disc is the actual delay in this. But I could be wrong. Does anybody have a smart idea or has ever handled such situation? We would like to bring this down to msecs.
cheers ioannis
I would recommend combining all the images into a single file, much as a website should combine all its image requests into a single request for a bunch of sprites. Almost all of the time spent loading a file from disk is spent in seek time (moving the head to the right track on the disk) and rotational delay (waiting for the disk to rotate around so the head is over the right bits). So, the time to read a large file from disk is essentially the same as the time to read a lot of small files from disk, and once the large image is in memory you can pull apart all the sprites and show them on your buttons.