EMF Rotation, reversing, fliping?

Posted on 1998-05-28
Last Modified: 2011-09-20
How can I EMF(Enhanced Meta File) image rotate?
and how can I reverse or flip the EMF images?
Question by:kjinihl

Accepted Solution

AlFa earned 50 total points
ID: 1164883
try this (you can change mapping, org etc...)
void DoMetaFile(CDC *pDC, CRect &Rt, const char *lpFileName)
      ALDUSMFHEADER aldusMFHeader; //header of placable metafile
      METAHEADER mfHeader;
    HGLOBAL hMF, hMem;

      HFILE fh = _lopen(lpFileName, OF_READ);
      int iDcSav=pDC->SaveDC();
      _llseek(fh, 0, 0);

      /* read the placeable header */
      _lread(fh, (LPSTR)&aldusMFHeader, sizeof(ALDUSMFHEADER));
      /* return to read metafile header */
      _llseek(fh, sizeof(aldusMFHeader), 0);
      /* read the metafile header */
      _lread(fh, (LPSTR)&mfHeader, sizeof(METAHEADER));

      LPSTR lpMem;
      if (!(hMem = GlobalAlloc(GHND, (mfHeader.mtSize * 2L))))
      if (!(lpMem = (LPSTR) GlobalLock(hMem)))
//            MessageBox(hWndMain, "Unable to lock memory for metafile bits",              NULL, MB_OK | MB_ICONHAND);
      /* seek to the metafile bits */
      _llseek(fh, sizeof(aldusMFHeader), 0);
      /* read metafile bits */
      WORD wBytesRead = _hread(fh, lpMem, (DWORD)mfHeader.mtSize * (DWORD)2);
      /* if there was an error */
      if( wBytesRead == -1 )
//            MessageBox(hWndMain, "Unable to read metafile bits", NULL, MB_OK | MB_ICONHAND);

// Essai de coordonées dans un ordre désordonné
//       CRect R(aldusMFHeader.bbox.left, aldusMFHeader.bbox.bottom, aldusMFHeader.bbox.right,;
    CRect R(aldusMFHeader.bbox);
    CRect RT(Rt.left,, Rt.right, Rt.bottom);

//      SetWindowScaleRect(pDC, RT, R, -1);
      pDC->SetViewportOrg(RT.left, RT.bottom);

  /* set the windows origin to correspond to the bounding box origin
      contained in the placeable header */
/*       long lWR=abs(R.left) + abs(R.right),
      lHR=abs( + abs(R.bottom),
            SetWindowScaleRect(pDC, R, Rt);
            long       lWR=(long)R.left -(long)R.right, //Largeur du rectangle
                        lHR=(long) - (long)R.bottom,//Hauteur du rectangle
                        lWT=(long)RT.right - (long)RT.left,//Largeur de traçage
                        lHT=(long) - (long)RT.bottom;//Hauteur de traçage
            pDC->SetWindowOrg(R.left, R.bottom);
            /* set the window extents based on the abs value of the bbox coords */
            pDC->SetWindowExt((int)lWR, (int)lHR);
            pDC->SetViewportExt((int)lWT, (int)lHT);
      if (0!=(hMF = SetMetaFileBits(hMem)))
            extern char cIsPreView;
            if (cIsPreView)
                  ::EnumMetaFile(pDC->GetSafeHdc(), (HMETAFILE)hMF, EnumMFProc, (LPARAM)(LPSTR)pDC);
                  BOOL bof = pDC->PlayMetaFile((HMETAFILE) hMF);




Author Comment

ID: 1164884
I Can't Realize Rotate with 90, 270 degree.
How Can I do this 90, 270 degree rotation of EMF ?
Please Immediately Reply to me.......

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question