将System.Drawing.Bitmap转换为stdole.StdPicture

|| 我目前有一个System.Drawing.Bitmap,我需要将其转换为stdole.StdPicture。 目前,我正在使用:
var pic = (stdole.StdPicture)Microsoft.VisualBasic.Compatibility.VB6.Support.ImageToIPicture
                   (MyDLL.Properties.Resources.Img); // this is a System.Drawing.Bitmap
但我收到了编译器警告:   警告\'Microsoft.VisualBasic.Compatibility.VB6.Support.ImageToIPicture(System.Drawing.Image)\'已过时:\'\“ Microsoft.VisualBasic.Compatibility。*类已过时,仅在32位进程中受支持。HTTP: //go.microsoft.com/fwlink/?linkid=160862 那该用什么呢?我找不到其他解决方案...     
已邀请:
摘自NetOffice http://netoffice.codeplex.com Office加载项示例
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);
   }
} 
    
如果您用Google搜索[将.net图像转换为ole图片],就会发现很多关于采用其他方法(例如将ole图片转换为图像)的ter不休,以及很多建议,实际上,“请勿尝试在.NET中使用ole图片”。我同意。几年前,我沿着那条路走,并决定我真的并不需要那么严重的OLE图片。 我强烈建议您重新评估对OLE图片对象的需求。如果要将图像保存在数据库中,请将其存储为BLOB而不是图片对象。如果您绝对必须使用OLE图片对象,那么祝您好运。这将非常令人沮丧。     

要回复问题请先登录注册