Converting Drawing to WMF format

Converting Drawing to WMF format

Post by F. Carlse » Wed, 18 Mar 1998 04:00:00



I have created an activex control that draws lines, etc. in a picture box.
However, I'd like to be able to save this in a file with WMF format.  I
realize that this may mean I'll have to rewrite the drawing procedures, but
has anyone done something like this? And do any of you know an easy way to
create wmf files?

Thanks

/Frode Carlsen

 
 
 

Converting Drawing to WMF format

Post by Jim Deutc » Thu, 19 Mar 1998 04:00:00


Drawing a metafile is not really "easy", but the basic steps include:

For the APIs:
First, define the area on which you are going to send drawing
instructions:
myHDC = CreateMetafile(0&) 'Create metafile in memory
ret = SetMapMode(myHDC, MM_ANISOTROPIC)
ret = SetWindowOrgEx(myHDC, 0, 0, myPoint)
ret = SetWindowExtEx(myHDC, nHeight, nWidth, mySize)
ret = SetViewportOrgEx(myHDC, 0, 0, myPoint)
ret = SetViewportExtEx(myHDC, nHeight, nWidth, mySize)

Then send some drawing instructions :
ret = MoveToEx(myHDC, x0, y0, myPoint)
ret = LineTo(myHDC, x1, y1)
ret = TextOut(myHDC, x0, y1, theText, Len(theText))
....

Then "transfer" the records of the device context to the metafile
on disk, if you like:
myHMF = CloseMetaFile(myHDC)
ret = CopyMetaFile(myHMF, tmpFileWMF)
or you can play the content of the metafile to any other device context
such as a printer, the picture box, ...
ret = PlayMetaFile(Printer.hdc, myHMF)

Jim Deutch
MS Dev MVP



> I have created an activex control that draws lines, etc. in a picture
box.
> However, I'd like to be able to save this in a file with WMF format.  I
> realize that this may mean I'll have to rewrite the drawing procedures,
but
> has anyone done something like this? And do any of you know an easy way
to
> create wmf files?

> Thanks

> /Frode Carlsen



 
 
 

Converting Drawing to WMF format

Post by F. Carlse » Fri, 20 Mar 1998 04:00:00


Thanks!  You saved my day.

Frode Carlsen

 
 
 

1. Saving API Drawings to a BMP or Converting from WMF to BMP

Hi,

Does anyone know how to easily convert a Metafile to a Bitmap using VB.

Actually, it is not necessarily from a Metafile since I have a Handle on
a Picture control on which I send some Graphical API functions (LineTo,
MoveTo, etc ...).I use then deviceContext to create the Metafile.

Thanks for the suggestions. Selim

2. Animating a series of stills

3. converting to WMF format: how?

4. How do I bring two images to use the same palette

5. Help converting WMF to other vector formats

6. Best for glut is Visual Studio 6 or .net studio??

7. Scriptable app to convert WMF to Mac formats????

8. Windows meta file format (.wmf): how to convert it

9. How to convert Placeable WMF to Standard WMF?

10. WMF file format & WMF readers

11. Converting Claris Draw to a Windows format