Exemple #1
0
 private static void Pixelate(Options options)
 {
     var stopwatch = new Stopwatch();
     //stopwatch.Start();
     //using (var image = Bitmap.FromFile(options.ImagePath))
     //{
     //    Console.WriteLine(string.Format("Image size: {0}x{1}", image.Width, image.Height));
     //    Console.WriteLine("Pixel size: {0}\n", options.PixelSize);
     //    Console.WriteLine("Starting normal...");
     //    using (var bitmap = new Bitmap(image))
     //    {
     //        var result = Pixelate(bitmap, options.PixelSize);
     //        result.Save(options.ResultPath);
     //    }
     //}
     //stopwatch.Stop();
     //Console.WriteLine("Done in: \"{0}\".\n", stopwatch.Elapsed.ToString("c"));
     //stopwatch.Reset();
     //Console.WriteLine("Starting using lockbits...");
     //stopwatch.Start();
     //using (var image = Bitmap.FromFile(options.ImagePath))
     //using (var bitmap = new Bitmap(image))
     //{
     //    var result = PixelateLockBits(bitmap, options.PixelSize);
     //    result.Save(options.ResultPath);
     //}
     //stopwatch.Stop();
     //Console.WriteLine("Done in: \"{0}\".\n", stopwatch.Elapsed.ToString("c"));
     //stopwatch.Reset();
     Console.WriteLine("Starting using lockbits parallel...");
     stopwatch.Start();
     using (var image = Bitmap.FromFile(options.ImagePath))
     using (var bitmap = new Bitmap(image))
     {
         var result = PixelateLockBitsParallel(bitmap, options.PixelSize);
         result.Save(options.ResultPath);
     }
     stopwatch.Stop();
     Console.WriteLine("Done in: \"{0}\".\n", stopwatch.Elapsed.ToString("c"));
     Console.WriteLine("Press any key to continue...");
     Console.ReadKey();
 }
Exemple #2
0
 private static Options ParseArguments(string[] args)
 {
     var options = new Options();
     Parser.Default.ParseArgumentsStrict(args, options);
     return options;
 }