How to save WMF to BMP without PictureBox Control

How to save WMF to BMP without PictureBox Control

Post by Tim Leine » Thu, 30 Jan 2003 03:21:12



Hi guys,

I have a little problem with converting a WMF to a BMP in
one step. Now I do like this:

Dim pic_Picture As Picture
Set pic_Picture = Clipboard.GetData(vbCFMetafile)
Call SavePicture(pic_Picture, str_TempFilename)
frmMain.picPictureBox.Picture = LoadPicture
  (str_TempFilename)
Call SavePicture(frmMain.picPictureBox.Image,  
  str_TempFilename)

But I cant use this way over the PictureBox, cause its
gonna be an DLL without Forms & Co. I heard something
about copying the WMF to MemoryDC and then saving from
their. May someone give me a hint on that?

Thanks
Tim

 
 
 

How to save WMF to BMP without PictureBox Control

Post by Mike D Sutto » Thu, 30 Jan 2003 05:37:55


Quote:> I have a little problem with converting a WMF to a BMP in
> one step. Now I do like this:
<snip>
> But I cant use this way over the PictureBox, cause its
> gonna be an DLL without Forms & Co. I heard something
> about copying the WMF to MemoryDC and then saving from
> their. May someone give me a hint on that?

Yep, you'll need to create a memory DC then create a memory Bitmap the size
of the MetaFile and select it into the DC.  Draw the MetaFile to the DC with
the PlayMetaFile() API call then grab the Bitmap data and write it and some
basic header information out to a file.
Have a look at the DC tutorial on my page for information on how to create
the memory DC, then the DIB tutorial for the Bitmap side of things,
including how to save it out to disk (Actually, the DIB class written
throughout the tutorial would suit your needs pretty much exactly and allow
you accomplish your task in just a few lines.)
Hope this helps,

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/



 
 
 

How to save WMF to BMP without PictureBox Control

Post by Tim Leine » Thu, 30 Jan 2003 05:54:31


Thanks allot. Very nice page. Have looked over the DIB and
DC Tutorials and will study them tommorrow. Very nice
explained.
Thx
Tim
 
 
 

How to save WMF to BMP without PictureBox Control

Post by Mike D Sutto » Thu, 30 Jan 2003 06:10:31


Quote:> Thanks allot. Very nice page. Have looked over the DIB and
> DC Tutorials and will study them tommorrow. Very nice
> explained.

You're welcome, let me know if you find any problems after having gone
through them.

    Mike

 -- EDais --

 - Microsoft Visual Basic MVP -
WWW: Http://EDais.earlsoft.co.uk/


 
 
 

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. Help on Installing OpenGL

3. save a graphic in PictureBox to a wmf file

4. New Copyright question

5. Print/save entire PictureBox w/ child controls

6. SVGA FLIC posted

7. Saving a monochrome bmp from PictureBox

8. plane to sphere?

9. Saving the picture (in PictureBox) to BMP

10. Save picturebox as BMP and BitBld ??

11. Picturebox won't save BMP in 256 colours

12. How save metafile(.WMF) to bitmap file(.BMP)?

13. How to save a wmf as a bmp