title: Existing Graphics into Bitmap
body: <p>I'm writing a plugin for a trading software (C#, winforms, .NET 3.5) and I'd like to draw a crosshair cursor over a panel (let's say <code>ChartPanel</code>) which contains data that might be expensive to paint. What I've done so far is:</p>
  
  <ol>
  <li>I added a <code>CursorControl</code> to the panel
  <ul>
  <li>this <code>CursorControl</code> is positioned over the main drawing panel so that it covers it's entire area</li>
  <li>it's <code>Enabled = false</code> so that all input events are passed to the parent 
  <code>ChartPanel</code></li>
  <li>it's <code>Paint</code> method is implemented so that it draws lines from top to bottom and from left to right at current mouse position</li>
  </ul></li>
  <li>When MouseMove event is fired, I have two possibilities:
  <ul>
  <li>A) Call <code>ChartPanel.Invalidate()</code>, but as I said, the underlying data may be expensive to paint and this would cause everything to redraw everytime I move a mouse, which is wrong (but it is the only way I can make this work now)</li>
  <li>B) Call <code>CursorControl.Invalidate()</code> and before the cursor is drawn I would take a snapshot of currently drawn data and keep it as a background for the cursor that would be just restored everytime the cursor needs to be repainted ... the problem with this is ... <em>I don't know how to do that</em>.</li>
  </ul></li>
  </ol>
  
  <p>2.B. Would mean to:</p>
  
  <ul>
  <li><strong>Turn existing <code>Graphics</code> object into <code>Bitmap</code> (it (the Graphics) is given to me through Paint method and I have to paint at it, so I just can't create a new Graphics object ... maybe I get it wrong, but that's the way I understand it)</strong></li>
  <li>before the crosshair is painted, restore the Graphics contents from the Bitmap and repaint the crosshair</li>
  </ul>
  
  <p>I can't control the process of painting the expensive data. I can just access my <code>CursorControl</code> and it's methods that are called through the API.</p>
  
  <p>So is there any way to store existing Graphics contents into Bitmap and restore it later? Or is there any better way to solve this problem?</p>
  
  <hr>
  
  <p>RESOLVED: So after many hours of trial and error I came up with a working solution. There are many issues with the software I use that can't be discussed generally, but the main principles are clear:</p>
  
  <ul>
  <li>existing Graphics with already painted stuff can't be converted to Bitmap directly, instead I had to use <code>panel.DrawToBitmap</code> method first mentioned in @Gusman's answer. I knew about it, I wanted to avoid it, but in the end I had to accept, because it seems to be the only way</li>
  <li>also I wanted to avoid double drawing of every frame, so the first crosshair paint is always drawn directly to the <code>ChartPanel</code>. After the mouse moves without changing the chart image I take a snapshow through <code>DrawToBitmap</code> and proceed as described in chosen answer.</li>
  <li>The control has to be Opaque (not enabled Transparent background) so that refreshing it doesn't call Paint on it's parent controls (which would cause the whole chart to repaint)</li>
  </ul>
  
  <p>I still experience occasional flicker every few seconds or so, but I guess I can figure that out somehow. Although I picked Gusman's answer, I would like to thank everyone involved, as I used many other tricks mentioned in other answers, like the Panel.BackgroundImage, use of Plot() method instead of Paint() to lock the image, etc.</p>