Opengl camera glReadPixels 截图--源码

    xiaoxiao2022-07-07  202

    val pixels = IntBuffer.allocate(screenWidth * screenHeight) GLES20.glReadPixels(0, 0, screenWidth, screenHeight, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, pixels ) val stitchBmp = Bitmap.createBitmap(screenWidth, screenHeight, Bitmap.Config.ARGB_8888) stitchBmp.copyPixelsFromBuffer(pixels)

    错误

    使用IntBuffer而不是ByteBuffer之前用ByteBuffer(screenWidth * screenHeight *4)发现不可以,这个方法是 glReadPixels 数组是像素的大小,而不是像素分量的大小

    源码

    https://github.com/AlbertSnow/GraphicDemo

    模块Camera Merge Preview With Overlay Texture

    类CameraTextureGLProgram

    最新回复(0)