问题描述
我想在相机表面视图上创建一个遮罩。见下图。掩码是可调整大小。图像将仅被未模糊区域点击。可以任何人给想法如何创建suh面具?
I want to create a mask on camera surface view. see image below. mask is resizable. image will be clicked only by unblurred area. can anybody give idea how to create suh mask? thanks in advance.
推荐答案
您无法在正在接收相机预览的SurfaceView的Surface上绘制。
You can't draw on the Surface of the SurfaceView that is receiving the camera preview.
您有两个基本选项:在SurfaceView的View部分绘制,将其视为,或创建第二个SurfaceView并将其层叠在相机表面上。
You have two basic options: draw on the View part of the SurfaceView, treating it as a custom view, or create a second SurfaceView and layer it on top of the camera surface.
对于后者, href =http://developer.android.com/reference/android/view/SurfaceView.html#setZOrderMediaOverlay(boolean) =nofollow> setZOrderMediaOverlay()
将Surface定位在摄像机表面层上方,但位于视图UI层下方。你可以使用Canvas或GLES来绘制它。您可以在的多表面测试中找到具有三个SurfaceView的活动示例。
For the latter, you would use setZOrderMediaOverlay()
to position the Surface above the camera Surface layer but below the View UI layer. You can use Canvas or GLES to draw on it. You can find an example of an activity with three SurfaceViews in Grafika's "multi-surface test".
这篇关于在android中的surfaceview上创建cameraview(mask)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!