[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

Problem converting OLE Metafile to Bitmap

bphillips

12/9/2004 12:40:00 AM

I'm having issues converting a metafile into a bitmap. The metafile is
the presentation data stripped from an OLE object. The OLE headers
have been stripped off and what appears to be the MetafilePict header
has also been stripped off.

The metafilepict header, though, contains all of the sizing information
(which I need) in order to keep the resultant bitmap the same size as
the original presentation metafile.

When I try to force the metafile into the given size, the resultant
bitmap always looks as if the text within it has been scaled down (and
so the bitmap text looks nothing like the original presentation of the
OLE object.) This only seems to affect the text. More complex objects
(with graphs, etc), seem to translate OK.

I've tried numerous different methods for converting the files , none
of which seem to work. From basic ideas like:

Image i = Image.FromStream(fs);
Bitmap b = new Bitmap(i, new Size(pictInfo.xExt, pictInfo.yExt));
// gives correct size, but text is sized incorrectly

To more complex ones using hardware device contexts, sizing rectangles
for the metafile, etc. Nothing seems to make the text size come out
right (or in the case of the hardware device context -- not at all.
I'm sure I've got issues there.)

Is there an easier way to:

1) maintain the correct text size in the metafile to bitmap conversion?
2) dump the metafile to some other graphic?
-or- the point of this entire exercise
3) dump the presentation data of an OLE object (as it appears in the
application) to a file that can be viewed (jpeg, bitmap, tiff)?
Any ideas/code hints would be greatly appreciated.

B Phillips