예제 #1
0
        static void Main(string[] args)
        {
            string left = args[0];
              string right = args[1];
              string diff = args[2];

              int iterationCount = int.Parse(args[3]);

              FileStream leftStream = File.OpenRead(left);
              FileStream rightStream = File.OpenRead(right);

              Bitmap leftImg = new Bitmap(leftStream);
              Bitmap rightImg = new Bitmap(rightStream);

              DiffResult result = new DiffResult();
              Stopwatch perf = new Stopwatch();
              perf.Start();
              for (int i = 0; i < iterationCount; i++)
              {
            result.Dispose();
            result = ImageDiff.Binding.Diff(leftImg, rightImg,
              new DiffOptions()
              {
            ErrorColor = Color.FromArgb(255, 255, 0, 255),
            Tolerance = 0.15f,
            OverlayTransparency = 1.0f,
            OverlayType = OverlayType.Movement,
            WeightByDiffPercentage = false,
            IgnoreColor = false
              });
              }
              perf.Stop();
              double msPerIter = (double)perf.ElapsedMilliseconds / iterationCount;
              Console.WriteLine(msPerIter + " ms per iteration.");
              double msPerPixel = msPerIter / (result.Image.Width * result.Image.Height);
              Console.WriteLine(msPerPixel * 1000 + " ns per pixel.");
              result.Image.Save(diff);
              result.Dispose();
        }
예제 #2
0
        public static DiffResult Diff(Bitmap left, Bitmap right, DiffOptions options)
        {
            DiffResult result = new DiffResult();

              NativeDiffResult nr = DiffARGB(left.nativeImage, right.nativeImage, NativeDiffOptions.FromManaged(options));

              result.Similarity = nr.Similarity;
              result.Image = new Bitmap(nr.Image.Width, nr.Image.Height, nr.Image.Data);
              return result;
        }