title: Display Issue with resized PNG images in MFC application
body: <p>in our MFC application, we are using lots of images(jpg and png). when we launch the application we are loading all the images into a map.
  whenever we resize the application we are resizing all the images in the map.
  we are using nearly 300 images so it is taking 3secs to resize the application.
  we tried to split the images into different maps based on requirement but that also has an impact on performance. managing is also becoming tuff.</p>
  
  <p>Along with this, there is one more issue on quality when we resize .png images. After resizing all the transparent area is becoming a blur. </p>
  
  <p>In our code we are using CxImage class for loading, rendering and resizing the image.</p>
  
  <p>Below is the code sample. Please suggest how to handle these kind of issues.
  can we use SVG files in MFC application? </p>
  
  <p>Loading the image</p>
  
  <pre class="lang-cpp prettyprint-override"><code>    int CPicture::Load(CString sFileName)
      {
          CString strFullFileName = sFileName;
          CString strOrigFileName = strFullFileName;
          int nRet = strFullFileName.ReverseFind('.');
          if(nRet != -1)
          {
              strFullFileName.Insert(nRet, _T("_bl"));
          }
  
          if( FALSE == CheckIfFileExists(strFullFileName) )
          {
              strFullFileName = strOrigFileName;
          }
      }
  
      CString ss = sFileName;
      ss.MakeLower();
  
      if(ss.Find(_T(".png")) &gt; 0)
      {
          // forcefully loading new images 
          if(m_pXImage)
          {
              SAFE_DELETE(m_pXImage);
          }
          if(NULL == m_pXImage)
          {
              m_pXImage = new CxImage(strFullFileName, CXIMAGE_FORMAT_PNG);
          }
          if (!m_pXImage-&gt;IsValid()){
              SAFE_DELETE(m_pXImage);
              //AfxMessageBox(m_pXImage-&gt;GetLastError());
              return E_IMAGEFILE_NOTLOADED;
          }
          msName = strFullFileName;
          return E_IMAGEFILE_LOADED;
      }
  
      if(ss.Find(_T(".gif")) &gt; 0)
      {
          // forcefully loading new images 
          if(m_pXImage)
          {
              SAFE_DELETE(m_pXImage);
          }
          if(NULL == m_pXImage)
          {
              m_pXImage = new CxImage(strFullFileName, CXIMAGE_FORMAT_GIF);
          }
          if (!m_pXImage-&gt;IsValid()){
              SAFE_DELETE(m_pXImage);
              //AfxMessageBox(m_pXImage-&gt;GetLastError());
              return E_IMAGEFILE_NOTLOADED;
          }
          msName = strFullFileName;
          return E_IMAGEFILE_LOADED;
      }
      int bResult = E_IMAGEFILE_NOTLOADED;
      if (m_pPicture != NULL)
          UnLoad();
  
      if (m_pPicture == NULL)
      {
          CFile           cFile;
          CFileException  fileException;
  
          if(!cFile.Open(strFullFileName, CFile::modeRead | CFile::typeBinary, &amp;fileException))
          {
              if(!cFile.Open(strFullFileName, CFile::modeRead | CFile::typeBinary, &amp;fileException))
              {
                  return E_IMAGEFILE_MISSING;
              }
          }
  
          msName = strFullFileName;
  
          if(cFile.GetLength() &lt;= 0)
          {
              cFile.Close(); 
  
              return E_IMAGEFILE_MISSING;
          }
  
          int nSize = static_cast&lt;int&gt; (cFile.GetLength());
          BYTE* pBuff = new BYTE[nSize];
  
          if (cFile.Read(pBuff, nSize) &gt; 0)
          {
              if(LoadFromBuffer(pBuff, nSize))
              {
                  bResult = E_IMAGEFILE_LOADED;
              }
              else
              {
                  bResult = E_IMAGEFILE_NOMEMORYTOLOAD;
              }
          }
          else
          {
  
              bResult = E_IMAGEFILE_MISSING;
          }
          cFile.Close();
          delete [] pBuff;
      }
      return bResult;
  }
  </code></pre>
  
  <p>Image scaling code </p>
  
  <pre class="lang-cpp prettyprint-override"><code>CPicture* CPicture::GetScaledClone(double fRatioX, double fRatioY)
      if(m_pXImage)
      {
          CPicture* pPic = new CPicture();
          pPic-&gt;m_nTotalParts = m_nTotalParts;
          pPic-&gt;m_pXImage = new CxImage(*m_pXImage);
  
          CSize size = GetSize();
          long lX = static_cast&lt;LONG&gt;(size.cx*fRatioX);
          long lY = static_cast&lt;LONG&gt;(size.cy*fRatioY);
          if(m_nTotalParts &gt; 1)
          {
              int nX = lX % m_nTotalParts;
              int nY = nX * lY/lX;
              lX -= nX;
              lY -= nY;
          }
  
          pPic-&gt;m_pXImage-&gt;Resample(lX, lY, 0);
          return pPic;
      }
  </code></pre>