在 C# 中使用外部应用程序打开 Image 对象
这是我在 Stack Overflow 上的第一篇文章,所以请耐心等待。这是我的问题。我正在从数据库中以字节数组的形式加载图像,并将其存储为名为 myImage 的图像对象。 这很好,我知道 myImage 已正确加载,因为当我将其保存到磁盘时,我可以毫无问题地打开它。但是,在我的应用程序中,我不需要保存它,而是 将其发送到外部应用程序(例如 Windows Image Viewer)进行显示。这是我到目前为止所拥有的片段:
using System.Diagnostics;
using System.Drawing;
// Image that is loaded from the database
Image myImage;
// Fiew is my external image viewing program
Process fiew = new Process();
fiew.StartInfo.FileName = @"C:\Fiew.exe";
fiew.StartInfo.Arguments = @"C:\cube.tif";
fiew.Start();
当然,我可以将 myImage 保存到临时目录并将其作为启动信息参数传递。这可行,但这对我来说不是一个选择。 因此,如何用 myImage 替换启动信息参数,以便将其传递给 Fiew.exe 而不是磁盘上的图像?这可能吗?感谢您的时间和帮助。非常感谢。
This is my first post on Stack Overflow so bear with me. Here's my problem. I am loading an image as a byte array from database and storing it as an Image object called myImage.
This is fine and I know myImage is being loaded correctly because when I save it to disk I can open it without problems. However, in my application I do not need to save it, but rather
send it to an external application (such as Windows Image Viewer) to be displayed. This is a snippet of what I have so far:
using System.Diagnostics;
using System.Drawing;
// Image that is loaded from the database
Image myImage;
// Fiew is my external image viewing program
Process fiew = new Process();
fiew.StartInfo.FileName = @"C:\Fiew.exe";
fiew.StartInfo.Arguments = @"C:\cube.tif";
fiew.Start();
I could, of course, save myImage to a temporary directory and pass it in as start info arguments. That works, but it is not an option for me.
Hence how can I substitute myImage for start info arguments so that it is passed to Fiew.exe instead of the image on disk? Is this even possible? Thank you for your time and help. It is greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
StartInfo.Arguments
是一个字符串数组,而不是二进制数据。此外,这还取决于可执行文件将接受什么作为启动参数。有可能,它正在寻找磁盘上某个位置的图像路径。
The
StartInfo.Arguments
is an array of strings, not binary data.Also, it depends on what the executable will accept as start-up parameters. Chances are, it is looking for a path to an image on the disk somewhere.