Пример #1
0
        public static int GetMaxHeaderSize(this IImagingConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var provider = config.GetModule <ImagingInstanceProvider <IImageFormatDetector> >();

            return(provider.GetMaxHeaderSize());
        }
Пример #2
0
        public static IEnumerable <IImageFormatDetector> GetFormatDetectors(this IImagingConfig config)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var provider = config.GetModule <ImagingInstanceProvider <IImageFormatDetector> >();

            return(provider.Values);
        }
Пример #3
0
        public static bool TryGetInfoDetector(
            this IImagingConfig config,
            ImageFormat format,
            [MaybeNullWhen(false)] out IImageInfoDetector infoDetector)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            var provider = config.GetModule <ImagingInstanceProvider <IImageInfoDetector> >();

            return(provider.TryGetValue(format, out infoDetector));
        }
Пример #4
0
        public static bool TryCreateDecoder(
            this IImagingConfig config,
            Stream stream,
            ImageFormat format,
            DecoderOptions?decoderOptions,
            [MaybeNullWhen(false)] out IImageDecoder decoder)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var provider = config.GetModule <ImageCoderProvider <IImageDecoder> >();
            var factory  = provider.GetFactory(format);

            decoder = factory.Invoke(stream, decoderOptions) ?? throw new ImagingException("Coder factory returned null.");
            return(true);
        }