Exemplo n.º 1
0
        public void Convert_to_Gs()
        {
            this.Reset();
            IMatrixFilter Ifilter;

            Ifilter = MatrixFilters.GreyScale;
            imFactory.Filter(Ifilter);
        }
Exemplo n.º 2
0
 public void createField(float rotAng)
 {
     // Prepare image to be delivered as flunence //
     imgFcty.Reset();
     imgFcty.Filter(MatrixFilters.GreyScale);             // convert to greyscale
     imgFcty.Resize(new System.Drawing.Size(xDim, yDim)); // resize to xDim x yDim
     imgFcty.Rotate(rotAng).BackgroundColor(System.Drawing.Color.White);
     imgFcty.Filter(MatrixFilters.Invert);                // invert pixel values
     int[,] imgArr = convertImgToArr(new Bitmap(imgFcty.Image));
     // Create fluence matrix //
     float[,] flncMtx = createFluenceMatrix(imgArr, 150);
     // Create MLC field //
     createMlcField(flncMtx, rotAng);
 }
Exemplo n.º 3
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));
            }
        }
Exemplo n.º 4
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));
        }
 public override void ProcessImage(ref ImageFactory imageFactory)
 {
     imageFactory.Resize(new Size(512, 512));
     imageFactory.Saturation(-100);
     imageFactory.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.Polaroid);
     imageFactory.GaussianBlur(15);
     imageFactory.Vignette();
     imageFactory.RoundedCorners(30);
     imageFactory.Rotate(-5);
     channel.SendMessage("My old friend...");
 }
Exemplo n.º 6
0
        protected void ProcessarButton_Click(object sender, EventArgs e)
        {
            byte[]       inputFile        = FileUpload1.FileBytes;
            MemoryStream imgMemoryStream  = new MemoryStream(inputFile);
            FileStream   outputFileStream = new FileStream(Server.MapPath(@"image.jpg"), FileMode.OpenOrCreate);

            ImageFactory image = new ImageFactory();

            image.Load(imgMemoryStream);
            image.Filter(MatrixFilters.Invert);
            image.Save(outputFileStream);
            outputFileStream.Close();
        }
Exemplo n.º 7
0
 private void chooseBtn_Click(object sender, EventArgs e)
 {
     if (grayScale.Checked == true)
     {
         imgFactory.Filter(MatrixFilters.GreyScale);
         Close();
     }
     else if (comicFilter.Checked == true)
     {
         imgFactory.Filter(MatrixFilters.Comic);
         Close();
     }
     else if (polaroidFilter.Checked == true)
     {
         imgFactory.Filter(MatrixFilters.Polaroid);
         Close();
     }
     else if (hiSatchFilter.Checked == true)
     {
         imgFactory.Filter(MatrixFilters.HiSatch);
         Close();
     }
 }
Exemplo n.º 8
0
        public override void ProcessImage(ref ImageFactory imageFactory)
        {
            imageFactory.Resize(new Size(512, 512));
            imageFactory.Pixelate(12);
            imageFactory.GaussianSharpen(20);
            imageFactory.Brightness(50);
            imageFactory.Contrast(50);
            imageFactory.Filter(ImageProcessor.Imaging.Filters.Photo.MatrixFilters.Invert);

            MemoryStream stream = new MemoryStream();

            imageFactory.Save(stream);

            imageFactory.Reset();
            imageFactory.Load(stream);
            imageFactory.Saturation(100);

            channel.SendMessage("PUNT");
        }
        /// <summary>
        /// Applies a filter to the image.
        /// </summary>
        /// <param name="imageFilters">The filter to apply to the image.</param>
        /// <returns>The resulting image.</returns>
        public Image ApplyFilter(ImageFilters imageFilters)
        {
            _editor.Load(_tempImage);

            IMatrixFilter filter;

            switch (imageFilters)
            {
            case ImageFilters.BlackWhite:
                filter = MatrixFilters.BlackWhite;
                break;

            case ImageFilters.Comic:
                filter = MatrixFilters.Comic;
                break;

            case ImageFilters.Gotham:
                filter = MatrixFilters.Gotham;
                break;

            case ImageFilters.Invert:
                filter = MatrixFilters.Invert;
                break;

            case ImageFilters.Polaroid:
                filter = MatrixFilters.Polaroid;
                break;

            case ImageFilters.Sepia:
                filter = MatrixFilters.Sepia;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(imageFilters), imageFilters, null);
            }

            _editor.Filter(filter);

            return(_editor.Image);
        }
        public ImagePreviewResponse Preview(string imageId, string containerName, string imageFormat, int brightness, int contrast, int saturation, int sharpness, bool sepia, bool polaroid, bool greyscale)
        {
            var response = new ImagePreviewResponse();

            //Create the id for the enhanced "preview" version of the source image
            string enhancedImageId    = Guid.NewGuid().ToString();
            var    outputFormatString = string.Empty;
            ISupportedImageFormat outputFormatProcessorProperty = null;

            System.Drawing.Imaging.ImageFormat outputFormatSystemrawingFormat = null;

            #region Select image format, or send error

            switch (imageFormat)
            {
            case "jpg":
                outputFormatString            = ".jpg";
                outputFormatProcessorProperty = new JpegFormat {
                    Quality = 90
                };
                outputFormatSystemrawingFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
                break;

            case "gif":
                outputFormatString             = ".gif";
                outputFormatProcessorProperty  = new GifFormat {
                };
                outputFormatSystemrawingFormat = System.Drawing.Imaging.ImageFormat.Gif;
                break;

            case "png":
                outputFormatString             = ".png";
                outputFormatProcessorProperty  = new PngFormat {
                };
                outputFormatSystemrawingFormat = System.Drawing.Imaging.ImageFormat.Png;
                break;

            case "bmp":
                outputFormatString             = ".bmp";
                outputFormatProcessorProperty  = new BitmapFormat {
                };
                outputFormatSystemrawingFormat = System.Drawing.Imaging.ImageFormat.Bmp;
                break;

            case "tiff":
                outputFormatString             = ".tiff";
                outputFormatProcessorProperty  = new TiffFormat {
                };
                outputFormatSystemrawingFormat = System.Drawing.Imaging.ImageFormat.Tiff;
                break;

            default:
                return(new ImagePreviewResponse {
                    isSuccess = false, ErrorMessage = "Please please use a supported file format: jpg, png, gif, bmp or tiff."
                });
            }

            #endregion

            #region verify all input parameters, or send error

            if (
                brightness < -100 || brightness > 100 ||
                sharpness < -100 || sharpness > 100 ||
                contrast < -100 || contrast > 100 ||
                saturation < -100 || saturation > 100
                )
            {
                return(new ImagePreviewResponse {
                    isSuccess = false, ErrorMessage = "Please pass in a value between -100 and 100 for all enhancement parameters"
                });
            }

            #endregion

            //Build out response object
            response.ImageID    = enhancedImageId;
            response.FileName   = enhancedImageId + outputFormatString;
            response.SourceFile = imageId + outputFormatString;

            #region Connect to Intermediary Storage

            // Credentials are from centralized CoreServiceSettings
            StorageCredentials storageCredentials = new StorageCredentials(CoreServices.PlatformSettings.Storage.IntermediaryName, CoreServices.PlatformSettings.Storage.IntermediaryKey);
            var             storageAccount        = new CloudStorageAccount(storageCredentials, false);
            CloudBlobClient blobClient            = storageAccount.CreateCloudBlobClient();

            #endregion


            try
            {
                //Pull down the source image as MemoryStream from Blob storage and apply image enhancement properties
                using (MemoryStream sourceStream = Common.GetAssetFromIntermediaryStorage(response.SourceFile, containerName, blobClient))
                {
                    #region Image Processor & Storage

                    using (MemoryStream outStream = new MemoryStream())
                    {
                        using (ImageFactory imageFactory = new ImageFactory())
                        {
                            // Load, resize, set the format and quality and save an image.
                            // Applies all in order...
                            sourceStream.Position = 0;
                            imageFactory.Load(sourceStream);

                            if (brightness != 0)
                            {
                                imageFactory.Brightness(brightness);
                            }
                            if (contrast != 0)
                            {
                                imageFactory.Contrast(contrast);
                            }
                            if (saturation != 0)
                            {
                                imageFactory.Saturation(saturation);
                            }

                            //Sharpness
                            if (sharpness != 0)
                            {
                                imageFactory.GaussianSharpen(sharpness);
                            }

                            //Filters
                            if (sepia == true)
                            {
                                imageFactory.Filter(MatrixFilters.Sepia);
                            }
                            if (polaroid == true)
                            {
                                imageFactory.Filter(MatrixFilters.Polaroid);
                            }
                            if (greyscale == true)
                            {
                                imageFactory.Filter(MatrixFilters.GreyScale);
                            }

                            imageFactory.Save(outStream);
                        }


                        //Store each image size to BLOB STORAGE ---------------------------------
                        #region BLOB STORAGE

                        //Creat/Connect to the Blob Container
                        //blobClient.GetContainerReference(containerName).CreateIfNotExists(BlobContainerPublicAccessType.Blob); //<-- Create and make public
                        CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);

                        //Get reference to the picture blob or create if not exists.
                        CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(response.FileName);

                        //Save to storage
                        //Convert final BMP to byteArray
                        Byte[] finalByteArray;

                        finalByteArray = outStream.ToArray();

                        //Store the enhanced "preview" into the same container as the soure
                        blockBlob.UploadFromByteArray(finalByteArray, 0, finalByteArray.Length);

                        #endregion
                    }

                    #endregion
                }
            }
            catch (Exception e)
            {
                return(new ImagePreviewResponse {
                    isSuccess = false, ErrorMessage = e.Message
                });
            }

            //Marke as successful and return the new ImageID and FileName back to the client for previewing:
            response.isSuccess = true;
            return(response);
        }
Exemplo n.º 11
0
 public ImageFactory PerformAction(ImageFactory image)
 {
     return(image.Filter(matrix));
 }
 protected override ImageFactory transform(ImageFactory factory)
 {
     return(factory.Filter(_filter));
 }
        public DataAccessResponseType ProcessApplicationImage(string accountId, string storagePartition, string sourceContainerName, string sourceFileName, int formatWidth, int formatHeight, string folderName, string type, int quality, ImageCropCoordinates imageCropCoordinates, ImageEnhancementInstructions imageEnhancementInstructions)
        {
            //Create image id and response object
            string imageId  = System.Guid.NewGuid().ToString();
            var    response = new DataAccessResponseType();

            //var imageSpecs = Sahara.Core.Settings.Imaging.Images.ApplicationImage;
            //var setSizes = imageSpecs.SetSizes;
            //var folderName = imageSpecs.ParentName;


            //-------------------------------------------------
            // REFACTORING NOTES
            //-------------------------------------------------
            // In this scenario we have ApplicationImages hard coded to 600x300 for the LARGE size. We then create a medium and small dynmically (as well as a thumbnail hardcoded to 96px tall)(specific sizes can be factored in if required).
            // In extended scenarios we can pass these specs from CoreServices to clients via a call or from a Redis Cache or WCF fallback.
            // In scenarios where accounts have "Flexible Schemas" we can retreive these properties from a Redis or WCF call for each account based on that accounts set properties.
            //-----------------------------------------------------------------------------


            //var largeSize = new ApplicationImageSize{X=600, Y=300, Name="Large", NameKey = "large"};
            //var mediumSize = new ApplicationImageSize { X = Convert.ToInt32(largeSize.X / 1.25), Y = Convert.ToInt32(largeSize.Y / 1.25), Name = "Medium", NameKey = "medium" }; //<-- Med is 1/1.25 of large
            //var smallSize = new ApplicationImageSize { X = largeSize.X / 2, Y = largeSize.Y / 2, Name = "Small", NameKey = "small" }; //<-- Small is 1/2 of large

            //We calculate thumbnail width based on a set height of 96px.
            //Must be a Double and include .0 in calculation or will ALWAYS calculate to 0!
            //double calculatedThumbnailWidth = ((96.0 / largeSize.Y) * largeSize.X); //<-- Must be a Double and include .0 or will calculate to 0!

            //var thumbnailSize = new ApplicationImageSize { X = (int)calculatedThumbnailWidth, Y = 96, Name = "Thumbnail", NameKey = "thumbnail" }; //<-- Thumbnail is 96px tall, width is calculated based on this

            //We are going to loop through each size during processing
            //var setSizes = new List<ApplicationImageSize> { largeSize, mediumSize, smallSize, thumbnailSize };

            //Folder name within Blob storage for application image collection
            //var folderName = "applicationimages"; //" + imageId; //<-- Each image lives within a folder named after it's id: /applicationimages/[imageid]/[size].jpg

            //Image Format Settings
            var outputFormatString = "." + type;



            ISupportedImageFormat outputFormatProcessorProperty; // = new JpegFormat { Quality = 90 }; // <-- Format is automatically detected though can be changed.

            //ImageFormat outputFormatSystemrawingFormat; // = System.Drawing.Imaging.ImageFormat.Jpeg;


            if (type == "gif")
            {
                outputFormatProcessorProperty = new GifFormat {
                    Quality = quality
                };                                                                   // <-- Format is automatically detected though can be changed.
                //outputFormatSystemrawingFormat = System.Drawing.Imaging.ImageFormat.Gif;
            }
            else if (type == "png")
            {
                outputFormatProcessorProperty = new PngFormat {
                    Quality = quality
                };                                                                   // <-- Format is automatically detected though can be changed.
                //outputFormatSystemrawingFormat = System.Drawing.Imaging.ImageFormat.Png;
            }
            else
            {
                outputFormatProcessorProperty = new JpegFormat {
                    Quality = quality
                };                                                                    // <-- Format is automatically detected though can be changed.
                //outputFormatSystemrawingFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
            }

            /**/

            //TO DO: IF ASPECT RATIO EXISTS THEN WE DETRIMINE THE SET SIZE (1 only) by method



            //Create instance of ApplicationImageDocumentModel to store image details into DocumentDB
            // var applicationImageDocumentModel = new ApplicationImageDocumentModel();
            //applicationImageDocumentModel.Id = imageId;
            // applicationImageDocumentModel.FilePath = folderName; //<--Concatenates with each FileName for fil location

            //Note: We store all images in a single folder to make deletions more performant

            // applicationImageDocumentModel.FileNames = new ApplicationImageFileSizes();


            //Get source file as MemoryStream from Blob storage and apply image processing tasks to each spcification
            using (MemoryStream sourceStream = Common.GetAssetFromIntermediaryStorage(sourceContainerName, sourceFileName))
            {
                //var sourceBmp = new Bitmap(sourceStream); //<--Convert to BMP in order to run verifications

                //Verifiy Image Settings Align With Requirements

                /*
                 * var verifySpecsResponse = Common.VerifyCommonImageSpecifications(sourceBmp, imageSpecs);
                 * if (!verifySpecsResponse.isSuccess)
                 * {
                 *  //return if fails
                 *  return verifySpecsResponse;
                 * }*/


                //Assign properties to the DocumentDB Document representation of this image
                //applicationImageDocumentModel.FileNames.Large = "large" + outputFormatString;
                //applicationImageDocumentModel.FileNames.Medium = "medium" + outputFormatString;
                //applicationImageDocumentModel.FileNames.Small = "small" + outputFormatString;
                //a/pplicationImageDocumentModel.FileNames.Thumbnail = "thumbnail" + outputFormatString;

                //Create 3 sizes (org, _sm & _xs)
                //List<Size> imageSizes = new List<Size>();

                Dictionary <Size, string> imageSizes = new Dictionary <Size, string>();

                imageSizes.Add(new Size(formatWidth, formatHeight), "");            //<-- ORG (no apennded file name)
                imageSizes.Add(new Size(formatWidth / 2, formatHeight / 2), "_sm"); //<-- SM (Half Size)
                imageSizes.Add(new Size(formatWidth / 4, formatHeight / 4), "_xs"); //<-- XS (Quarter Size)

                foreach (KeyValuePair <Size, string> entry in imageSizes)
                {
                    Size   processingSize   = entry.Key;
                    string appendedFileName = entry.Value;

                    #region Image Processor & Storage

                    //Final location for EACH image will be: http://[uri]/[containerName]/[imageId]_[size].[format]

                    var filename     = imageId + appendedFileName + outputFormatString; //<-- [imageid][_xx].xxx
                    var fileNameFull = folderName + "/" + filename;                     //<-- /applicationimages/[imageid][_xx].xxx

                    //Size processingSize = new Size(formatWidth, formatHeight);
                    var resizeLayer = new ResizeLayer(processingSize)
                    {
                        ResizeMode = ResizeMode.Crop, AnchorPosition = AnchorPosition.Center
                    };


                    using (MemoryStream outStream = new MemoryStream())
                    {
                        using (ImageFactory imageFactory = new ImageFactory())
                        {
                            // Load, resize, set the format and quality and save an image.
                            // Applies all in order...
                            sourceStream.Position = 0; //<-- Have to set position to 0 to makse sure imageFactory.Load starts from the begining.
                            imageFactory.Load(sourceStream);

                            if (imageCropCoordinates != null)
                            {
                                var cropLayer = new ImageProcessor.Imaging.CropLayer(imageCropCoordinates.Left, imageCropCoordinates.Top, imageCropCoordinates.Right, imageCropCoordinates.Bottom, CropMode.Pixels);
                                //var cropRectangle = new Rectangle(imageCropCoordinates.Top, imageCropCoordinates.Left);

                                imageFactory.Crop(cropLayer);     //<-- Crop first
                                imageFactory.Resize(resizeLayer); //<-- Then resize
                            }
                            else
                            {
                                imageFactory.Resize(resizeLayer);//<-- Resize
                            }

                            //Convert to proper format
                            imageFactory.Format(outputFormatProcessorProperty);

                            if (imageEnhancementInstructions != null)
                            {
                                //Basics ---

                                if (imageEnhancementInstructions.Brightness != 0)
                                {
                                    imageFactory.Brightness(imageEnhancementInstructions.Brightness);
                                }
                                if (imageEnhancementInstructions.Contrast != 0)
                                {
                                    imageFactory.Contrast(imageEnhancementInstructions.Contrast);
                                }
                                if (imageEnhancementInstructions.Saturation != 0)
                                {
                                    imageFactory.Saturation(imageEnhancementInstructions.Saturation);
                                }

                                // Sharpness ---
                                if (imageEnhancementInstructions.Sharpen != 0)
                                {
                                    imageFactory.GaussianSharpen(imageEnhancementInstructions.Sharpen);
                                }


                                //Filters ----

                                if (imageEnhancementInstructions.Sepia == true)
                                {
                                    imageFactory.Filter(MatrixFilters.Sepia);
                                }

                                if (imageEnhancementInstructions.Polaroid == true)
                                {
                                    imageFactory.Filter(MatrixFilters.Polaroid);
                                }
                                if (imageEnhancementInstructions.Greyscale == true)
                                {
                                    imageFactory.Filter(MatrixFilters.GreyScale);
                                }
                            }

                            imageFactory.Save(outStream);
                        }


                        //Store image size to BLOB STORAGE ---------------------------------
                        #region BLOB STORAGE

                        //CloudBlobClient blobClient = Sahara.Core.Settings.Azure.Storage.StorageConnections.AccountsStorage.CreateCloudBlobClient();
                        CloudBlobClient blobClient = Settings.Azure.Storage.GetStoragePartitionAccount(storagePartition).CreateCloudBlobClient();

                        //Create and set retry policy
                        IRetryPolicy exponentialRetryPolicy = new ExponentialRetry(TimeSpan.FromMilliseconds(400), 6);
                        blobClient.DefaultRequestOptions.RetryPolicy = exponentialRetryPolicy;

                        //Creat/Connect to the Blob Container
                        blobClient.GetContainerReference(accountId).CreateIfNotExists(BlobContainerPublicAccessType.Blob); //<-- Create and make public
                        CloudBlobContainer blobContainer = blobClient.GetContainerReference(accountId);

                        //Get reference to the picture blob or create if not exists.
                        CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(fileNameFull);


                        if (type == "gif")
                        {
                            blockBlob.Properties.ContentType = "image/gif";
                        }
                        else if (type == "png")
                        {
                            blockBlob.Properties.ContentType = "image/png";
                        }
                        else
                        {
                            blockBlob.Properties.ContentType = "image/jpg";
                        }

                        //Save to storage
                        //Convert final BMP to byteArray
                        Byte[] finalByteArray;

                        finalByteArray = outStream.ToArray();

                        blockBlob.UploadFromByteArray(finalByteArray, 0, finalByteArray.Length);

                        #endregion
                    }

                    #endregion
                }
            }
Exemplo n.º 14
0
 public override void Apply(ImageFactory fs)
 {
     fs = fs.Filter(matrix);
 }
Exemplo n.º 15
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;
                }
            }
        }
Exemplo n.º 16
0
        private static void ApplyFilterSetting(ImageFactory imageToAdjust, string setting, string value)
        {
            switch (setting)
            {
            case "brightness":
                imageToAdjust.Brightness(int.Parse(value));
                break;

            case "contrast":
                imageToAdjust.Contrast(int.Parse(value));
                break;

            case "filter":
                switch (value)
                {
                case "gotham":
                    imageToAdjust.Filter(MatrixFilters.Gotham);
                    break;

                case "invert":
                    imageToAdjust.Filter(MatrixFilters.Invert);
                    break;

                case "polaroid":
                    imageToAdjust.Filter(MatrixFilters.Polaroid);
                    break;

                case "blackwhite":
                    imageToAdjust.Filter(MatrixFilters.BlackWhite);
                    break;

                case "greyscale":
                    imageToAdjust.Filter(MatrixFilters.GreyScale);
                    break;

                case "lomograph":
                    imageToAdjust.Filter(MatrixFilters.Lomograph);
                    break;

                case "sepia":
                    imageToAdjust.Filter(MatrixFilters.Sepia);
                    break;

                case "comic":
                    imageToAdjust.Filter(MatrixFilters.Comic);
                    break;

                case "hisatch":
                    imageToAdjust.Filter(MatrixFilters.HiSatch);
                    break;

                case "losatch":
                    imageToAdjust.Filter(MatrixFilters.LoSatch);
                    break;
                }

                break;

            case "flip":
                imageToAdjust.Flip(flipVertically: value == "vertical", flipBoth: value == "both");
                break;

            case "rotate":
                imageToAdjust.Rotate(int.Parse(value));
                break;
            }
        }