ICODecoder fails to read the image from a jar file
Brought to you by:
ianmdev
We have icons checked into our jar file. Reading such an icon using the simplest code I expect to work:
try (InputStream stream = resource.openStream()) {
icos = ICODecoder.readExt(stream);
}
results in an IOException at present.
A cursory look at the code reveals several basic bugs - for instance, instead of calling read(byte[]) in a loop, it is called once and then any result other than the expected length results in an exception.
However, due to another bug which I raised separately, it is impossible to know what the actual error was.
Would it be possible for you to post an example jar file that can be read to produce the problem?
I suppose this happens on large layers. On some icons I'm using this occurs on layer #3 which is 256x256 pixels in size. It seems that the Ressource InputStream.read Method doesn't fill the byte array in one turn.
Changing src\net\sf\image4j\codec\ico\ICODecoder.java
lines 230-233:
to:
fixes that in my case.
This problem should now be fixed.
Latest sources are now available at https://github.com/imcdonagh/image4j.