gpt4 book ai didi

android - 可以在连接到相机的 SurfaceTexture 上绘制吗?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:14:25 26 4
gpt4 key购买 nike

我想在通过 setPreviewTexture 连接到 CameraSurfaceTexture 上绘图。我可以通过 SurfaceTextureListener 获取 SurfaceTexture。但是,如果我只是尝试使用 eglCreateWindowSurface & eglMakeCurrent 它会失败,因为表面已经连接。

1) 是否可以在这个表面上作画?或者是否将其绑定(bind)到相机使得无法做到这一点。

2) 如果不可能。能否将表面快速使用(或复制)到 OpenGL 纹理并在单独的表面中使用?如果是怎么办?

3) 如果不是,从 SurfaceTexture 获取相机预览并进入 OpenGL 的最快方法是什么?

另请注意,让我无法连接的代码的灵感来自 Romain Guy 的帖子:http://groups.google.com/group/android-developers/browse_thread/thread/539457146a401cf1

最佳答案

是的,这是可能的,确实是 SurfaceTexture 的全部要点。问题是我在倒退地思考它们。为了让它们正常工作,您需要:

1) Create a texture through OpenGL.
2) Pass this texture to the constructor of new SurfaceTexture.
3) Give this new SurfaceTexture to the camera.
4) Make sure you are using OES_External (see documentation for
details).

我最大的问题是试图弄清楚如何做相反的事情。也就是说,创建一个 SurfaceTexture 并将其传递给 OpenGL。但相反的才是正确的做法。

关于android - 可以在连接到相机的 SurfaceTexture 上绘制吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8582090/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com