将 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
那么该用什么来代替?我找不到其他解决方案然而...
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)Microsoft.VisualBasic.Compatibility.VB6.Support.ImageToIPicture
(MyDLL.Properties.Resources.Img); // this is a System.Drawing.Bitmap
but I get a Compiler Warning:
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
So what to use instead? I couldn't find another solution yet...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
摘自 NetOffice http://netoffice.codeplex.com Office 插件示例
taken from NetOffice http://netoffice.codeplex.com Office Addin Example
如果您在 Google 上搜索 [将 .net 图像转换为 ole 图片],您会发现大量关于采用其他方式(即将 ole 图片转换为图像)的讨论,以及很多建议,其中效果,“不要尝试在.NET 中使用 ole 图片”。我同意。几年前,我沿着这条路走下去,并决定我并不那么需要 OLE 图片。
我强烈建议您重新评估对 OLE 图片对象的需求。如果要将图像保存在数据库中,请将它们存储为 BLOB 而不是图片对象。如果您绝对必须使用 OLE 图片对象,那么祝您好运。这将会非常令人沮丧。
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.