I am trying to draw a bitmap to my SurfaceView
actually with the following code: (this will be run in another Thread
and in a while
, because it needs to refresh the SurfaceView
).
while (true)
{
try
{
// Enable drawing
// ERROR LINE!
Canvas ca = mPreview2.Holder.LockCanvas();
// Get current frame
Bitmap test = mediaPlayer.CurrentFrame;
// Actual drawing
Paint paint = new Paint();
ca.DrawBitmap(test, 0, 0, paint);
// Stop drawing
mPreview2.Holder.UnlockCanvasAndPost(ca);
} catch (Exception ex)
{
throw ex;
}
}
But I've got the following error: (this is happening on line: Canvas ca = mPreview2.Holder.LockCanvas();
Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference