public static MemoryStreamImageProxy FromStream(Stream istr, string name) { MemoryStreamImageProxy img = new MemoryStreamImageProxy(); img._url = name; img._name = name; img.CopyFromStream(istr); return(img); }
/// <summary> /// Creates a <see cref="MemoryStreamImageProxy"/> from a stream. A file name must be provided in order /// to deduce the kind of stream (.png for .png stream, .jpg for jpg stream and so on). /// </summary> /// <param name="istr">The image stream to copy from.</param> /// <param name="name">The name. The kind of image is deduced from the extension of this name.</param> /// <returns>A memory stream image proxy holding the image.</returns> /// <exception cref="ArgumentNullException"> /// istr /// or /// name - Name must be provided in order to deduce the file extension /// </exception> public static new MemoryStreamImageProxy FromStream(Stream istr, string name) { if (istr == null) { throw new ArgumentNullException(nameof(istr)); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name), "Name must be provided in order to deduce the file extension"); } var img = new MemoryStreamImageProxy { _url = name, _name = name, _extension = System.IO.Path.GetExtension(name) }; img.CopyFromStream(istr); return(img); }
public static MemoryStreamImageProxy FromStream(Stream istr, string name) { MemoryStreamImageProxy img = new MemoryStreamImageProxy(); img._url = name; img._name = name; img.CopyFromStream(istr); return img; }