示例#1
0
        static void Main(string[] args)
        {
            var timer = new Timer();

            using (timer.Run())
            {
                Thread.Sleep(1000);
            }
            Console.WriteLine(timer.ElapsedMilliseconds);

            using (timer.Continue())
            {
                Thread.Sleep(1000);
            }
            Console.WriteLine(timer.ElapsedMilliseconds);

            using (timer.Run())
            {
                Thread.Sleep(1000);
            }
            Console.WriteLine(timer.ElapsedMilliseconds);

            Console.WriteLine(timer.ElapsedTicks);

            var bitmap = (Bitmap)Image.FromFile(@"C:\Users\Anton\Documents\Visual Studio 2015\Projects\Photoshop\cat.jpg");

            using (timer.Run())
            {
                using (var bitmapEditor = new BitmapEditor(bitmap))
                {
                    for (int i = 0; i < bitmap.Width; i++)
                    {
                        for (int j = 0; j < bitmap.Height; j++)
                        {
                            bitmapEditor.SetPixel(i, j, 0, 0, 0);
                        }
                    }
                }
            }
            Console.WriteLine(timer.ElapsedMilliseconds);

            using (timer.Run())
            {
                for (int i = 0; i < bitmap.Width; i++)
                {
                    for (int j = 0; j < bitmap.Height; j++)
                    {
                        bitmap.SetPixel(i, j, Color.White);
                    }
                }
            }
            Console.WriteLine(timer.ElapsedMilliseconds);

            Console.Read();
        }
示例#2
0
        static void Main(string[] args)
        {
            var bitmap = (Bitmap)Bitmap.FromFile(@"..\..\kok.bmp");
            var timer  = new Timer();

            using (timer.StartOver())
            {
                using (var bitmapEditor = new BitmapEditor(bitmap))
                {
                    for (int i = 20; i < 80; i++)
                    {
                        for (int j = 0; j < 5; j++)
                        {
                            bitmapEditor.SetPixel(i, 20 + j, 102, 182, 32);
                        }
                    }
                }
            }
            Console.WriteLine(timer.ElapsedMilliseconds);
            Console.WriteLine(timer.ElapsedTicks);
            using (timer.Continue())
            {
                using (var bitmapEditor = new BitmapEditor(bitmap))
                {
                    for (int i = 20; i < 80; i++)
                    {
                        for (int j = 0; j < 5; j++)
                        {
                            bitmapEditor.SetPixel(i, 40 + j, 35, 11, 232);
                        }
                    }
                }
            }
            Console.WriteLine(timer.ElapsedMilliseconds);
            Console.WriteLine(timer.ElapsedTicks);
            bitmap.Save(@"..\..\image2.png", ImageFormat.Png);
        }
示例#3
0
        static void Main(string[] args)
        {
            //Tes();

            var bitmap = (Bitmap)Image.FromFile("1000x1000.bmp");
            var timer  = new Timer();

            using (timer.StartTimer())
            {
                for (int x = 0; x < 1000; x++)
                {
                    for (int y = 0; y < 1000; y++)
                    {
                        bitmap.SetPixel(x, y, Color.BurlyWood);
                    }
                }
            }
            Console.WriteLine(timer.ElapsedMilliseconds);             //986

            using (timer.StartTimer())
            {
                using (var bitmapEditor = new BitmapEditor(bitmap))
                {
                    for (int x = 0; x < 1000; x++)
                    {
                        for (int y = 0; y < 1000; y++)
                        {
                            bitmapEditor.SetPixel(x, y, (byte)(255 - x / 4), (byte)(y / 4), (byte)(x / 8 + y / 8));
                        }
                    }
                }
            }
            Console.WriteLine(timer.ElapsedMilliseconds);             //49

            Console.ReadKey();
        }