I'm trying to make my C# code add an image to my (WPF) application's canvas. However, my code does not work.
Image I = new Image();
I.Source = System.IO.File.Open(@"C:\Users\Public\Pictures\Sample Pictures\Penguins.jpg", System.IO.FileMode.Open);
I get the error:
Cannot implicitly convert type 'System.IO.FileStream' to 'System.Windows.Media.ImageSource'
I see why this is: The Image object wants the raw bitmap (or jpg or whatever), and my code is giving it an output stream from the file. How do I convert between the two?