Csharp/C#教程:将System.Drawing.Bitmap转换为stdole.StdPicture分享


将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 https://netoffice.codeplex.com Office Addin示例

 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); } } 

如果你在谷歌搜索[转换.net图像到ole图片],你会发现很多关于其他方式的讨论(即将图片转换为图片),以及许多建议,效果,“不要尝试在.NET中使用ole图片”。 我同意。 几年前我走了那条路,并决定我真的不需要那么糟糕的OLE画面。

我强烈建议您重新评估您对OLE图片对象的需求。 如果要将图像保存在数据库中,请将它们存储为BLOB而不是图片对象。 如果你绝对必须使用OLE图片对象,那么祝你好运。 这将非常令人沮丧。

上述就是C#学习教程:将System.Drawing.Bitmap转换为stdole.StdPicture分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/998142.html

(0)
上一篇 2021年12月26日
下一篇 2021年12月26日

精彩推荐