Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中以编程方式拍摄GLSurfaceView的屏幕截图_Android - Fatal编程技术网

如何在android中以编程方式拍摄GLSurfaceView的屏幕截图

如何在android中以编程方式拍摄GLSurfaceView的屏幕截图,android,Android,我想在android中以编程方式拍摄GlSurfaceView的屏幕截图。我正在使用下面的代码来实现此功能,但我无法实现此功能。请帮助我以编程方式拍摄GLSURFACHEVIEW的屏幕截图 校准方法 createBitmapFromGLSurface((int)customglSurfaceView.getX(), (int)customglSurfaceView.getY(), 方法体 public static Bitmap createBitmapFromGLSurface(int x

我想在android中以编程方式拍摄GlSurfaceView的屏幕截图。我正在使用下面的代码来实现此功能,但我无法实现此功能。请帮助我以编程方式拍摄GLSURFACHEVIEW的屏幕截图

校准方法

createBitmapFromGLSurface((int)customglSurfaceView.getX(), (int)customglSurfaceView.getY(), 
方法体

public static Bitmap createBitmapFromGLSurface(int x, int y, int w, int h) throws OutOfMemoryError {
    int bitmapBuffer[] = new int[w * h];
    int bitmapSource[] = new int[w * h];
    IntBuffer intBuffer = IntBuffer.wrap(bitmapBuffer);
    intBuffer.position(0);

    try {
        glObject.glReadPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, intBuffer);
        int offset1, offset2;
        for (int i = 0; i < h; i++) {
            offset1 = i * w;
            offset2 = (h - i - 1) * w;
            for (int j = 0; j < w; j++) {
                int texturePixel = bitmapBuffer[offset1 + j];
                int blue = (texturePixel >> 16) & 0xff;
                int red = (texturePixel << 16) & 0x00ff0000;
                int pixel = (texturePixel & 0xff00ff00) | red | blue;
                bitmapSource[offset2 + j] = pixel;
            }
        }
    } catch (GLException e) {
        return null;
    }
    return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888);
}
公共静态位图createBitmapFromGLSurface(int x,int y,int w,int h)抛出OutOfMemoryError{
int bitmapBuffer[]=新的int[w*h];
int bitmapSource[]=新int[w*h];
IntBuffer IntBuffer=IntBuffer.wrap(bitmapBuffer);
intBuffer.position(0);
试一试{
glReadPixels(x,y,w,h,GL10.GL_RGBA,GL10.GL_无符号字节,intBuffer);
国际抵销1,抵销2;
对于(int i=0;i>16)&0xff;

int red=(texturePixel在此处尝试解决方案:[StackOverflow:OpenGL屏幕截图Android][1][1]:@Kai Its solve my problem。