Solved

Metafile converter

Posted on 2002-05-28
3
726 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 31

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 31

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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
Host to IP 7 80
difference between String.subString() and String.subSequence() 6 237
VBA "SendKeys" Syntax for Multiple Keystrokes 7 117
Path of Workbook 3 86
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

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