Solved

Converting EMF to Bitmap

Posted on 2006-10-19
7
358 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 27

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 27

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

776 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