Hi Folks,
I've noticed a few people ask the question, How do I create a XImage from a FileStream? So here is the answer;
You can not create a XImage directly from the FileStream but you can create an XImage from a System.Drawing.Image (GDI+ Image) using the XImage.FromGdiPlusImage(Image) static method.
So, use System.Drawing.Image.FromStream(imageStream) to create your GDI+ Image object, and then use Ximage.FromGdiPlusImage(gdiPlusImage) to create you're XImage.
Example;
Code:
System.IO.Stream imageStream = System.Net.WebRequest.Create(imagePath).GetResponse().GetResponseStream();
System.Drawing.Image systemImage = System.Drawing.Image.FromStream(imageStream);
XImage xImage = XImage.FromGdiPlusImage(systemImage);
Hope this helps someone,
P.