title: Get Emf image size ratio (Win32, C/C++)
body: <p>i want to convert .emf vector image file to .bmp using the win32 api and C/C++.</p>
  
  <p>It works with a square image. But I do not know how to get the ratio of the size of the .emf image when it is rectangular.</p>
  
  <p>The ENHMETAHEADER structure filled with the GetEnhMetaFileHeader () function does not seem to contain the correct information.
  rclBounds and rclFrame of the ENHMETAHEADER structure give equivalent widths and heights while my .emf image is clearly rectangular (the height should be almost twice the width with my test image).</p>
  
  <p>How can I get this ratio? how software like irfanview managed to do it?</p>
  
  <p>Here is the code i use to get the image width et height:</p>
  
  <pre><code>BOOL CConvertEMFToBMP::ConvertToBMP(const char* strFileName, const char* strBMPFile, int w, int h, int div, int indexX, int indexY)
  {
      HENHMETAFILE    hemf;
      HBITMAP         bitmap;
      HDC             memDC;
      ENHMETAHEADER   emh;
  
      HDC dc = ::GetDC(NULL);
  
      hemf = ::GetEnhMetaFileA(strFileName);
  
      ZeroMemory(&amp;emh, sizeof(ENHMETAHEADER));
      emh.nSize = sizeof(ENHMETAHEADER);
      if (GetEnhMetaFileHeader(hemf, sizeof(ENHMETAHEADER), &amp;emh) == 0)
      {
          DeleteEnhMetaFile(hemf);
          printf("Error: Can't get EnhMetaFileHeader\n");
          return FALSE;
      }
  
      long frameWidth  = emh.rclFrame.right  - emh.rclFrame.left;
      long frameHeight = emh.rclFrame.bottom - emh.rclFrame.top;
  
      RECT rect;
      long width = emh.rclBounds.right - emh.rclBounds.left;
      long height = emh.rclBounds.bottom - emh.rclBounds.top;
  
  ...
  }
  </code></pre>
  
  <p>With my .emf image:
  Under IrfanView:
  Original Size: 38208 x 52340  Pixels (1999.81 MPixels) (1.37)
  Current Size : 19104 x 26170  Pixels (499.95 MPixels) (1.37)</p>
  
  <p>Using my code:
  width  = 165091
  height = 165069</p>
  
  <p>But for some image, it works...
  Exemple with another image:</p>
  
  <p>Under IrfanView:
  Original Size: 9921 x 14030  Pixels (139.19 MPixels) (1.41)
  Current Size : 9921 x 14030  Pixels (139.19 MPixels) (1.41)</p>
  
  <p>Using my code:
  width  = 9920
  height = 14030</p>