Exemplo n.º 1
0
 private void button1_Click(object sender, System.EventArgs e)
 {
     new Thread(() =>
     {
         Thread.CurrentThread.IsBackground = true;
         this.Text         = "Tincoder :: STARTING";
         VecInt2 current   = new VecInt2(0, 0);
         List <char> chars = new List <char>();
         while (true)
         {
             Color px = encodedImage.GetPixel(current.Val1, current.Val2);
             if (checkBox1.Checked == false)
             {
                 if (px.A == 0 && px.R == 0 && px.G == 0 && px.B == 0)
                 {
                     break;
                 }
             }
             chars.Add((char)px.A);
             chars.Add((char)px.R);
             chars.Add((char)px.G);
             chars.Add((char)px.B);
             if (checkBox2.Checked && checkBox4.Checked)
             {
                 richTextBox1.Text = string.Join("", chars);
             }
             current.Val1++;
             if (current.Val1 == encodedImage.Width)
             {
                 if (checkBox3.Checked)
                 {
                     this.Text = "Tincoder :: " + current.Val1 + "/" + current.Val2;
                 }
                 if (checkBox2.Checked)
                 {
                     richTextBox1.Text = string.Join("", chars);
                 }
                 current.Val2++;
                 current.Val1 = 1;
                 if (current.Val2 == encodedImage.Height)
                 {
                     break;
                 }
             }
             if (checkBox3.Checked && checkBox4.Checked)
             {
                 this.Text = "Tincoder :: " + current.Val1 + "/" + current.Val2;
             }
         }
         richTextBox1.Text = string.Join("", chars);
         this.Text         = "Tincoder :: DONE";
     }).Start();
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            new Thread(() =>
            {
                Thread.CurrentThread.IsBackground = true;
                encodedImage = new Bitmap(encodedImage, 1, 1);
                encodedImage.SetPixel(0, 0, Color.Transparent);
                encodedImage       = new Bitmap(encodedImage, 1024, 1024);
                button1.Enabled    = false;
                var current        = new VecInt2(0, 0);
                List <string> list = (new List <string>(richTextBox1.Text.SplitInParts(4)));
                Text = "Tincoder :: STARTING";
                foreach (string c in list)
                {
                    List <char> chars = new List <char>(c.ToCharArray());
                    while (chars.Count < 4)
                    {
                        int i = 0;
                        while (i < (5 - chars.Count))
                        {
                            chars.Add('\0');
                            i++;
                        }
                    }
                    List <int> ints = new List <int>();
                    foreach (char a in chars)
                    {
                        ints.Add(MathExtensions.Clamp <int>(Convert.ToInt32(a), 0, 255));
                    }

                    encodedImage.SetPixel(current.Val1, current.Val2, Color.FromArgb(ints[0], ints[1], ints[2], ints[3]));
                    if (checkBox1.Checked && checkBox3.Checked)
                    {
                        pictureBox1.Image = encodedImage;
                        Thread.Sleep(7);
                    }
                    if (checkBox2.Checked && checkBox3.Checked)
                    {
                        Text = "Tincoder :: " + current.Val1 + "/" + current.Val2;
                    }
                    current.Val1++;
                    if (current.Val1 == 1024)
                    {
                        if (checkBox1.Checked)
                        {
                            pictureBox1.Image = encodedImage;
                            Thread.Sleep(7);
                        }
                        if (checkBox2.Checked)
                        {
                            Text = "Tincoder :: " + current.Val1 + "/" + current.Val2;
                        }
                        current.Val2++;
                        current.Val1 = 1;
                        if (current.Val2 == 1024)
                        {
                            break;
                        }
                    }
                }
                //end of list foreach
                pictureBox1.Image = encodedImage;
                Thread.Sleep(7);
                Text            = "Tincoder :: DONE";
                button1.Enabled = true;
            }).Start();
        }