1

I'm trying to edit a image file where instead of path i should be able to provide ImageSource as parameter.

//EditCode:

Process proc = Process.Start(Path);
proc.EnableRaisingEvents = true;
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Verb = "edit";
proc.StartInfo = startInfo;
proc.Exited += new EventHandler((s, e) => myProcess_Exited(s, e, obj.ToString()));

The above code works well when i pass the Path of the image file as the parameter. But now i have only the ImageSource.

//ImageSourceCode:

private BitmapFrame LoadImage(string path)
{
    BitmapDecoder decoder = null;

    if (File.Exists(path) && (path != null))
    {                    
       using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
       {
          decoder = BitmapDecoder.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
       }
       return decoder.Frames.FirstOrDefault();
    }
    else
        return null;
}

The above code gets the path and convert an image as a source(BitmapFrame) and returns it.

Now i need this BitmapFrame to be passed in some function and edit the particular image file in paint and save it.

I neeed somthing like this,

Process proc = Process.Start(`ImageSource`);// Instead of path i need to pass the Image Source.
proc.EnableRaisingEvents = true;
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Verb = "edit";
proc.StartInfo = startInfo;

How can i achieve this?

A Coder
  • 3,039
  • 7
  • 58
  • 129

1 Answers1

0

You can't.

ProcessStartInfo starts a new process that is outside the App Domain of your application. You can't pass it structures in memory within your app domain as a command line parameter.

Mick
  • 6,527
  • 4
  • 52
  • 67
  • Thanks for your comment. Do i have any other method to achieve this functionality? – A Coder Oct 15 '15 at 06:46
  • The only possible solution would be to create an application and pass the structure using WCF inproc or some other protocol. To Edit the image using the registered program in the OS... I don't think so. You could possibly try... http://stackoverflow.com/questions/11179241/open-process-paste-text-within-this-process – Mick Oct 15 '15 at 07:04
  • Is it possible to edit image other than paint? FYI, mine is WPF application. – A Coder Oct 15 '15 at 07:36
  • Your working code is effectively simulating right clicking on the file in Windows Explorer and clicking Edit. If want to invoke your own WPF app to edit the image then you have a lot more options to choose from when it comes to communicating with it from another app. http://stackoverflow.com/questions/13742637/passing-information-between-applications-in-c-sharp – Mick Oct 15 '15 at 08:13