Пример #1
0
        public IColorMap Invoke()
        {
            IColorMap image = raw;
            IColorMap newimage;

            foreach (List <Stage> stagesGroup in stages.Split(s => s.AutoAdjuster != null, LinqExtensions.SplitPlace.Last))
            {
                var last = stagesGroup.Last();
                if (last.AutoAdjuster != null)
                {
                    if (stagesGroup.Count > 1)
                    {
                        newimage = FiltersPipeline.ProcessFilters(image, stagesGroup.Take(stagesGroup.Count - 1).Select(s => s.Filter));
                        image.Dispose();
                        image = newimage;
                    }
                    IColorMap imagetoadjust = image;
                    last.AutoAdjuster.AutoAdjust(last.Filter, imagetoadjust);
                    if (image != imagetoadjust)
                    {
                        imagetoadjust.Dispose();
                    }
                    last.AutoAdjuster = null;

                    newimage = FiltersPipeline.ProcessFilters(image, last.Filter);
                    image.Dispose();
                    image = newimage;
                }
                else
                {
                    newimage = FiltersPipeline.ProcessFilters(image, stagesGroup.Select(s => s.Filter));
                    image.Dispose();
                    image = newimage;
                }
            }
            return(image);
        }
Пример #2
0
        public static IColorMap ProcessFilters(IColorMap map, IEnumerable <IFilter> filters)
        {
            IColorMap currentMap = map;

            foreach (var filter in filters)
            {
                if (filter == null)
                {
                    throw new ArgumentNullException(nameof(filter));
                }

                var newmap = filter.CreateResultMap(currentMap);
                filter.ProcessMap(currentMap, newmap);
                if (newmap != currentMap && currentMap != map)
                {
                    currentMap.Dispose();
                }
                currentMap = newmap;
            }
            return(currentMap);
        }