/// <summary> /// Creates an <see cref="ImageFile"/> from the specified data stream. /// </summary> /// <param name="stream">A <see cref="Sytem.IO.Stream"/> that contains image data.</param> /// <param name="encoding">The encoding to be used for text metadata when the source encoding is unknown.</param> /// <returns>The <see cref="ImageFile"/> created from the file.</returns> public static ImageFile FromStream(Stream stream, Encoding encoding) { // JPEG if (JPEGDetector.IsOfType(stream)) { return(new JPEGFile(stream, encoding)); } // TIFF if (TIFFDetector.IsOfType(stream)) { return(new TIFFFile(stream, encoding)); } // SVG if (SVGDetector.IsOfType(stream)) { return(new SVGFile(stream)); } throw new NotValidImageFileException(); }
/// <summary> /// Creates an <see cref="ImageFile"/> from the specified data stream. /// </summary> /// <param name="stream">A <see cref="Sytem.IO.Stream"/> that contains image data.</param> /// <param name="encoding">The encoding to be used for text metadata when the source encoding is unknown.</param> /// <returns>The <see cref="ImageFile"/> created from the file.</returns> public static ImageFile FromStream(Stream stream, Encoding encoding) { // JPEG if (JPEGDetector.IsOfType(stream)) { return(new JPEGFile(stream, encoding)); } // TIFF if (TIFFDetector.IsOfType(stream)) { return(new TIFFFile(stream, encoding)); } // SVG if (SVGDetector.IsOfType(stream)) { return(new SVGFile(stream)); } // We don't know return(null); }