Esempio n. 1
0
        public ImageFilterSequence(IEnumerable <FilterType> filterTypes)
        {
            if (filterTypes == null)
            {
                throw new ArgumentNullException("filterTypes cannot be null");
            }

            _filters = new List <IImageFilter>();

            foreach (var filterType in filterTypes)
            {
                var filter = ImageFilterFactory.Get(filterType);
                _filters.Add(filter);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            try
            {
                const string sourcePicturePath = @"d:\example_image.png";

                const string destinationPicturePath = @"d:\example_image2.png";

                var imageLoader          = ImageLoaderFactory.Get(SourceType.FileSystem);
                var basicImageSerializer = ImageSerializerFactory.Get(SerializerTypes.BasicSerializer);

                var imageFilter = ImageFilterFactory.Get(FilterType.BlackAndWhite);

                var imageSaver = ImageSaverFactory.Get(SourceType.FileSystem);

                Image image;

                using (var stream = imageLoader.Load(sourcePicturePath))
                {
                    image = basicImageSerializer.Serialize(stream);
                }

                imageFilter.Apply(image);

                using (var stream = basicImageSerializer.Deserialize(image))
                {
                    imageSaver.Save(destinationPicturePath, stream);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.WriteLine("Press any key for exit");
            Console.ReadLine();
        }