我想访问Android中的主要(OpenGL)屏幕来实现一些覆盖3D效果。 是否可以这样做?
如果是,我该怎么办?
在修改此上下文时,我的应用程序应该是一项服务,对不对?
如何访问Android中的主屏幕/ OpenGL缓冲区?
0
A
回答
4
出于明显的安全原因,您无法访问帧缓冲区。
3
你可能想要做的是研究glReadPixels()函数。我运行了一个测试,我用glsurfaceview和image view分割了屏幕,并想看看我是否可以从glview中获取像素并创建一个Bitmap,然后将其应用于ImageView。经过一番研究,我发现使用glReadPixels()的作品,但你必须在使用它们作为android位图之前变换像素。这是我最终使用的方法。我相信我在另一个论坛上发现了这种方式。
public Bitmap SaveGLPixels(int x, int y, int w, int h, GL10 gl)
{
int b[]=new int[w*h];
int bt[]=new int[w*h];
IntBuffer ib=IntBuffer.wrap(b);
ib.position(0);
gl.glReadPixels(x, y, w, h, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, ib);
for(int i=0; i<h; i++)
{//remember, that OpenGL bitmap is incompatible with Android bitmap
//and so, some correction need.
for(int j=0; j<w; j++)
{
int pix=b[i*w+j];
int pb=(pix>>16)&0xff;
int pr=(pix<<16)&0x00ff0000;
int pix1=(pix&0xff00ff00) | pr | pb;
bt[(h-i-1)*w+j]=pix1;
}
}
Bitmap.Config bconfig = Bitmap.Config.RGB_565;
Bitmap sb=Bitmap.createBitmap(bt, w, h, bconfig);
return sb;
}
相关问题
- 1. 访问缓冲区在OpenGL
- 2. 如何访问opengl 2屏幕渲染缓冲区的原始像素数据?
- 3. 控制台中的屏幕缓冲区
- 4. 在Python中操作屏幕缓冲区
- 5. Opengl浮动缓冲区
- 6. OpenGL像素缓冲区直接在Linux和Mac OSX屏幕上
- 7. OpenGL - 顶点缓冲区对象没有绘制到屏幕
- 8. OpenGL-ES 1.1 iPhone - 深度缓冲区导致洋红色屏幕
- 9. 缓冲区的屏幕命令
- 10. Android上的OpenGL深度缓冲区
- 11. 在Windows屏幕上渲染缓冲区
- 12. 渲染到帧缓冲区和屏幕
- 13. 如何在PowerShell中查找最小屏幕缓冲区宽度?
- 14. 访问流缓冲区HttpWebRequest
- 15. 在OpenGL中清除颜色缓冲区
- 16. 模板缓冲区在OpenGL
- 17. 来自屏幕外缓冲区的Android NDK glReadPixels()
- 18. OpenGL深度缓冲区
- 19. OpenGL统一缓冲区?
- 20. OpenGL:渲染缓冲区,深度缓冲区
- 21. Opengl选择缓冲区
- 22. 如何写入OpenGL深度缓冲区
- 23. OpenGL深度缓冲区问题
- 24. OpenGL:缓冲区对象性能问题
- 25. OpenGL多边形z缓冲区问题
- 26. OpenGL绘制缓冲区问题
- 27. OpenGl:模板缓冲区问题(Wall + Window)?
- 28. OpenGL:顶点索引缓冲区问题
- 29. OpenGL ES深度缓冲区
- 30. 如何在android和opengl中使用顶点缓冲区1.1
根本不可能访问主要的gl上下文来绘制覆盖图? – Emanuele 2011-05-16 19:18:58