Solved

Metafile converter

Posted on 2002-05-28
3
702 Views
Last Modified: 2013-11-20
Is it possible to convert from .wmf to emf (Enhanced metafile) ?

Is there a simple function to do the job ?
0
Comment
Question by:win32
  • 2
3 Comments
 
LVL 30

Expert Comment

by:Zoppo
ID: 7039189
Hi win32,

this is from MSDN:

------------------------
To convert a Windows-format metafile to an enhanced-format metafile, call the GetMetaFileBitsEx function to retrieve the data from the Windows-format metafile and then call the SetWinMetaFileBits function to convert this data into an enhanced-format metafile.
------------------------

hope this helps,

ZOPPO
0
 

Author Comment

by:win32
ID: 7041497
Yes I know.. but, can't you give me a sample. I am completly lost right now..

This is what I have:
pDC and a wmf file..

I do this:
HMETAFILE hwmf = GetMetaFile(sPath);

// Now I have the hwmf, and need to convert it to emf
HENHMETAFILE = HENHMETAFILE SetWinMetaFileBits(
  UINT cbBuffer,              // size of buffer
  CONST BYTE *lpbBuffer,      // metafile data buffer
  HDC hdcRef,                 // handle to reference DC
  CONST METAFILEPICT *lpmfp   // size of metafile picture
);


And yes.. I have no idea where to get the parameters ??
0
 
LVL 30

Accepted Solution

by:
Zoppo earned 70 total points
ID: 7041532
well, I guess at first you might need to call
GetMetaFileBitsEx like:

UINT iBufSize = GetMetaFileBitsEx(
   hwmf,
   0,
   NULL
);

if ( 0 == iBufSize )
{
   TRACE( "Error (%d) occured\n", GetLastError() );
   return;
}

BYTE pBytes = new BYTE [iBufSize];

GetMetaFileBitsEx(
   hwmf,
   iBufSize,
   (void*)pBytes
);

HENHMETAFILE hNewEmf = SetWinMetaFileBits(
   iBufSize,
   pBytes,
   hDC, // handle to your DC
   NULL // or pointer to a METAFILEPICT structur you filled
)

if ( NULL == hNewEmf )
{
   TRACE( "Error (%d) occured\n", GetLastError() );
   return;
}

ZOPPO
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 47
Question regarding Copy/Paste 16 87
mapBully challenge 6 89
wordappend challenge 8 85
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

21 Experts available now in Live!

Get 1:1 Help Now