private static string SpecialEffectImage(IMatrixFilter effectFilter, string imageFilePath,
     bool isActualSize)
 {
     var specialEffectImageFile = Util.TempPath.GetPath("fullsize_specialeffect");
     using (var imageFactory = new ImageFactory())
     {
         var image = imageFactory
                 .Load(imageFilePath)
                 .Image;
         var ratio = (float)image.Width / image.Height;
         if (isActualSize)
         {
             image = imageFactory
                 .Resize(new Size((int)(768 * ratio), 768))
                 .Filter(effectFilter)
                 .Image;
         }
         else
         {
             image = imageFactory
                 .Resize(new Size((int)(300 * ratio), 300))
                 .Filter(effectFilter)
                 .Image;
         }
         image.Save(specialEffectImageFile);
     }
     return specialEffectImageFile;
 }
Пример #2
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Bitmap newImage = null;
            Image  image    = factory.Image;

            try
            {
                newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb);

                IMatrixFilter matrix = this.DynamicParameter as IMatrixFilter ?? this.ParseFilter((string)this.DynamicParameter);

                if (matrix != null)
                {
                    return(matrix.TransformImage(factory, image, newImage));
                }
            }
            catch
            {
                if (newImage != null)
                {
                    newImage.Dispose();
                }
            }

            return(image);
        }
Пример #3
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Bitmap newImage = null;
            Image  image    = factory.Image;

            try
            {
                newImage = new Bitmap(image.Width, image.Height);
                newImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
                IMatrixFilter matrix = this.DynamicParameter;
                newImage = matrix.TransformImage(image, newImage);

                image.Dispose();
                image = newImage;
            }
            catch (Exception ex)
            {
                if (newImage != null)
                {
                    newImage.Dispose();
                }

                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }

            return(image);
        }
Пример #4
0
        private static string SpecialEffectImage(IMatrixFilter effectFilter, string imageFilePath,
                                                 bool isActualSize)
        {
            var specialEffectImageFile = Util.TempPath.GetPath("fullsize_specialeffect");

            using (var imageFactory = new ImageFactory())
            {
                var image = imageFactory
                            .Load(imageFilePath)
                            .Image;
                var ratio = (float)image.Width / image.Height;
                if (isActualSize)
                {
                    image = imageFactory
                            .Resize(new Size((int)(768 * ratio), 768))
                            .Filter(effectFilter)
                            .Image;
                }
                else
                {
                    image = imageFactory
                            .Resize(new Size((int)(300 * ratio), 300))
                            .Filter(effectFilter)
                            .Image;
                }
                image.Save(specialEffectImageFile);
            }
            return(specialEffectImageFile);
        }
Пример #5
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Bitmap newImage = null;
            Image  image    = factory.Image;

            try
            {
                // TODO: Optimize this one day when I can break the API.
                newImage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb);
                newImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
                IMatrixFilter matrix = this.DynamicParameter;
                newImage = matrix.TransformImage(image, newImage);

                image.Dispose();
                image = newImage;
            }
            catch (Exception ex)
            {
                newImage?.Dispose();

                throw new ImageProcessingException("Error processing image with " + this.GetType().Name, ex);
            }

            return(image);
        }
Пример #6
0
        /// <summary>
        /// Filter an image applying a black and white
        /// </summary>
        public void ApplyFilter(IMatrixFilter filter)
        {
            // Set the filter value
            _currentFilter = filter;

            // Try to add the Filter Func to the _currentEdits list:
            AddNewFunc((image) => _imageEditor.ProcessImage(image, factory => factory.Filter(_currentFilter)), false, true);
        }
Пример #7
0
        //Recives an IMartixFilter parameter and applies it
        public static BitmapImage Filter(IMatrixFilter filter)
        {
            using (MemoryStream outStream = new MemoryStream())
            {
                _factory.Filter(filter).Save(outStream);

                return(Converter.ToBitmap(outStream));
            }
        }
 public PowerPoint.Shape ApplySpecialEffectEffect(IMatrixFilter effectFilter, bool isActualSize)
 {
     Source.SpecialEffectImageFile = SpecialEffectImage(effectFilter, Source.FullSizeImageFile ?? Source.ImageFile, isActualSize);
     var specialEffectImageShape = AddPicture(Source.SpecialEffectImageFile, EffectName.SpecialEffect);
     var slideWidth = SlideWidth;
     var slideHeight = SlideHeight;
     FitToSlide.AutoFit(specialEffectImageShape, slideWidth, slideHeight);
     CropPicture(specialEffectImageShape);
     return specialEffectImageShape;
 }
Пример #9
0
        /// <summary>
        /// Performs the Filter effect from the ImageProcessor library.
        /// </summary>
        /// <param name="image">The image with which to apply the effect.</param>
        /// <param name="matrixFilter">The IMatrixFilter used to apply the effect.</param>
        /// <returns>A new image with the Filter effect applied.</returns>
        public Image Filter(Image image, IMatrixFilter matrixFilter)
        {
            using var factory = new ImageFactory();

            factory.Load(image);
            factory.Filter(matrixFilter);

            var result = factory.Image;

            return(new Bitmap(result));
        }
Пример #10
0
        public PowerPoint.Shape ApplySpecialEffectEffect(IMatrixFilter effectFilter, bool isActualSize)
        {
            Source.SpecialEffectImageFile = SpecialEffectImage(effectFilter, Source.FullSizeImageFile ?? Source.ImageFile, isActualSize);
            var specialEffectImageShape = AddPicture(Source.SpecialEffectImageFile, EffectName.SpecialEffect);
            var slideWidth  = SlideWidth;
            var slideHeight = SlideHeight;

            FitToSlide.AutoFit(specialEffectImageShape, slideWidth, slideHeight);
            CropPicture(specialEffectImageShape);
            return(specialEffectImageShape);
        }
Пример #11
0
        /// <summary>
        /// Applies a filter to the current image. Use the <see cref="MatrixFilters"/> class to
        /// assign the correct filter.
        /// </summary>
        /// <param name="matrixFilter">
        /// The <see cref="IMatrixFilter"/> of the filter to add to the image.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Filter(IMatrixFilter matrixFilter)
        {
            if (this.ShouldProcess)
            {
                Filter filter = new Filter {
                    DynamicParameter = matrixFilter
                };
                this.CurrentImageFormat.ApplyProcessor(filter.ProcessImage, this);
            }

            return(this);
        }
Пример #12
0
        /// <summary>
        /// Determines whether the specified <see cref="IMatrixFilter" />, is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="IMatrixFilter" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="IMatrixFilter" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            IMatrixFilter filter = obj as IMatrixFilter;

            if (filter == null)
            {
                return(false);
            }

            return(this.GetType().Name == filter.GetType().Name &&
                   this.Matrix.Equals(filter.Matrix));
        }
Пример #13
0
        private static MemoryStream Filter(byte[] photoBytes, IMatrixFilter e)
        {
            ISupportedImageFormat format = new PngFormat {
                Quality = 70
            };

            using MemoryStream inStream = new MemoryStream(photoBytes);
            MemoryStream outStream = new MemoryStream();

            using (ImageFactory imageFactory = new ImageFactory())
            {
                imageFactory.Load(inStream)
                .Filter(e)
                .Format(format)
                .Save(outStream);
            }
            return(outStream);
        }
        public void TestFilterRegex()
        {
            Dictionary <string, IMatrixFilter> data = new Dictionary <string, IMatrixFilter>
            {
                {
                    "filter=lomograph", MatrixFilters.Lomograph
                },
                {
                    "filter=polaroid", MatrixFilters.Polaroid
                },
                {
                    "filter=comic", MatrixFilters.Comic
                },
                {
                    "filter=greyscale", MatrixFilters.GreyScale
                },
                {
                    "filter=blackwhite", MatrixFilters.BlackWhite
                },
                {
                    "filter=invert", MatrixFilters.Invert
                },
                {
                    "filter=gotham", MatrixFilters.Gotham
                },
                {
                    "filter=hisatch", MatrixFilters.HiSatch
                },
                {
                    "filter=losatch", MatrixFilters.LoSatch
                },
                {
                    "filter=sepia", MatrixFilters.Sepia
                }
            };

            Processors.Filter filter = new Processors.Filter();
            foreach (KeyValuePair <string, IMatrixFilter> item in data)
            {
                filter.MatchRegexIndex(item.Key);
                IMatrixFilter result = filter.Processor.DynamicParameter;
                Assert.AreEqual(item.Value, result);
            }
        }
Пример #15
0
        private static byte[] CallFunction(byte[] photoBytes, string textDiplay,
                                           string bubbleFigure, string bubblePos, string filter)
        {
            string assetsPath = ConfigurationManager.AppSettings["ASSETS_ROOT"] ?? @"C:\Temp\images\";

            bubbleFigure = bubbleFigure.ToUpper();
            bubblePos    = bubblePos.ToUpper();
            filter       = filter.ToUpper();

            var imgGen = new MemeImgGen.ImageProcessor(assetsPath);

            BubbleFigure   figure       = (BubbleFigure)Enum.Parse(typeof(BubbleFigure), bubbleFigure);
            BubblePosition position     = (BubblePosition)Enum.Parse(typeof(BubblePosition), bubblePos);
            BubbleFilter   bFilter      = (BubbleFilter)Enum.Parse(typeof(BubbleFilter), filter);
            IMatrixFilter  bubbleFilter = imgGen.GetFilterByName(bFilter);

            // 이미지 변환 메서드 호출
            byte[] outBytes = imgGen.ImageGenerate(photoBytes, textDiplay, figure, position, bubbleFilter);
            return(outBytes);
        }
Пример #16
0
        public static async void Run(
            [QueueTrigger("meme-que")] VisionInfo info,
            string BlobName,
            [Blob("meme-input/{BlobName}", FileAccess.Read)] byte[] inputBlob,
            [Blob("meme-output/{BlobName}", FileAccess.Write)] Stream outputBlob,
            TraceWriter log)
        {
            string assetsPath = ConfigurationManager.AppSettings["ASSETS_ROOT"] ?? @"C:\Temp\images\";

            string bubbleFigure = info.BubbleInfo.Figure.ToUpper();
            string bubblePos    = info.BubbleInfo.Position.ToUpper();
            string filter       = info.BubbleInfo.Filter.ToUpper();
            string textDisplay  = info.BubbleInfo.Text;
            var    imgGen       = new MemeImgGen.ImageProcessor(assetsPath);

            BubbleFigure   figure       = (BubbleFigure)Enum.Parse(typeof(BubbleFigure), bubbleFigure);
            BubblePosition position     = (BubblePosition)Enum.Parse(typeof(BubblePosition), bubblePos);
            BubbleFilter   bFilter      = (BubbleFilter)Enum.Parse(typeof(BubbleFilter), filter);
            IMatrixFilter  bubbleFilter = imgGen.GetFilterByName(bFilter);

            // 이미지 변환 메서드 호출
            byte[] outBytes = imgGen.ImageGenerate(inputBlob, textDisplay, figure, position, bubbleFilter);
            await outputBlob.WriteAsync(outBytes, 0, outBytes.Length);
        }
Пример #17
0
        /// <summary>
        /// Applies a filter to the current image. Use the <see cref="MatrixFilters"/> class to 
        /// assign the correct filter.
        /// </summary>
        /// <param name="matrixFilter">
        /// The <see cref="IMatrixFilter"/> of the filter to add to the image.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Filter(IMatrixFilter matrixFilter)
        {
            if (this.ShouldProcess)
            {
                Filter filter = new Filter { DynamicParameter = matrixFilter };
                this.CurrentImageFormat.ApplyProcessor(filter.ProcessImage, this);
            }

            return this;
        }
 public MatrixFilterTransformation(IMatrixFilter filter)
 {
     _filter = filter;
 }
Пример #19
0
 public FilterModel(IMatrixFilter filter, string name)
 {
     Filter = filter;
     Name   = name;
 }
Пример #20
0
        /// <summary>
        /// Main method of this class for processing image
        /// provide filtering, image overlaying etc
        /// </summary>
        /// <param name="photoBytes"></param>
        /// <returns></returns>
        public byte[] ImageGenerate(byte[] photoBytes, string textDiplay,
                                    BubbleFigure bubbleFigure, BubblePosition bubblePosition, IMatrixFilter appliedFilter)
        {
            // Get width and height of original image
            // I know it's not good solution but now... remain
            int originImgWidth, originImgHeight;

            using (Image image = Image.FromStream(new MemoryStream(photoBytes)))
            {
                originImgWidth  = image.Width;
                originImgHeight = image.Height;
            }

            // 가정
            // 1. 이미지의 widht 는 400으로 한다. (resize 필요)
            // 2. 버블은 좌,우 및 상,하로 구분한다

            var bubbleInfo = GetBubbleInfo(bubblePosition, bubbleFigure);

            // Format is automatically detected though can be changed.
            ISupportedImageFormat format = new JpegFormat {
                Quality = 70
            };

            Bitmap bitmap = (Bitmap)Image.FromFile(Path.Combine(assetsPath, bubbleInfo.ImageName));

            #region 강제 텍스트 출력예
            //string firstText = "내 이름은";
            //string secondText = "빌 게이츠";

            //PointF firstLocation = new PointF(10f, 10f);
            //PointF secondLocation = new PointF(10f, 50f);

            //using (Graphics graphics = Graphics.FromImage(bitmap))
            //{
            //    using (Font arialFont = new Font("Malgun Gothic", 20, FontStyle.Bold))
            //    {
            //        graphics.DrawString(firstText, arialFont, Brushes.Black, firstLocation);
            //        graphics.DrawString(secondText, arialFont, Brushes.Black, secondLocation);
            //    }
            //}
            #endregion

            //Bitmap newBitmap = new Bitmap(bitmap.Width, bitmap.Height);
            // create bitmap for overlaying
            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                using (Font font1 = new Font(this.fontName, 120, FontStyle.Bold, GraphicsUnit.Pixel))
                {
                    Rectangle rect1 = bubbleInfo.TextArea;

                    StringFormat stringFormat = new StringFormat();
                    stringFormat.Alignment     = StringAlignment.Center;
                    stringFormat.LineAlignment = StringAlignment.Center;
                    graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;

                    Font goodFont = FindFont(graphics, textDiplay, rect1.Size, font1);
                    graphics.DrawString(textDiplay, goodFont, Brushes.Black, rect1, stringFormat);
                }
            }
            //Image img = (Image)bitmap;
            Image overlayImage = (Image)bitmap;

            //get width and height of layer for overlay
            int overlayWidth, overlayHeight;
            overlayWidth  = overlayImage.Width;
            overlayHeight = overlayImage.Height;

            // revise TextArea width and Height
            Rectangle rec = bubbleInfo.TextArea;
            if (bubbleFigure == BubbleFigure.NORMAL)
            {
                bubbleInfo.TextArea = new Rectangle(rec.X, rec.Y, rec.Width - figure_normal_revise_w, rec.Height - figure_normal_revise_h);
            }

            using (MemoryStream inStream = new MemoryStream(photoBytes))
            {
                // if bubblePosition is right side, start X is imgWidth - overlayWidth
                if (bubblePosition == BubblePosition.TOPRIGHT || bubblePosition == BubblePosition.BOTTOMRIGHT)
                {
                    bubbleInfo.StartPoint = new Point(originImgWidth - overlayWidth, bubbleInfo.StartPoint.Y);
                }

                // if bubblePosition is bottom side, start y is imgHeight - overlayHeight
                if (bubblePosition == BubblePosition.BOTTOMLEFT || bubblePosition == BubblePosition.BOTTOMRIGHT)
                {
                    bubbleInfo.StartPoint = new Point(bubbleInfo.StartPoint.X, originImgHeight - overlayHeight);
                }

                using (MemoryStream outStream = new MemoryStream())
                {
                    // Initialize the ImageFactory using the overload to preserve EXIF metadata.
                    using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true))
                    {
                        //Image img = Image.FromFile(@"C:\Temp\images\bubble-tp.png");
                        ImageLayer layer = new ImageLayer();
                        layer.Image    = overlayImage;
                        layer.Opacity  = this.opacity;
                        layer.Position = bubbleInfo.StartPoint;

                        //필터 적용?
                        // Comic, Gotham, GreyScale, Lomograph, Polaroid, HiSatch, Sepia
                        var filter = appliedFilter;

                        // Load, resize, set the format and quality and save an image.
                        var factory = imageFactory.Load(inStream)
                                      //.Resize(size)
                                      .Format(format);

                        if (appliedFilter != null)
                        {
                            factory.Filter(filter);
                        }

                        factory
                        .Overlay(layer)
                        .Save(outStream);
                    }

                    return(outStream.ToArray());
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Processes the image.
        /// </summary>
        /// <param name="factory">
        /// The the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class containing
        /// the image to process.
        /// </param>
        /// <returns>
        /// The processed image from the current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public Image ProcessImage(ImageFactory factory)
        {
            Bitmap        newImage = null;
            Image         image    = factory.Image;
            IMatrixFilter matrix   = null;

            try
            {
                // Dont use an object initializer here.
                newImage     = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppPArgb);
                newImage.Tag = image.Tag;

                switch ((string)this.DynamicParameter)
                {
                case "polaroid":
                    matrix = new PolaroidMatrixFilter();
                    break;

                case "lomograph":
                    matrix = new LomographMatrixFilter();
                    break;

                case "sepia":
                    matrix = new SepiaMatrixFilter();
                    break;

                case "blackwhite":
                    matrix = new BlackWhiteMatrixFilter();
                    break;

                case "greyscale":
                    matrix = new GreyScaleMatrixFilter();
                    break;

                case "gotham":
                    matrix = new GothamMatrixFilter();
                    break;

                case "invert":
                    matrix = new InvertMatrixFilter();
                    break;

                case "hisatch":
                    matrix = new HiSatchMatrixFilter();
                    break;

                case "losatch":
                    matrix = new LoSatchMatrixFilter();
                    break;

                case "comic":
                    matrix = new ComicMatrixFilter();
                    break;
                }

                if (matrix != null)
                {
                    return(matrix.TransformImage(factory, image, newImage));
                }
            }
            catch
            {
                if (newImage != null)
                {
                    newImage.Dispose();
                }
            }

            return(image);
        }
        private void AddBackgroundImage(IMatrixFilter filter)
        {
            using (var imageFactory = new ImageFactory())
            {
                var image = imageFactory.Load(AnimatedBackgroundPath);

                image = filter == null ? image.GaussianBlur(20) : image.Filter(filter);

                image.Save(AnimatedBackgroundPath);
            }

            var newBackground = Shapes.AddPicture(AnimatedBackgroundPath, Core.MsoTriState.msoFalse,
                                                  Core.MsoTriState.msoTrue,
                                                  0, 0,
                                                  PowerPointPresentation.Current.SlideWidth,
                                                  PowerPointPresentation.Current.SlideHeight);

            newBackground.ZOrder(Core.MsoZOrderCmd.msoSendToBack);
        }
Пример #23
0
        /// <summary>
        /// Applies an IMatrixFilter effect to the current image.
        /// </summary>
        /// <param name="this">The current ImageEditorState.</param>
        /// <param name="filter">The IMatrixFilter used to apply the effect.</param>
        public static void Filter(this ImageEditorState @this, IMatrixFilter filter)
        {
            var newImage = ImageProcessor.Instance.Filter(@this.Image, filter);

            @this.Update(newImage);
        }
Пример #24
0
        private void Start_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
restart:
            foreach (string filename in Filenames)
            {
                byte[] photoBytes            = File.ReadAllBytes(filename);
                ISupportedImageFormat format = new JpegFormat();
                using (MemoryStream inStream = new MemoryStream(photoBytes))
                {
                    string[] temp           = filename.Split(new Char[] { '\\' });
                    string   tempe          = temp.Last();
                    string   outputFileName = string.Format("E:\\res\\{0}", tempe);
                    string   quote          = quotes[new Random().Next(0, quotes.Length)];
                    using (MemoryStream outStream = new MemoryStream())
                    {
                        // Initialize the ImageFactory using the overload to preserve EXIF metadata.
                        using (ImageFactory imageFactory = new ImageFactory())
                        {
                            // Load, resize, set the format and quality and save an image.
                            if (BlackWhite.Checked)
                            {
                                IMatrixFilter filter = MatrixFilters.BlackWhite;
                                imageFactory.Load(inStream);
                                imageFactory.Filter(filter);
                                imageFactory.Format(format);
                                imageFactory.Watermark(new TextLayer
                                {
                                    FontFamily = new FontFamily("Arial"),
                                    FontSize   = this.fontsize,
                                    Position   = new Point(xpos, ypos),
                                    Opacity    = opacity,
                                    DropShadow = shadow,
                                    Text       = quote
                                });
                                imageFactory.Save(outputFileName);
                                wallpaper.SetDesktopWallpaper(outputFileName);
                            }
                            else if (Comic.Checked)
                            {
                                IMatrixFilter filter = MatrixFilters.Comic;
                                imageFactory.Load(inStream);
                                imageFactory.Filter(filter);
                                imageFactory.Format(format);
                                imageFactory.Watermark(new TextLayer
                                {
                                    FontFamily = new FontFamily("Arial"),
                                    FontSize   = fontsize,
                                    Position   = new Point(xpos, ypos),
                                    Opacity    = opacity,
                                    DropShadow = shadow,
                                    Text       = quote
                                });
                                imageFactory.Save(outputFileName);
                                wallpaper.SetDesktopWallpaper(outputFileName);
                            }
                            else if (HiSatch.Checked)
                            {
                                IMatrixFilter filter = MatrixFilters.HiSatch;
                                imageFactory.Load(inStream);
                                imageFactory.Filter(filter);
                                imageFactory.Format(format);
                                imageFactory.Watermark(new TextLayer
                                {
                                    FontFamily = new FontFamily("Arial"),
                                    FontSize   = this.fontsize,
                                    Position   = new Point(xpos, ypos),
                                    Opacity    = opacity,
                                    DropShadow = shadow,
                                    Text       = quote
                                });
                                imageFactory.Save(outputFileName);
                                wallpaper.SetDesktopWallpaper(outputFileName);
                            }
                            else if (LoSatch.Checked)
                            {
                                IMatrixFilter filter = MatrixFilters.LoSatch;
                                imageFactory.Load(inStream);
                                imageFactory.Filter(filter);
                                imageFactory.Format(format);
                                imageFactory.Watermark(new TextLayer
                                {
                                    FontFamily = new FontFamily("Arial"),
                                    FontSize   = fontsize,
                                    Position   = new Point(xpos, ypos),
                                    Opacity    = opacity,
                                    DropShadow = shadow,
                                    Text       = quote
                                });
                                imageFactory.Save(outputFileName);
                                wallpaper.SetDesktopWallpaper(outputFileName);
                            }
                            else if (Polaroid.Checked)
                            {
                                IMatrixFilter filter = MatrixFilters.Polaroid;
                                imageFactory.Load(inStream);
                                imageFactory.Filter(filter);
                                imageFactory.Format(format);
                                imageFactory.Watermark(new TextLayer
                                {
                                    FontFamily = new FontFamily("Arial"),
                                    FontSize   = fontsize,
                                    Position   = new Point(xpos, ypos),
                                    Opacity    = opacity,
                                    DropShadow = shadow,
                                    Text       = quote
                                });
                                imageFactory.Save(outputFileName);
                                wallpaper.SetDesktopWallpaper(outputFileName);
                            }
                            else if (GreyScale.Checked)
                            {
                                IMatrixFilter filter = MatrixFilters.GreyScale;
                                imageFactory.Load(inStream);
                                imageFactory.Filter(filter);
                                imageFactory.Format(format);
                                imageFactory.Watermark(new TextLayer
                                {
                                    FontFamily = new FontFamily("Arial"),
                                    FontSize   = fontsize,
                                    Position   = new Point(xpos, ypos),
                                    Opacity    = opacity,
                                    DropShadow = shadow,
                                    Text       = quote
                                });
                                imageFactory.Save(outputFileName);
                                wallpaper.SetDesktopWallpaper(outputFileName);
                            }
                            else if (Gotham.Checked)
                            {
                                IMatrixFilter filter = MatrixFilters.Gotham;
                                imageFactory.Load(inStream);
                                imageFactory.Filter(filter);
                                imageFactory.Format(format);
                                imageFactory.Watermark(new TextLayer
                                {
                                    FontFamily = new FontFamily("Arial"),
                                    FontSize   = fontsize,
                                    Position   = new Point(xpos, ypos),
                                    Opacity    = opacity,
                                    DropShadow = shadow,
                                    Text       = quote
                                });
                                imageFactory.Save(outputFileName);
                                wallpaper.SetDesktopWallpaper(outputFileName);
                            }
                            else if (Sepia.Checked)
                            {
                                IMatrixFilter filter = MatrixFilters.Sepia;
                                imageFactory.Load(inStream);
                                imageFactory.Filter(filter);
                                imageFactory.Format(format);
                                imageFactory.Watermark(new TextLayer
                                {
                                    FontFamily = new FontFamily("Arial"),
                                    FontSize   = fontsize,
                                    Position   = new Point(xpos, ypos),
                                    Opacity    = opacity,
                                    DropShadow = shadow,
                                    Text       = quote
                                });
                                imageFactory.Save(outputFileName);
                                wallpaper.SetDesktopWallpaper(outputFileName);
                            }
                        }
                        // Do something with the stream.
                    }
                }
                //wallpaper.SetDesktopWallpaper(filename);
                Thread.Sleep(value);
                if (Filenames.Last() == filename)
                {
                    goto restart;
                }
            }
        }