I use standard android tool for compressing PNG texture and archiving it with gzip:
/android-sdks/tools/etc1tool texture.png --encodeNoHeader
gzip texture.pkm
Then I try to load it:
FileHandle file = ...;
ETC1.ETC1Data data = new ETC1.ETC1Data(file);
ETC1TextureData td = new ETC1TextureData(data, false);
Texture texture = new Texture(td);
But I get an java.nio.BufferOverflowException
inside ETC1Data (FileHandle pkmFile)
constructor:
in = new DataInputStream(new BufferedInputStream(new GZIPInputStream(pkmFile.read())));
int fileSize = in.readInt();
compressedData = BufferUtils.newUnsafeByteBuffer(fileSize);
int readBytes = 0;
while ((readBytes = in.read(buffer)) != -1) {
compressedData.put(buffer, 0, readBytes);//Exception occurs here
}
compressedData.position(0);
compressedData.limit(compressedData.capacity());
How to fix it? Thanks.
ps if it's important: unarchived pkm file size is 33KB