title: Setting Resized bitmap file to an MFC Picture Control
body: <p>Is there an easier way to do it than this, and if this is the only way, are there any potential memory leaks here?</p>
  
  <pre><code>    CImage img1;
              int dimx = 100, dimy = 100;
      img1.Load(filename);
      //filename = path on local system to the bitmap
  
      CDC *screenDC = GetDC();
      CDC *pMDC = new CDC;
      pMDC-&gt;CreateCompatibleDC(screenDC);
  
      CBitmap *pb = new CBitmap;
      pb-&gt;CreateCompatibleBitmap(screenDC, dimx, dimy);
  
      CBitmap *pob = pMDC-&gt;SelectObject(pb);
      pMDC-&gt;SetStretchBltMode(HALFTONE);
      img1.StretchBlt(pMDC-&gt;m_hDC,0, 0, dimx, dimy, 0, 0, img1.GetWidth(), img1.GetHeight(), SRCCOPY);
      pMDC-&gt;SelectObject(pob);
  
      CImage new_image;
      new_image.Attach((HBITMAP)(*pb));
      //
      m_pictureCtrl.SetBitmap(new_image.Detach());
      ReleaseDC(screenDC);
  </code></pre>