Esempio n. 1
0
        private void GenerateCrop(GeneratorElementConfig config)
        {
            Console.WriteLine("from: " + config.InputFileName() + "\nto: " + config.OutputFileName() + "\nmethod: " + config.MethodName);
            var   image = Image.FromFile(config.InputFilePath);
            Image res   = SeamCarving.CropImage(image, config.ToWidth, config.ToHeight);

            res.Save(config.OutputFilePath(), getImageFormat(config.FileExtension()));
        }
Esempio n. 2
0
        private void GenerateSeamCarving(GeneratorElementConfig config)
        {
            Console.WriteLine("from: " + config.InputFileName() + "\nto: " + config.OutputFileName() + "\nmethod: " + config.MethodName);
            var image = Image.FromFile(config.InputFilePath);

            SeamCarving.LoadImage(new Bitmap(image));
            EnergyFunctionBase energyFunction = GetEnergyFunction(config.MethodName);

            if (config.ChangeWidth)
            {
                SeamCarving.ResizeWidth(energyFunction, image.Size.Width - config.ToWidth);
            }
            else
            {
                SeamCarving.ResizeHeight(energyFunction, image.Size.Height - config.ToHeight);
            }
            Image res = SeamCarving.ToImage();

            res.Save(config.OutputFilePath(), getImageFormat(config.FileExtension()));
        }