Exemplo n.º 1
0
        static int CalculateDarkness(char a)
        {
            int wid = 12;

            for (int i = 0; i < wid / 2; i++)
            {
                Console.SetCursorPosition(0, 10 + i);
                Console.Write("".PadLeft(wid, a));
            }

            PrintScreen ps = new PrintScreen();
            Image       im = ps.CaptureScreen();
            double      summLeft = 0, summRight = 0;

            using (Bitmap bit = (Bitmap)im)
            {
                for (int i = 40; i < 80; i++)
                {
                    for (int j = 150; j < 190; j++)
                    {
                        summLeft += (bit.GetPixel(i, j).R + bit.GetPixel(i, j).G + bit.GetPixel(i, j).B) * 2 / (3.0 * 40 * 40);
                        bit.SetPixel(i, j, Color.Red);
                    }
                }
            }
            return((int)summLeft);
        }
Exemplo n.º 2
0
        static Color CalculateColor(char a)
        {
            int wid = 12;

            for (int i = 0; i < wid / 2; i++)
            {
                Console.SetCursorPosition(0, 10 + i);
                Console.Write("".PadLeft(wid, a));
            }
            PrintScreen ps = new PrintScreen();
            Image       im = ps.CaptureScreen();
            double      R = 0, G = 0, B = 0;

            using (Bitmap bit = (Bitmap)im)
            {
                for (int i = 40; i < 80; i++)
                {
                    for (int j = 150; j < 190; j++)
                    {
                        //summLeft += (bit.GetPixel(i, j).R + bit.GetPixel(i, j).G + bit.GetPixel(i, j).B) * 2 / (3.0 * 40 * 40);
                        //bit.SetPixel(i, j, Color.Red);
                        R += bit.GetPixel(i, j).R / 1600.0;
                        G += bit.GetPixel(i, j).G / 1600.0;
                        B += bit.GetPixel(i, j).B / 1600.0;
                    }
                }
            }
            return(Color.FromArgb(Math.Min(255, (int)R), Math.Min(255, (int)G), Math.Min(255, (int)B)));
        }
Exemplo n.º 3
0
        static int Compare(char a, char b)
        {
            int wid = 80;

            for (int i = 0; i < wid / 2; i++)
            {
                Console.SetCursorPosition(0, 10 + i);
                Console.Write("".PadLeft(wid, a));
            }
            for (int i = 0; i < wid / 2; i++)
            {
                Console.SetCursorPosition(wid, 10 + i);
                Console.Write("".PadLeft(wid, b));
            }
            //ConsoleKey k = ConsoleKey.DownArrow;
            //while (k != ConsoleKey.LeftArrow && k != ConsoleKey.RightArrow && k != ConsoleKey.UpArrow)
            //{
            //    k = Console.ReadKey().Key;
            //}
            //Print();


            DirectoryInfo di = new DirectoryInfo("C:\\ss");

            if (!di.Exists)
            {
                di.Create();
            }

            PrintScreen ps = new PrintScreen();
            Image       im = ps.CaptureScreen();
            double      summLeft = 0, summRight = 0;

            using (Bitmap bit = (Bitmap)im)
            {
                for (int i = 90; i < 500; i++)
                {
                    for (int j = 300; j < 400; j++)
                    {
                        summLeft += (bit.GetPixel(i, j).R + bit.GetPixel(i, j).G + bit.GetPixel(i, j).B) / 755.0;
                    }
                }
                for (int i = 790; i < 1200; i++)
                {
                    for (int j = 300; j < 400; j++)
                    {
                        summRight += (bit.GetPixel(i, j).R + bit.GetPixel(i, j).G + bit.GetPixel(i, j).B) / 755.0;
                    }
                }
                //bit.Save("pk.png");
            }
            Print();
            if (summLeft > summRight)
            {
                return(1);
            }
            if (summRight > summLeft)
            {
                return(-1);
            }
            return(0);
            //if (k == ConsoleKey.LeftArrow)
            //    return 1;
            //if (k == ConsoleKey.RightArrow)
            //    return -1;
            ////
            ////
            //return 0;
        }