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.
精彩评论