Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Standard tool from Google is not suitable for compression. But ETC1Compressor works fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.