我目前有一个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.Compatiability.*类过时,仅在32位进程中支持. http://go.microsoft.com/fwlink/?linkid=160862
那么用什么代替呢?我还没找到另一个解决办法..。
发布于 2011-05-28 16:40:33
摘自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);
}
} 发布于 2011-05-24 15:07:41
如果你在谷歌上搜索将.net图片转换成ole图片,你会发现很多关于向相反方向(即把ole图片转换成图像)的闲聊,还有很多建议,实际上,“不要试图在.NET中使用ole图片”。我同意。几年前,我走上了这条路,决定我并不那么需要OLE的照片。
我强烈建议您重新评估您对OLE图片对象的需求。如果要将图像保存在数据库中,请将它们存储为BLOB而不是图片对象。如果您一定要使用OLE图片对象,那么祝您好运。会很令人沮丧的。
https://stackoverflow.com/questions/6110337
复制相似问题