title: Visualising multi-layer image in WPF
body: <p>My data structure has two fields:</p>
  
  <pre><code>* BackgroundImage (of type Bitmap/Image)
  * Points (of type Point2D [])
  </code></pre>
  
  <p>My use case is as follows: a user can load an image into the app. After the image appears on user's screen, they might add points to it (by clicking a mouse button). The points should be visualized on the top of the image, but a user should be albe to reposition them if needed (e.g. drag'n'drop). </p>
  
  <p>At the moment I solve the problem by doing the following every time the user adds / moves a point:
  * clone the BackgroundImage
  * draw all the points on the cloned image (using System.Drawing.Graphics)
  * return the cloned image with the points (expose it as a property and bind to Image in WPF).</p>
  
  <p>The time performance of this solution is ok, however it consumes a lot of memory, as everytime I end up copying whole image. I'm wondering if there's a better way of doing this (e.g. by using layers - then my BackgroundImage remains the same all the time while I keep modifying only the top layer).</p>
  
  <p>My code is quite long, but if it's needed just let me know and I'll post it.</p>