List of usage examples for javax.microedition.khronos.opengles GL10 glTexImage2D
void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, java.nio.Buffer pixels);
From source file:Main.java
/** * non-premultiplied alpha version of GLUtils.texImage2D(). Note: this method is Slow and should only be used when really necessary! * * @param gl// www . ja v a2 s.c o m * @param bitmap * @see GLUtils.texImage2D() */ public static void texImage2DNonPremultipliedAlpha(final GL10 gl, final Bitmap bitmap) { final int[] pixels = extractPixels(bitmap); final byte[] pixelComponents = new byte[pixels.length * 4]; int byteIndex = 0, p; for (int i = 0; i < pixels.length; i++) { p = pixels[i]; // Convert to byte representation RGBA required by gl.glTexImage2D. pixelComponents[byteIndex++] = (byte) ((p >> 16) & 0xFF); // red pixelComponents[byteIndex++] = (byte) ((p >> 8) & 0xFF); // pixelComponents[byteIndex++] = (byte) ((p) & 0xFF); // blue pixelComponents[byteIndex++] = (byte) (p >> 24); // alpha } gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA, bitmap.getWidth(), bitmap.getHeight(), 0, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, ByteBuffer.wrap(pixelComponents)); }