private Bitmap createBitmapFromGLSurface(int w, int h, GL10 gl) { int bitmapBuffer[] = new int[w * h]; int bitmapSource[] = new int[w * h]; IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer); intBuffer.position(0); try { gl.glReadPixels(0, 0, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, intBuffer); int offset1, offset2, texturePixel, blue, red, pixel; for (int i = 0; i < h; i++) { offset1 = i * w; offset2 = (h - i - 1) * w; for (int j = 0; j < w; j++) { texturePixel = bitmapBuffer[offset1 + j]; blue = (texturePixel >> 16) & 0xff; red = (texturePixel << 16) & 0x00ff0000; pixel = (texturePixel & 0xff00ff00) | red | blue; bitmapSource[offset2 + j] = pixel; } } } catch (GLException e) { Log.e("CreateBitmap", "createBitmapFromGLSurface: " + e.getMessage(), e); return null; } return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888); }
private void checkError() { int eglError; if ((eglError = mEgl10.eglGetError()) != EGL_SUCCESS) { String errorMessage = "eglError: " + getErrorString(eglError); logLine(errorMessage); if (mCheckError) { throw new GLException(eglError, errorMessage); } } }
private void checkError() { int eglError; if ((eglError = mEgl10.eglGetError()) != EGL_SUCCESS) { String errorMessage = "eglError: " + getErrorString(eglError); logLine(errorMessage); if (mCheckError) { throw new GLException(eglError, errorMessage); } } }
private Bitmap createBitmapFromGLSurface(int w, int h, GL10 gl) { int bitmapBuffer[] = new int[w * h]; int bitmapSource[] = new int[w * h]; IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer); intBuffer.position(0); try { gl.glReadPixels(0, 0, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, intBuffer); int offset1, offset2, texturePixel, blue, red, pixel; for (int i = 0; i < h; i++) { offset1 = i * w; offset2 = (h - i - 1) * w; for (int j = 0; j < w; j++) { texturePixel = bitmapBuffer[offset1 + j]; blue = (texturePixel >> 16) & 0xff; red = (texturePixel << 16) & 0x00ff0000; pixel = (texturePixel & 0xff00ff00) | red | blue; bitmapSource[offset2 + j] = pixel; } } } catch (GLException e) { Log.e("CreateBitmap", "createBitmapFromGLSurface: " + e.getMessage(), e); return null; } return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888); }