I am working on an Add in To Excel performing some operations on OLE object. It requires getting some data from OLE object embedded programmatically in worksheet (conversion from math type to TeX language). So far I've dealt with most of the issues like adding it to excel worksheet, getting the equation from Math Type OLE object and setting the equation. But there's the last thing to do.
I need to extract the metafile with image of the equation set by math type OLE object. I want to extract the image and save it as a memory bitmap and then display it in some kind of control. The issue is - I have the code to get the Metafile from OLE object:
oleDataObject.GetData(ref formatEtc,out stgMedium);
//get data returns proper data
//what to do now?
ptr = stgMedium.unionmember;
HandleRef handleRef = new HandleRef(null, ptr);
IntPtr ptrToHandle = GlobalLock(handleRef);
int Length = GlobalSize(handleRef);
I have no idea if I'm doing the right thing to get the metafile, and the most imprtant (assuming that ist ok getting the metafile this way): how to manage the metafile to save the image data as bitmap in add-in's memory.