Skip to content

[QUESTION] Write ETC1 Compressed Texture in a Swing Application #1

@ndorigatti

Description

@ndorigatti

Hi @nicastel , I'm looking at this wonderful repo to find out if it could be possibile to write to a file the ETC1 compressed texture as pkm format instead of writing the PNGs.

I have done a swing application that from a GEOTIFF creates the tiles for worldwind but it writes PNG files.
Since in the worldwind app, PNGs must be read, compressed and then showed, I'd prefer to compress the tiles in the desktop app since it is made one time only (the app will be offline, so tiles are prepared in desktop app).
I am looking at the pure Java implementation but i see that in the file ETC1Benchmarck.testJavaETC1ImageCompressor
you have a "testing purpose" file writing that states:

if (texture != null) {
int estimatedMemorySize = ETC1.ETC_PKM_HEADER_SIZE+ texture.getHeight() * texture.getWidth() / 2;
File f = new
File(Environment.getExternalStorageDirectory(),"bmngpkm.pkm");
f.delete();
f.createNewFile();
ETC1Util.writeTexture(texture, new FileOutputStream(f));
System.out.println("Texture PKM created ");
}

Do you think we can make ETC1Util.writeTexture available for Swing Application too?
I was looking at what the method does
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4.2_r1/android/opengl/ETC1Util.java#ETC1Util.writeTexture%28android.opengl.ETC1Util.ETC1Texture%2Cjava.io.OutputStream%29
and it seems to rely on "convertable" code, but two functions are native:
ETC1.formatHeader and ETC1.getEncodedDataSize

from your expertees and knowledge, do you think is feasible or do you have already tried/done it?

The signature method of ETC1Util can be changed from:
(ETC1Texture texture, OutputStream output)
to
(ByteBuffer dataBuffer, int width, int height, OutputStream output)
and all the references to ETC1Texture on desktop are removed, but I'm scared about those native methods.

Many Thanks,
Nicola

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions