title: Draw lines using Device Context over a CImage object
body: <p>Im building a MFC c++ application in which i let the user read an image, draw lines on it and then save it.</p>
  
  <p>so i have a "CImage" object which is called "Image" in which the user loads the image to.</p>
  
  <p>and i have a device context object and i was able to draw lines on it
  <em>the device context object that is</em> in run-time using "OnLButtonDown" and "OnLButtonUp" event handlers.</p>
  
  <p>i then let the user save the image using "CImage.save" .. the image is saved but the device context drawn lines aren't there which is to be expected ..
  but I DO want them to appear in the saved image..</p>
  
  <p>the question is how can i get the device context Object to affect my CImage Object? </p>
  
  <p>this is the event handler for mouse button down</p>
  
  <pre><code>void CProFilterDlg::OnLButtonDown(UINT nFlags, CPoint point)
  {
      curser =point;
      if (draw &amp;&amp; Boundry.PtInRect(point) )
      {
          CDialogEx::OnLButtonDown(nFlags, point);
      }
  
  }
  </code></pre>
  
  <p>and this one when the mouse button is up</p>
  
  <pre><code>void CProFilterDlg::OnLButtonUp(UINT nFlags, CPoint point)
  {
      if (draw &amp;&amp; Boundry.PtInRect(curser) &amp;&amp; Boundry.PtInRect(point))
      {
          CClientDC dc(this);
          dc.MoveTo(curser);
          dc.LineTo(point);
          CDialogEx::OnLButtonUp(nFlags, point);
      }
  
  
  }
  </code></pre>
  
  <p>this is where i load my Cimage object</p>
  
  <pre><code>void CProFilterDlg::OnBnClickedBtnBrowse()
  {
      CFileDialog Browse(true);
      if(Browse.DoModal() == IDOK)
      {
           ImagePath = Browse.GetPathName();
      }
  
          image.Load(ImagePath);
  }
  </code></pre>
  
  <p>and this is where i save my CImage</p>
  
  <pre><code>void CProFilterDlg::OnBnClickedSave()
  {
      CFileDialog Save(true);
      if(Save.DoModal() == IDOK)
      {
          ImagePath = Save.GetPathName();
      }
      image.Save(ImagePath,Gdiplus::ImageFormatBMP);
  }
  </code></pre>