我在onDrawFrame里面调用glReadPixels获取像素点数组,结果是数据错误,全是-16777216,导致截图后显示黑屏,其它手机(小米,魅族,ov等)调用glReadPixels方法后都是获取到正确的像素点,显示正常,希望官方能够解答疑惑
private Bitmap createBitmapFromGLSurface(int x, int y, 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(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) & 0xffff0000;
int pixel = (texturePixel & 0xff00ff00) | red | blue;
bitmapSource[offset2 + j] = pixel;
}
}
} catch (GLException e) {
LogManager.e(TAG, "GLException: " + e.toString());
return null;
}
LogManager.e(TAG, "bitmapBuffer: " + Arrays.toString(bitmapBuffer));
LogManager.e(TAG, "bitmapSource: " + Arrays.toString(bitmapSource));
return Bitmap.createBitmap(bitmapSource, w, h, Bitmap.Config.ARGB_8888);
}
华为系列手机在GLSurfaceView截屏后黑屏
4
浏览2429 发布于2018-02-08 08:01未知归属地
全部评论
最多点赞
最新发布
最早发布
写回答
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
- 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
- 如您发布的内容为转载内容,请注明内容来源。
我要发帖子
了解社区公约,与您携手共创和谐专业的开发者社区。







































苏公安网备 32011402010933号