Solved

EMF Rotation, reversing, fliping?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Focus not getting shifted out of  editbox 2 66
Issues with C++ Class 19 101
designing in object programming 12 94
Adding items to a C# list incrementally 5 33
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

829 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