Recently I packed all my data files together to save space in the Jar (and boy did it save a lot of space, like 30%!) and changed the Image creation routine to read in the image and then create the image from the bytes in memory.
This works but is slow as molasses on the 7210 - I'm talking like 5 seconds to create each image.
Am I doing anything wrong ? or can anyone suggest a better way of doing this ?
public Image CreateImage( int nResourceID )
This technique is especially effective with 256 colour images that all have the same palette - the palette takes an additional 768 bytes in the png, and compression will remove all except one.
I think your code is slow because you are re-reading the file for each image. You cannot randomly-access data in a jar, so skip() has to read all the data upto that point, unzipping as it goes. So you are repeatedly unzipping the same data. Can you load the entire binary file into memory, then extract the icons using:
>I think your code is slow because you are re-reading the file for
>each image. You cannot randomly-access data in a jar, so skip() >has to read all the data upto that point, unzipping as it goes.
Of course - I'd forgotten that the packed data file was also compressed and so needs to be decompressed before the data can be read out of it.
>Can you load the entire binary file into memory, then extract the icons using:
Not quite - I've got too much data to load in at once, but I'm sure I can split the packed file into the different chunks that will be needed at the same time and load those bits into memory - which should be just as good