Extract images from Windows EMF during EnumEnhMetaFile parse?

Unanswered Extract images from Windows EMF during EnumEnhMetaFile parse?

  • Friday, April 13, 2012 9:45 PM
     
     

    A program I am modifying converts EMF files to a different format (SVG). It does this with EnumEnhMetaFile() which calls the program's parsing routine for each record of the EMF. That works great for the vector stuff.   However, it also needs to be able to pull out a bitmap when it hits an EMR_STRETCHDIBITS.   (The final target is actually a base64 encoded PNG, but the sticking point is grabbing the Bitmap.)    Does Microsoft provide a function somewhere for pulling out an image at this point? The inverse operation, adding a bitmap to the EMF, is abitmap.Draw, what I need is some sort of abitmap.Read that can operate from within the EnumEnhMetaFile data processing.

    Note, I did find CreateDIBitmap which brings up another issue - that makes a Bitmap handle, and while Bitmaps have a Save method that may be used with an encoder (so as to write the PNG to a file or memory, as an intermediate step) the Bitmap handle seems not to support this.

    I do not want to render the EMF into a bitmap, I want the original bitmap that is stored in the EMF.   (It is possible that the resolution of the bitmap in the EMF is greater than that of the desktop.)  The method used must work on Windows XP and up, but need not work on anything earlier than that.


    Thank you.



    • Edited by mathog Friday, April 13, 2012 9:47 PM
    • Edited by mathog Friday, April 13, 2012 9:47 PM
    •  

All Replies