Ejemplo n.º 1
0
        public static IImage Decode(this IImageCodec imageCodec, string filePath)
        {
            if (!imageCodec.IsSupportedFileFormat(filePath))
            {
                throw new FileFormatException(IO.Properties.ExceptionMessages.UnsupportedFileFormat);
            }

            using (FileStream fs = File.OpenRead(filePath))
                return(imageCodec.Decode(fs));
        }
Ejemplo n.º 2
0
        public static IImage FromFile(string filePath)
        {
            IImageCodec imageCodec = ImageCodec.FromFileExtension(filePath);

            if (imageCodec is null)
            {
                throw new UnsupportedFileFormatException();
            }

            return(imageCodec.Decode(filePath));
        }
Ejemplo n.º 3
0
        public IImage FromStream(Stream stream, IFileFormat imageFormat = null)
        {
            if (imageFormat is null)
            {
                stream = FileFormatFactory.Default.FromStream(stream, out imageFormat);
            }

            IImageCodec imageCodec = imageCodecFactory.FromFileFormat(imageFormat);

            if (imageCodec is null)
            {
                throw new FileFormatException(IO.Properties.ExceptionMessages.UnsupportedFileFormat);
            }

            return(imageCodec.Decode(stream));
        }