We help IT Professionals succeed at work.

Converting EMF to Bitmap

djsansui
djsansui asked
on
Medium Priority
515 Views
Last Modified: 2010-08-05
I need to enable drag and drop of pictures from Excel into my VB6 form.  When you drag an image out of Excel, it has no bitmap in it's data object, just a metafile and enhanced metafile.

I need to extract the bitmap from the metafile so I can save it as a jpeg.

The solutions I've found so far either save it as a metafile with a .bmp extension, or screw up the color depth.  The hack I'm using right now is to open it in MS Paint and re-save the file as a bitmap, but I need a way to do this within code (without opening extra windows, etc).  If I use PlayEnhMetaFile into any kind of IPicture or StdPicture, it remains as a metafile.

How can I extract/convert the EMF to a Bitmap?
Comment
Watch Question

Ark
CERTIFIED EXPERT

Commented:
Picture1.AutoSize=True
Picture1.AutoRedraw=True
Picture1.Picture = LoadPicture("c:\test.emf")
SavePicture Picture1.Image, "c:\test.bmp"

Commented:
try this you may have an idea here ...
http://vbaccelerator.com/codelib/gfx/vbjpeg.htm

Author

Commented:
Ark,

Thanks, that almost works... it does save the image as a proper bitmap file, but for whatever reason, the picbox control stretches the image a bit and messes up the colors.

Any ideas?
CERTIFIED EXPERT
Commented:
Try PlayEnhMetaFile into Picture1.hDc and then SavePicture Picture1.Image, "c:\test.bmp"

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.