Interesting effect but unwanted. After successfully converting GDI+ handle to WMF bits and saving them to file, I am getting semi-transparency when the file is loaded into a VB6 picture/property. But when displayed in GDI+, no noticeable side effects.
The source image is a GDI+ 32bppARGB bitmap that includes only simple transparency: pixels are either 100% opaque or 100% transparent. It is converted to EMF and then to WMF using this logic. I'll use the GDI+ flat api names, but any .Net solutions would be welcomed as well.
1. Create blank EMF using desktop DC: GdipRecordMetafileStream
2. Get EMF graphics: GdipGetImageGraphicsContext
3. Draw source to EMF: GdipDrawImageRectRect
4. Convert EMF to windows EMF: GdipGetHemfFromMetafile
5. Convert EMF bits to WMF: GdipEmfToWmfBits
6. Write bits to file & clean up
Attached are the source (32bppARGB bitmap) & converted EMF, WMF. Again, loaded via GDI+ all looks good, but loading WMF into VB6, I'm getting unwanted semi-transparency; not so with the EMF. I have also double & triple checked that the source alpha values are either 0 or 255 and nothing between. Saving an image with transparency produces this effect from the logic I described above.
Any ideas how to get rid of the semi-transparency for the WMF? Maybe a different way of getting GDI+ handle with simple transparency to windows WMF format? I have tried both 32bppARGB & 8bpp bitmaps (i.e., like a transparent GIF)
Insomnia is just a byproduct of, "It can't be done"