What I think to be the filled in white squares (Destiny)

by specops115, Thursday, May 01, 2014, 19:44 (3867 days ago) @ specops115



namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private Bitmap err,clean,prize;
        public Form1()
        {
            InitializeComponent();
            this.MouseClick += Mouse_Click;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int[,] toSolve = new int[,] { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 49, 64, 81, 81, 16, 1, 36, 0, 0 }, { 0, 0, 16, 36, 36, 9, 49, 0, 0, 0, 0 }, { 0, 0, 4, 64, 0, 4, 9, 16, 25, 0, 0 }, { 0, 0, 1, 25, 1, 81, 9, 4, 4, 0, 0 }, { 0, 0, 1, 4, 9, 25, 16, 36, 49, 0, 0 }, { 0, 0, 64, 81, 9, 36, 0, 49, 0, 0, 0 }, { 0, 0, 25, 49, 16, 1, 25, 64, 1, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };
            int[,] toSolveRt = new int[11,11];
            for (int k = 0; k < 11; k++)
            {
                for (int l = 0; l < 11; l++)
                {
                    toSolveRt[k, l] = (int)Math.Sqrt(toSolve[k, l]);
                }
            }
            arraySolver i = new arraySolver(toSolveRt);
            Console.WriteLine("\n\n\n");
            arraySolver j = new arraySolver(toSolve);


            err = new Bitmap("rx_err_crc_fail.jpg");
            clean = new Bitmap("clear.png");
            prize = new Bitmap("rx_prize.jpg");

            List<colorNote> colors = new List<colorNote>();
            List<Color> matches = new List<Color>();


            matches.AddRange(i.getNotes());
            matches.Add(Color.FromArgb(9, 9, 14));
            matches.AddRange(j.getNotes());


            
            ScanImage(clean, matches);
            ScanImage(prize, matches);
            ScanImage(err, matches);

            matches.Clear();


            
        }

        private void ScanImage(Bitmap b, List<Color> matches)
        {
            int found = 0;
            Color foundColor = Color.Red;
            Color hiddenColor = Color.Black;

            for (int x = 0; x < b.Width; x++)
            {
                int currentColor = (x / 50) % matches.Count;
                for (int y = 0; y < b.Height; y++)
                {
                    Color pixelColor = b.GetPixel(x, y);
                    //colorNote check = new colorNote(pixelColor);
                    //bool didFind = false;
                    //for (int z = 0; z < colors.Count && !didFind; z++)
                    //{
                    //    if (colors[z].doesEqual(check))
                    //    {
                    //        colors[z].addOne();
                    //        didFind = true;
                    //    }
                    //}
                    //if (!didFind)
                    //{
                    //    colors.Add(check);
                    //}
                    if (matches.Contains(pixelColor))//b.GetPixel(x, y) == Color.FromArgb(19,33,49))//21, 26, 34))
                    {
                        found++;
                        //Console.WriteLine(b.GetPixel(x, y).R + "   " + b.GetPixel(x, y).G + " " + b.GetPixel(x, y).B);
                        b.SetPixel(x, y, foundColor);
                    }
                    else
                    {
                        //Console.WriteLine(b.GetPixel(x, y).R + "   " + b.GetPixel(x, y).G + " " + b.GetPixel(x, y).B);
                        //b.SetPixel(x, y, hiddenColor);
                    }
                }
            }
            Console.WriteLine(found);
            //foreach (colorNote g in colors)
            //{
            //    if (g.count > 300)
            //    {
            //        g.print();
            //    }
            //}
            pictureBox1.Image = b;
        }

        private void Mouse_Click(object sender, EventArgs e)
        {
            Point test = pictureBox1.PointToClient(Control.MousePosition);
            PrintColorAt(test);
            
            
        }

        private void PrintColorAt(Point p)
        {
            int x = p.X;
            int y = p.Y;
            Color c = clean.GetPixel(x, y);
            Console.WriteLine(c.R + " " + c.G + " " + c.B + " " + c.A);
        }

        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            Point test = pictureBox1.PointToClient(Control.MousePosition);
            PrintColorAt(test);
        }
    }

    public class colorNote
    {
        public Color c;
        public int count = 0;

        public colorNote(Color x)
        {
            c = x;
            count = 1;
        }

        public bool doesEqual(colorNote t)
        {
            return t.c == c;
        }

        public void addOne()
        {
            count++;
        }

        public void print()
        {
            Console.WriteLine("Color: ( " + c.R + ", " + c.G + ", " + c.B + " ) + " + count);
        }
    }

    public class arraySolver
    {
        int[,] toKeep;
        public arraySolver(int[,] toSolve)
        {
            for (int x = 2; x < 9; x++)
            {
                for (int y = 2; y < 9; y++)
                {
                    int curVal = toSolve[x,y];
                    int min = Math.Min(x, y);
                    //Console.Write(" X,Y: " + x + "  " + y + "   (" + (x - min) + ", " + (y - min) + ")    (");
                    toSolve[x - min, y - min] += curVal;
                    min = Math.Min(x, 10 - y);
                    //Console.Write((x - min) + ", " + (y + min) + ")    (");
                    toSolve[x - min, y + min] += curVal;
                    min = Math.Min(10 - x, y);
                    //Console.Write((x + min) + ", " + (y - min) + ")    (");
                    toSolve[x + min, y - min] += curVal;
                    min = Math.Min(10 - x, 10 - y);
                    //Console.WriteLine((x + min) + ", " + (y + min) + ")   ");
                    toSolve[x + min, y + min] += curVal;
                    
                }
            }


            for (int y = 0; y < 11; y++)
            {
                for (int x = 0; x < 11; x++)
                {
                    Console.Write(toSolve[y,x].ToString().PadLeft(3,'0') + "    ");
                }
                Console.WriteLine();
            }

            toKeep = toSolve;
        }

        public List<Color> getNotes()
        {
            List<Color> toRet = new List<Color>();
            Color temp = Color.FromArgb(toKeep[0, 0], toKeep[1, 0], toKeep[2, 0]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));

            temp = Color.FromArgb(toKeep[0,2], toKeep[0,3], toKeep[0,4]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));


            temp = Color.FromArgb(toKeep[0,6], toKeep[0,7], toKeep[0,8]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));

            temp = Color.FromArgb(toKeep[0, 10], toKeep[1, 10], toKeep[2, 10]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));

            temp = Color.FromArgb(toKeep[4, 10], toKeep[5, 10], toKeep[6, 10]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));

            temp = Color.FromArgb(toKeep[8, 10], toKeep[9, 10], toKeep[10, 10]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));

            temp = Color.FromArgb(toKeep[10, 6], toKeep[10, 7], toKeep[10, 8]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));

            temp = Color.FromArgb(toKeep[10, 2], toKeep[10, 3], toKeep[10, 4]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));

            temp = Color.FromArgb(toKeep[8, 0], toKeep[9, 0], toKeep[10, 0]);
            toRet.Add(temp);
            toRet.Add(Color.FromArgb(temp.B, temp.G, temp.R));
            toRet.Add(Color.FromArgb(temp.R, temp.B, temp.G));
            toRet.Add(Color.FromArgb(temp.B, temp.R, temp.G));
            toRet.Add(Color.FromArgb(temp.G, temp.R, temp.B));
            toRet.Add(Color.FromArgb(temp.G, temp.B, temp.R));

            return toRet;

            
        }
    }
}



Complete thread:

 RSS Feed of thread