views:

177

answers:

1

I am using below function to make a image of current form and set it in clipboard

Image bit = new Bitmap(this.Width, this.Height);
Graphics gs = Graphics.FromImage(bit);
gs.CopyFromScreen(this.Location, new Point(0, 0), bit.Size);
Guid guid = System.Guid.NewGuid();
string FileName = guid.ToString();
//Copy that image in the clipbaord.
Image imgToCopy = Image.FromFile(Path.Combine(Environment.CurrentDirectory, 
    FileName + ".jpg"));
Clipboard.SetImage(imgToCopy);

Now my image is in clipboard and i am able to show it in picturebox on other form using below code :

mypicturebox.Image = Clipboard.GetImage();

Now the the problem is that i want to show it in default imageviewer of that system. so for that i think using "System.Diagnostics.Process.Start" we can do that.. but i dont know, how to find default imageviewer and how to set clipboard's image in that ... please help me out... if i find solution than thats good otherwise i am thinking to save that file from clipboard to harddisk and then view it in window's default imageviewer... please help me to resolve my problem.. i am using c#.net

+3  A: 

Your best approach is to save the Image to disk somewhere, and then run that file with Process.Start. This will result in the file's being opened by the default viewer application, as you desire.

It is possible to find out what program is set as the default viewer, and then start that program directly (instead of starting the file), but you then have the problem of communicating with that running application and passing your image to it somehow. This probably isn't possible with many viewer applications (and remember that there are thousands of possible viewer applications that could be set as the default), because normally you only communicate with a viewer app via its command-line arguments.

The only sound, reliable way to do this is to save the image to disk and then shell-start it with Process.Start.

MusiGenesis
thanks a lot for your valuable solution...
Rajesh Rolen- DotNet Developer