Beispiel #1
0
 private void RegenerateImage()
 {
     if (_displayingContent != null)
     {
         _converter = new HexagonConverter((float)numericUpDownRadius.Value);
         var bitmap = _converter.GenerateBitmap(_displayingContent);
         SetImage(BitmapHelper.AddBorder(bitmap, 10));
     }
     else
     {
         MessageBox.Show("Content Null");
     }
 }
Beispiel #2
0
        private void buttonParse_Click(object sender, EventArgs e)
        {
            try
            {
                //var b = (Bitmap) Image.FromFile("image.jpg");
                var b = _converter.GenerateBitmap(textBox1.Text);

                this.Text = "Finished Reading Image";
                Application.DoEvents();

                b = BitmapHelper.SplitColors(b, 0.7f);

                this.Text = "Finished Spliting Colors";
                Application.DoEvents();

                b = BitmapHelper.TrimToBlack(b);

                this.Text = "Finished Trimming To Black";
                Application.DoEvents();

                b = BitmapHelper.AddBorder(b, 3);

                this.Text = "Finished Adding Border";
                Application.DoEvents();

                var radius = HexagonConverter.GetHexagonRadiusFromImage(b, 0f);

                this.Text = "Finished Getting Radius";
                Application.DoEvents();

                try
                {
                    var converter  = new HexagonConverter(radius);
                    var parsedData = converter.ParseCorrectBitmap(b);
                    textBox2.Text = parsedData;
                    this.Text     = "Finished Parsing";
                    Application.DoEvents();
                }
                catch (IndexOutOfRangeException exception)
                {
                    this.Text = "Error parsing Image: " + exception.Message;
                    Application.DoEvents();
                }

                SetImage(b);
            }
            catch (IndexOutOfRangeException exception)
            {
            }
        }
Beispiel #3
0
        void ProcessImage()
        {
            richTextBoxLog.Clear();

            if (_loadedBitmap == null)
            {
                richTextBoxLog.AppendText("Image Is Not Loaded\n");
                Application.DoEvents();
                return;
            }

            richTextBoxLog.AppendText("Clonning Original Bitmap\n");
            Application.DoEvents();

            var b = BitmapHelper.CloneBitmap(_loadedBitmap);

            var splitCoefficient = (float)numericUpDownSplitColorCoefficient.Value / 1000f;

            richTextBoxLog.AppendText("Splitting Color\n");
            Application.DoEvents();
            b = BitmapHelper.SplitColors(b, splitCoefficient);
            if (_finishAtSplitColor)
            {
                goto FINISH;
            }

            richTextBoxLog.AppendText("Trimming To Black\n");
            Application.DoEvents();
            b = BitmapHelper.TrimToBlack(b);
            if (_finishAtTrimBlack)
            {
                goto FINISH;
            }

            richTextBoxLog.AppendText("Adding Border\n");
            Application.DoEvents();
            b = BitmapHelper.AddBorder(b, (int)numericUpDownBorderSize.Value);
            if (_finishAtAddBorder)
            {
                goto FINISH;
            }

            richTextBoxLog.AppendText("Getting Hexagon Radius\n");
            Application.DoEvents();
            var radius = HexagonConverter.GetHexagonRadiusFromImage(b, 0f);

            richTextBoxLog.AppendText("Hexagon Radius = " + radius + "\n");
            Application.DoEvents();
            if (_finishAtGetHexagonRadius)
            {
                goto FINISH;
            }

            try
            {
                var content = new HexagonConverter(radius, 0f).ParseCorrectBitmap(b);
                _lastParsedContent = content;
                richTextBoxLog.AppendText("Parsed Successfully:\n" + content + "\n");
                Application.DoEvents();
            }
            catch (Exception e)
            {
                richTextBoxLog.AppendText("Error: " + e.Message + "\n");
                Application.DoEvents();
            }


FINISH:
            richTextBoxLog.AppendText("Finished\n");
            Application.DoEvents();
            SetImage(b);
        }