From a COM library (Microsoft Office Document Imaging aka MODI) I receive an image as an IPictureDisp which I would like to convert to a System.Drawing.Image object.
Wh
Function GetImage(MyIPicture As stdole.IPictureDisp) As Drawing.Image
If CType(MyIPicture.Type, Integer) <> 1 then Throw New ArgumentException("Image not supported")
Return Drawing.Image.FromHbitmap(MyIPicture.Handle, MyIPicture.hPal)
End Function
Inspired from this post in the MSDN Forum.
No idea why the CType(MyIPicture.Type, Integer) = 1
is required, but it works..