title: How to draw a bitmap to a SurfaceView?
body: <p>I am trying to draw a bitmap to my <code>SurfaceView</code> actually with the following code: (this will be run in another <code>Thread</code> and in a <code>while</code>, because it needs to refresh the <code>SurfaceView</code>).</p>
  
  <pre><code>        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;
              }
          }
  </code></pre>
  
  <p>But I've got the following error: (this is happening on line: <code>Canvas ca = mPreview2.Holder.LockCanvas();</code></p>
  
  <pre><code>Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
  </code></pre>