在Windows照片查看器C#中从picturebox打开图像 [英] Open image from picturebox in windows photo viewer C#

查看:322
本文介绍了在Windows照片查看器C#中从picturebox打开图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I find thisd solution

I have picture saved in database and retrieved from database in picturebox...that working fine.

I need to show that picture in picture and fax viuwer

Error is : The system cant find file specified

 

Some help?





我尝试过:





What I have tried:

private void button12_Click(object sender, EventArgs e)
        {
            Process photoViewer = new Process();
            photoViewer.StartInfo.FileName = @"c:\\testImage.jpg";
            photoViewer.StartInfo.Arguments = @"c:\\testImage.jpg";
            photoViewer.Start();


        }

推荐答案

基于众多回复,我开始怀疑你不是关于你希望实现的目标非常明确。我会尽力猜测。也就是说,如果您只是在问题中提供更多细节,那会更容易。



要查看带有图像查看器的文件,您需要实际拥有一个文件。该文件应该在磁盘上,而不是在内存中。因为您在问题中指定了C:\ testImage.jpg,我自然会认为您之前已将图像保存到磁盘。您的后续回复似乎表明情况可能并非如此。



因此,如果图像尚未在磁盘上,您的第一步是将其保存到磁盘。你没有提到什么类型的应用程序(WinForm,WPF,WebForm等)。



出于猜测的目的,我将为WinForm解释。将JPEG图像从WinForm图片框保存到磁盘的方法如下:

Based on numerous replies, I begin to suspect you are not being very clear about what you hope to accomplish. I'll do my best to guess. That said, it would be easier, if you simply provided more detail in the question.

To view a file with an image viewer, you need to actually have a file. The file should be on-disk, not in memory. Because you specified "C:\testImage.jpg" in your question, I naturally assumed that you had already previously saved your image to disk. Your later responses, seem to indicate this may not be the case.

So, your first step, if the image is not already on disk, is to save it to disk. You don't mention what type of application (WinForm, WPF, WebForm, etc.).

For the purposes of this guess, I'll explain for WinForm. The way to save an JPEG image, from a WinForm picture box, to disk would be as follows:
string myPictures = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
string myPath = System.IO.Path.Combine(myPictures, "testImage.jpg");

pictureBox1.Image.Save(myPath, System.Drawing.Imaging.ImageFormat.Jpeg);



要显示该图像,请使用一些图像查看器...


To display that image, using some image viewer...

// Use default image viewer
System.Diagnostics.Process.Start(myPath);

// Use image viewer application indicated by the variable "myImageViewer"
System.Diagnostics.Process.Start(myImageViewer, myPath);


这篇关于在Windows照片查看器C#中从picturebox打开图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆