简体   繁体   中英

how to decompression texture in android opengl es 2.0

I am having a ETC1 compressed texture.i am using below code to decompress and load the same,

 public void LoadCompressedTexture()
{
    GLES20.glGenTextures(1, bg_grid_tex_id, 0);

    InputStream input = mContext.getResources().openRawResource(R.raw.compressed_tex);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,bg_grid_tex_id[0]);

    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
    GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
    try{
        ETC1Util.loadTexture(GLES20.GL_TEXTURE_2D, 0, 0,GLES20.GL_RGB, GLES20.GL_UNSIGNED_SHORT_5_6_5, input);
    }
    catch(IOException e){
        System.out.println("DEBUG! IOException"+e.getMessage());
    }
}

解压缩的纹理

i am getting the image shape as expected but the size is small, remaining portion is filled with black.

Is there any way to set the height and width before decompressing, so that the size of decompressed image will change??

Can you share the original compressed PKM image file?

Firstly, is your compressor configured to round up width and height to the nearest power or two, and therefore padding the image with black? If so fix this offline (don't pad) or adjust your texture coordindates.

Secondly, if the input texture is correct then the size of the texture on screen has nothing to do with the size of the texture image; it depends on the input geometry of your triangles and the texture coordinates at each vertex. How are you drawing the quad on screen?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM