Exemplo n.º 1
0
        /// <summary>
        /// Performs the Alpha method from the ImageProcessor library.
        /// </summary>
        /// <param name="image">The image with which to apply the effect.</param>
        /// <param name="percentage">The amount of transparency as a percentage.</param>
        /// <returns>A new image with the Alpha effect applied.</returns>
        public Image Alpha(Image image, int percentage)
        {
            using var factory = new ImageFactory();

            factory.Load(image);
            factory.Alpha(percentage);

            var result = factory.Image;

            return(new Bitmap(result));
        }
Exemplo n.º 2
0
 public IImageTransformer Alpha(int percentage)
 {
     _image.Alpha(percentage);
     return(this);
 }
Exemplo n.º 3
0
        public static void Process(ref byte[] buffer, Dictionary <string, double> edits)
        {
            using (var inputStream = new MemoryStream(buffer))
            {
                using (var outputStream = new MemoryStream())
                {
                    using (var factory = new ImageFactory())
                    {
                        factory.Load(inputStream);

                        foreach (var edit in edits)
                        {
                            switch (edit.Key)
                            {
                            case "Alpha":
                            {
                                factory.Alpha((int)edit.Value);
                                break;
                            }

                            case "Contrast":
                            {
                                factory.Contrast((int)edit.Value);
                                break;
                            }

                            case "Exposure":
                            {
                                factory.Brightness((int)edit.Value);
                                break;
                            }

                            case "Flip":
                            {
                                var flipVertical = edit.Value == 1;
                                factory.Flip(flipVertical);
                                break;
                            }

                            case "Pixelate":
                            {
                                factory.Pixelate((int)edit.Value);
                                break;
                            }

                            case "Quality":
                            {
                                factory.Quality((int)edit.Value);
                                break;
                            }

                            case "Rotate":
                            {
                                factory.Rotate((int)edit.Value);
                                break;
                            }

                            case "Rounded":
                            {
                                factory.RoundedCorners((int)edit.Value);
                                break;
                            }

                            case "Saturation":
                            {
                                factory.Saturation((int)edit.Value);
                                break;
                            }
                            }
                        }

                        factory.Save(outputStream);

                        var length = (int)outputStream.Length;

                        buffer = new byte[length];

                        outputStream.Read(buffer, 0, length);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public override void Apply(ImageFactory fs)
 {
     fs = fs.Alpha(percentage);
 }