1 | initial version |
So, here is what I did, nos a real solution, but it may point someone where the real problem is. As I commented, it seems obvious that you can't draw on the same surface used for the camera preview...
I modified SampleViewBase.java in the Tutorial 0 this way to have it working:
public SampleViewBase(Context context) {
[...]
mHolder.setType( SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS );
}
public void setPreview() throws IOException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) mCamera.setPreviewTexture( new SurfaceTexture(10) ); else mCamera.setPreviewDisplay(mHolder); }
public void surfaceCreated(SurfaceHolder holder) { Log.i(TAG, "surfaceCreated"); mHolder = holder; (new Thread(this)).start(); }
public void run() { [...] while (mThreadRun) { [...]
if (bmp != null) {
/*
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawBitmap(bmp, (canvas.getWidth() - getFrameWidth()) / 2, (canvas.getHeight() - getFrameHeight()) / 2, null);
mHolder.unlockCanvasAndPost(canvas);
}
*/
}
}
}
2 | spelling |
So, here is what I did, nos not a real solution, but it may point someone where the real problem is. As I commented, it seems obvious that you can't draw on the same surface used for the camera preview...
I modified SampleViewBase.java in the Tutorial 0 this way to have it working:
public SampleViewBase(Context context) {
[...]
mHolder.setType( SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS );
}
public void setPreview() throws IOException { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) mCamera.setPreviewTexture( new SurfaceTexture(10) ); else mCamera.setPreviewDisplay(mHolder); }
public void surfaceCreated(SurfaceHolder holder) { Log.i(TAG, "surfaceCreated"); mHolder = holder; (new Thread(this)).start(); }
public void run() { [...] while (mThreadRun) { [...]
if (bmp != null) {
/*
Canvas canvas = mHolder.lockCanvas();
if (canvas != null) {
canvas.drawBitmap(bmp, (canvas.getWidth() - getFrameWidth()) / 2, (canvas.getHeight() - getFrameHeight()) / 2, null);
mHolder.unlockCanvasAndPost(canvas);
}
*/
}
}
}