开发者

Android - How can I show camera in 2 or more views

I'm trying to create an Android app based on camera. I want to split my screen into 2 or 4 views. (when 2 views are show, one will be above and one will be 开发者_如何学Pythonbelow. And when 4 views, 2 will be on top (side by side) and 2 will be at bottom (side by side)) I want to show the what camera is seeing in all the views. I mean all the views must render according to camera. Is it possible? HOw?


This is not practical AFAIK. The camera will draw to only one SurfaceView, not four. While you could try to make a mock SurfaceView that then passes the information to four separate SurfaceViews, your performance probably will be awful.


The only way I see this being possible is having setPreviewCallback() method take those frames, converting them to bitmaps or jpegs, and then drawing those images on the other surface views. I'm with CommonsWare though. It will be slow and painful.


I've actually did that in my app Face Costume: Face Costume

What I did was use the camera preview buffer, convert it from YUV to RGB, and render it on an OpenGL texture. You don't have to choose OpenGL, you can also do it using the regular canvas method.

On dual core tablets it works well... haven't tested it on other hardware.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜