Solved

Converting EMF to Bitmap

Posted on 2006-10-19
7
368 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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

840 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