#Convert GL_TEXTURE_2D To Android Bitmap

1 messages ยท Page 1 of 1 (latest)

umbral skiffBOT
#

<@&987246883653156906> please have a look, thanks.

#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Good day reader!! I want to convert GL_TEXTURE_2D to Android Bitmap in the most fastest way possible Thanks in advance

To convert GL_TEXTURE_2D to Android Bitmap, you can use the following method:

public Bitmap convertGLTextureToBitmap(int textureId, int width, int height) {
    int[] pixels = new int[width * height];
    IntBuffer intBuffer = IntBuffer.wrap(pixels);
    intBuffer.position(0);

    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
    GLES20.glPixelStorei(GLES20.GL_PACK_ALIGNMENT, 1);
    GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, intBuffer);

    Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    bitmap.setPixels(pixels, 0, width, 0, 0, width, height);

    return bitmap;
}

Useful links: