Solved

EMF Rotation, reversing, fliping?

Posted on 1998-05-28
2
389 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now