Solved

Converting EMF to Bitmap

Posted on 2006-10-19
7
382 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?
0
Comment
Question by:djsansui
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 28

Expert Comment

by:Ark
ID: 17770514
Picture1.AutoSize=True
Picture1.AutoRedraw=True
Picture1.Picture = LoadPicture("c:\test.emf")
SavePicture Picture1.Image, "c:\test.bmp"
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17771078
try this you may have an idea here ...
http://vbaccelerator.com/codelib/gfx/vbjpeg.htm
0
 
LVL 2

Author Comment

by:djsansui
ID: 17775353
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?
0
 
LVL 28

Accepted Solution

by:
Ark earned 500 total points
ID: 17777936
Try PlayEnhMetaFile into Picture1.hDc and then SavePicture Picture1.Image, "c:\test.bmp"
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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