Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

老哥,在部分华为手机上,运行您的Demo,拍照可以保存照片,但照片是黑色,是什么原因? #36

Closed
StoneCodingg opened this issue Jan 24, 2019 · 6 comments

Comments

@StoneCodingg
Copy link

No description provided.

@CainKernel
Copy link
Owner

华为手机需要另外找办法从GPU中提取数据,比如ImageReader等工具,glReadPixels无法提取。华为官方没给出解决方案,这个问题都存在好几年了。

@StoneCodingg
Copy link
Author

有实现的Demo,或者可以提供一下具体的解决思路或者博客吗?网站找glReadPixels获取失败的相关解决都是无效的,相关资料也很少
我是需要将getCurrentFrame()方法直接替换成其他的方法去获取缓冲区中的数据吗?

@CainKernel
Copy link
Owner

跟这篇文章写的思路是一样的 —— android 使用ImageReader+共享EGLContext把opengles渲染的图像转bitmap
直接提取GPU纹理数据出错,那就只能用ImageReader 等自带的工具提取,利用新的Surface创建一个SharedContext,makeCurrent到SharedContext上下文中,然后将纹理绘制到Surface中,ImageReader在接收到纹理数据之后,通过reader.acquireNextImage()取出获取图像数据,然后再取出来,思路就这么简单。还有Android 7.0 可以通过DirectTexture直接同GPU内存中提取纹理数据,只不过由于GraphicBuffer对象是在 libui.so中,Android 7.0之后,不能通过dlopen来加载这个非公开共享库了,所以这个方法基本失效。而OpenGLES3.0的PBuffer方案,也不能保证底层一定能够提取得到纹理数据,因此,最稳妥的方案应该是ImageReader了。

@gaoqianZ
Copy link

这个问题你解决了吗

@CainKernel
Copy link
Owner

CainKernel commented Mar 12, 2019 via email

@StoneCodingg
Copy link
Author

感谢作者百忙中抽出时间回复,最近忙新的项目,这个问题也一直拖着没解决,您分享的内容及解决办法我大致看了下,只是没时间去代码实现,非常感谢您!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants