开发者

How to clear preview frame from surface after stopPreview

When I call stopPreview on my camera, the last frame remains on the surfaceview. How do I clear it, to black for example?

I tried setBackGroundColor, setVisib开发者_如何学编程ility but neither make a difference. I assume because it is of type PUSH_BUFFER.

Thanks


Did you try the following? On your surface view, override the onDraw with something like this:

@Override
public void draw(Canvas canvas) {
   super.draw(canvas);

   if (m_stopped) // Set it to true when you stop the preview.
   {
       canvas.drawColor(Color.BLACK);
   }
}

You might need to call invalidate() after you stop the preview in order to make sure the onDraw is called.


Thanks Lior,

Unfortunately, I made a schoolboy error and assumed 0 was black when using setBackGroundColor.

Having actually read the docs this is transparent so am now using Color.BLACK which works as expected.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜