title: How to Invalidate only part of a paintbox/bitmap to optimise its performance?
body: <p>The question relates to: <a href="https://stackoverflow.com/questions/25509235/drawing-on-a-paintbox-how-to-keep-up-with-mouse-movements-without-delay">Drawing on a paintbox - How to keep up with mouse movements without delay?</a></p>
  
  <p>I was going to at some point ask the question of how to repaint only part of a paintbox without invalidating the whole paintbox, which is slow when there is a lot of drawing going on or in my case when there are a lot of tiles drawn on screen.</p>
  
  <p>From the link above <a href="https://stackoverflow.com/users/3962893/peter-kostov">Peter Kostov</a> did touch on the subject briefly in one of his comments: </p>
  
  <blockquote>
    <p>you can partly BitBlt the offscreen bitmap (only regions where it is changed). This will improve the performance dramatically.</p>
  </blockquote>
  
  <p>I have limited graphic skills and have never really used <code>BitBlt</code> before but I will be reading more about it after I post this question.</p>
  
  <p>With that said, I wanted to know how exactly could you determine if regions of a bitmap have changed? Does this involve something simple or is there more magic so to speak involved in determining which regions have changed?</p>
  
  <p>Right now I am still painting directly to the paintbox but once I draw to the offscreen buffer bitmap my next step is to optimise the painting and the above comments sound exactly like what I need, only the determining regions that have changed has confused me slightly.</p>
  
  <p>Of course if there are other ways of doing this please feel free to comment.</p>
  
  <p>Thanks.</p>