public void CreateCollage(int columns, int rows)
 {
     DirectoryInfo di = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("~/Content/Images/"));
     DirectoryInfo diroutput = new DirectoryInfo(System.Web.HttpContext.Current.Server.MapPath("~/Content/DoneCollage/"));
     {
         List<FileInfo> files = di.GetFiles().ToList();
         var setting = new CollageSettings(
             new CollageDimensionSettings
             {
                 NumberOfColumns = columns,
                 NumberOfRows = rows,
                 TileScalePercent = new Percentage(100),
                 TileHeight = 50,
                 TileWidth = 50
             },
             new AdditionalCollageSettings
             {
                 CutTileRandomly = false,
                 RotateAndFlipRandomly = false
             },
             files, diroutput);
         var collage = new CollageGenerator(setting);
         collage.Create();
         if (File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Content/DoneCollage/") + "result.jpg"))
         {
             foreach (FileInfo file in di.GetFiles())
             {
                 file.Delete();
             }
         }
     }
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var options = CreateOptions();

            try
            {
                options.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("{0}: ", programName);
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `{0} --help' for more information.", programName);
                return;
            }

            if (showHelp)
            {
                ShowHelp(options);
                return;
            }

            if (!ValidateOptions())
                return;

            var imagesList = new List<FileInfo>();
            imagesList.AddRange(Directory.GetFiles(inputDirectory, "*.jpg").Select(name => new FileInfo(name)));

            if (imagesList.Count == 0)
            {
                var dirInfo = new DirectoryInfo(inputDirectory);
                Console.WriteLine("No images found in {0}.", dirInfo.FullName);
                return;
            }

            Console.WriteLine("Number of images found: {0}", imagesList.Count);

            var collageSettings =
                new CollageSettings(
                    new CollageDimensionSettings
                        {
                            NumberOfColumns = numberOfColums,
                            NumberOfRows = numberOfRows,
                            TileHeight = tileHeight,
                            TileWidth = tileWidth,
                            TileScalePercent = new Percentage(scalePercent)
                        },
                    new AdditionalCollageSettings
                        {
                            RotateAndFlipRandomly = rotateAndFlipRandomly
                        },
                    imagesList,
                    new DirectoryInfo(outputDirectory));

            var collage = new CollageGenerator(collageSettings);

            collage.Create();

            Console.WriteLine("Collage saved");
        }
Exemplo n.º 3
0
        private void CreateCollage(CollageSettings settings)
        {
            this.collage = new CollageGenerator(settings);

            collage.CreateCompleted += this.collage_CreateCompleted;
            collage.CreateProgressChanged += this.collage_CreateProgressChanged;

            collage.CreateAsync();
        }