title: Crop function BitBlt(...)
body: <p>I want to create a crop function in an existing engine. This is what I already have:</p>
  
  <pre><code>bool Bitmap::Crop(RECT cropArea)
  {
  BITMAP bm;
  GetObject(m_Handle, sizeof(bm), &amp;bm);
  
  HDC hSrc = CreateCompatibleDC(NULL);
  SelectObject(hSrc, m_Handle);
  
  HDC hNew = CreateCompatibleDC(NULL);
  HBITMAP hBmp = CreateCompatibleBitmap(hNew, bm.bmWidth, bm.bmHeight);
  HBITMAP hOld = (HBITMAP)SelectObject(hNew, hBmp);
  
  BitBlt(hNew, 0, 0, bm.bmWidth, bm.bmHeight, hSrc, 0, 0, SRCCOPY);
  
  SelectObject(hNew, hOld);
  
  DeleteDC(hSrc);
  DeleteDC(hNew);
  
  DeleteObject(m_Handle);
  
  m_Handle = hBmp;
  }
  </code></pre>
  
  <p>I want it to just copy the whole image to a new HBITMAP and replace the old with it. So I know that it works. After that it is just playing with the BitBlt parameters.</p>
  
  <p>m_Handle is a HBITMAP of the class Bitmap.</p>
  
  <p>The result of this code is just a black screen.</p>