gpt4 book ai didi

c# - 将 System.Drawing.Bitmap 转换为 stdole.StdPicture

转载 作者:太空狗 更新时间:2023-10-29 21:30:13 26 4
gpt4 key购买 nike

我目前有一个 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

但我收到编译器警告:

Warning 'Microsoft.VisualBasic.Compatibility.VB6.Support.ImageToIPicture(System.Drawing.Image)' is obsolete: '"Microsoft.VisualBasic.Compatibility.* classes are obsolete and supported within 32 bit processes only. 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);
}
}

关于c# - 将 System.Drawing.Bitmap 转换为 stdole.StdPicture,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6110337/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com