在 C# 中使用外部应用程序打开 Image 对象

发布于 2024-12-29 00:40:12 字数 663 浏览 3 评论 0原文

这是我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黑寡妇 2025-01-05 00:40:12

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文