title: c++ efficiently draw line over background image
body: <p>A <code>TBitmap* prevImg</code> object takes some time to be generated, so I generate it once and want to set it as a <em>background</em>:</p>
  
  <pre><code>Image1-&gt;Picture-&gt;Assign(prevImg); //TImage* Image1
  </code></pre>
  
  <p>Now I want to paint some lines and numbers on mousemove on top of this:</p>
  
  <pre><code>void __fastcall TTriggerSystemForm::Image1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y){
    if(!prevImg)return;
    Image1-&gt;Picture-&gt;Assign(prevImg); //reset image
  
    Image1-&gt;Canvas-&gt;Pen-&gt;Color=clRed; //draw a vertical dotted red line
    Image1-&gt;Canvas-&gt;Pen-&gt;Style=psDot;
    Image1-&gt;Canvas-&gt;MoveTo(X,0);
    Image1-&gt;Canvas-&gt;LineTo(X,Image1-&gt;Picture-&gt;Height);
  }
  </code></pre>
  
  <p>Now this is working already fine. However, since the image is sometimes blinking and the task's CPU goes up to 8% just because of this mousemove-Event, this is probably not very effective.</p>
  
  <p>I'm using C++ Builder XE2 with VCL.</p>
  
  <p><strong>Is there a better way to draw something dynamically on a given TImage object without changing the original image source?</strong></p>