private static Image CreateBackdrop(IndexViewModel model)
        {
            var backdrop = new Backdrop(Image.FromStream(model.InputImage.InputStream), model.ToBackdropSettings());

            if (model.AddDominantColorsOverlay)
            {
                AddDominantColorsOverlay(backdrop);
            }

            return backdrop.Image;
        }
Esempio n. 2
0
        private static void CreateBackdrop(ProgramOptions programOptions)
        {
            var imagePath = programOptions.InputFile;

            var backdrop = new Backdrop(Image.FromFile(imagePath, false), programOptions.ToBackdropSettings());

            if (programOptions.AddDominantColorsOverlay)
            {
                AddDominantColorsOverlay(backdrop);
            }

            backdrop.Image.Save(programOptions.DefinitiveOutputFile, programOptions.OutputImageFormat.ToImageFormat());
        }
Esempio n. 3
0
        private static void AddDominantColorsOverlay(Backdrop backdrop)
        {
            var boxWidth = (int)((float)backdrop.Image.Width / backdrop.DominantColors.Count());
            var boxHeight = (int)(boxWidth * 0.2);
            var boxSize = new Size(boxWidth, boxHeight);

            for (var i = 0; i < backdrop.DominantColors.Count; ++i)
            {
                using (var coloredBoxGraphics = Graphics.FromImage(backdrop.Image))
                using (var solidBrush = new SolidBrush(backdrop.DominantColors[i]))
                {
                    coloredBoxGraphics.FillRectangle(solidBrush, new Rectangle(new Point(i * boxWidth, backdrop.Image.Height - boxHeight), boxSize));
                }
            }
        }