Convert System.Drawing.Bitmap to stdole.StdPicture

前端 未结 2 1842
礼貌的吻别
礼貌的吻别 2021-01-12 18:57

I have a System.Drawing.Bitmap currently and I need to convert it into an stdole.StdPicture.
Currently I\'m using:

var pic = (stdole.StdPicture)Microsof         


        
相关标签:
2条回答
  • 2021-01-12 19:28

    taken from NetOffice http://netoffice.codeplex.com Office Addin Example

    public class IconConverter : System.Windows.Forms.AxHost
    {
       private IconConverter(): base(string.Empty)
       {
       }
    
       public static stdole.IPictureDisp GetIPictureDispFromImage(System.Drawing.Image image)
       {
    
          return (stdole.IPictureDisp)GetIPictureDispFromPicture(image);
       }
    } 
    
    0 讨论(0)
  • 2021-01-12 19:32

    If you do a Google search for [convert .net image to ole picture], you'll find a whole lot of chatter about going the other way (i.e. converting an ole picture to image), and a lot of advice that says, in effect, "don't try to use ole pictures in .NET". I concur. I went down that path a few years ago and decided that I didn't really need the OLE picture that badly.

    I strongly recommend that you re-evaluate your need for OLE picture objects. If you're saving images in a database, store them as BLOBs rather than as picture objects. If you absolutely have to use OLE picture objects, then good luck. It's going to be very frustrating.

    0 讨论(0)
提交回复
热议问题