8位png图像在opengl loadTexture()操作中是否比32位图像节省内存?

时间:2018-10-01 20:38:14

标签: android memory opengl-es png

由于质量变化不大,我一直在将32位png大图像转换为8位,以查看是否减少了内存使用量。到目前为止,它似乎没有任何影响。因为opengl loadtexture()操作(特别是创建位图)将为32位图像占用8位相同数量的内存,所以这种转换是否浪费了?

编辑11/6以回应评论:

public void loadTexture(final int resourceId,int element)
    {
        // Read in the resource
        final Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId, options);

        // Bind to the texture in OpenGL
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataHandle[element]);

        // Set filtering
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);//GL_NEAREST
        GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);

        // Load the bitmap into the bound texture.
        GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);

        // Recycle the bitmap, since its data has been loaded into OpenGL.
        bitmap.recycle();
    }

0 个答案:

没有答案