Load bitmap from memory in Diagram

Jan 22 at 10:27 AM
Hello,

Is there one way to load a bitmap from memory in the Diagram instead of
Diagram.Background Image = Name Image.FromFile

The goal is show the image taken by a camera.

Thanks in advance
Coordinator
Apr 11 at 8:43 AM
Sorry, I oversaw your post. Seems that notification EMail does not work any longer. :-(
Is there one way to load a bitmap from memory in the Diagram instead of Diagram.Background Image = Name Image.FromFile
You could use Image.FromStream and load the image from a memory stream or any another stream.
Example:
// Get image from a chunk of memory, in this case from a file.
// This could be also done with a fileStream, but this example is about memory streams.
byte[] buffer = File.ReadAllBytes(fileName);
Image img = Image.FromStream(new MemoryStream(buffer), true, true);  // The Image will take the ownership of the memory stream, do not dispose it here!
Diagram.BackgroundImage = new NamedImage(img, "MyImage");