How to copy a canvas into a bitmap
<p>Is there any way to copy the contents of a canvas I have just drawn onto, into a bitmap?</p>

<p><strong>EDIT:</strong> just to clarify, my current drawing procedure works as follows:</p>

<pre><code>Canvas canvas = holder.lockCanvas();

if (canvas != null)
{
  onDraw(canvas); // this does all the drawing

  // at this point I would like to copy the canvas into a bitmap

  holder.unlockCanvasAndPost(canvas); // this makes the canvas visible to the user
}
</code></pre>

<p><strong>EDIT:</strong> Looking at the first answer posted, I have written the following code:</p>

<pre><code>if (grab_screen == -1) // draw and show on screen as normal
{
    Canvas canvas = holder.lockCanvas();
    if(canvas != null)
    {
        onDraw(canvas);
        holder.unlockCanvasAndPost(canvas);
    }                   
}
else // draw into screengrab_bitmap[grab_screen]
{
    Canvas canvas = new Canvas(screengrab_bitmap[grab_screen]);
    onDraw(canvas);
    grab_screen = -1;
}
</code></pre>

<p>This should mean that if I set grab_screen to n, then on the next call to onDraw, the image will be written to screengrab_bitmap[n].</p>
