Solved

EMF Rotation, reversing, fliping?

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

Accepted Solution

by:
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))))
      {
            return;
      }
      if (!(lpMem = (LPSTR) GlobalLock(hMem)))
      {
//            MessageBox(hWndMain, "Unable to lock memory for metafile bits",              NULL, MB_OK | MB_ICONHAND);
            (void)GlobalFree(hMem);
            return;
      }
      /* 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);
            (void)GlobalUnlock(hMem);
            (void)GlobalFree(hMem);
            return;
      }

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

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

  /* 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(R.top) + abs(R.bottom),
      lWT=abs(RT.right)+abs(RT.left),
      lHT=abs(RT.top)+abs(RT.bottom);*/
    if(cIsPreView*0)
            SetWindowScaleRect(pDC, R, Rt);
      else
      {
            long       lWR=(long)R.left -(long)R.right, //Largeur du rectangle
                        lHR=(long)R.top - (long)R.bottom,//Hauteur du rectangle
                        lWT=(long)RT.right - (long)RT.left,//Largeur de traçage
                        lHT=(long)RT.top - (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);
            else
                  BOOL bof = pDC->PlayMetaFile((HMETAFILE) hMF);
      }

      (void)GlobalFree(hMem);

      pDC->RestoreDC(iDcSav);
}

0
 

Author Comment

by:kjinihl
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.......
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

740 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