コード例 #1
0
        private void RunShaderButton_Click(object sender, EventArgs e)
        {
            switch (shadersComboBox.SelectedIndex)
            {
            case 0:
                return;

            case 1:
                ResetShading();

                sw = Stopwatch.StartNew();
                VerticesAverageBrightnessShader.Run(rebuiltImageBitmap, trianglesHashSet);
                sw.Stop();
                label10.Text = sw.ElapsedMilliseconds.ToString();
                rebuiltImagePictureBox.Image = rebuiltImageBitmap;

                standartDeviationLabel.Text = StandartDeviation.Run(sourceImageBitmap, rebuiltImageBitmap).ToString();

                // Выставляем элементы формы
                showHideImageGroupBox.Enabled         = true;
                showHidePPointsGroupBox.Enabled       = true;
                showHideGridGroupBox.Enabled          = true;
                pPointsControlsGroupBox.Enabled       = true;
                triangulationControlsGroupBox.Enabled = true;
                saveInPngButton.Enabled = true;
                saveInTButton.Enabled   = true;
                return;

            case 2:
                ResetShading();

                sw = Stopwatch.StartNew();

                TriangleGradientShader shader = new TriangleGradientShader(rebuiltImageBitmap, trianglesHashSet);
                shader.Run();

                sw.Stop();
                label10.Text = sw.ElapsedMilliseconds.ToString();
                rebuiltImagePictureBox.Image = rebuiltImageBitmap;

                standartDeviationLabel.Text = StandartDeviation.Run(sourceImageBitmap, rebuiltImageBitmap).ToString();

                // Выставляем элементы формы
                showHideImageGroupBox.Enabled         = true;
                showHidePPointsGroupBox.Enabled       = true;
                showHideGridGroupBox.Enabled          = true;
                pPointsControlsGroupBox.Enabled       = true;
                triangulationControlsGroupBox.Enabled = true;
                saveInPngButton.Enabled = true;
                saveInTButton.Enabled   = true;

                // Код для записи в файл
                //using (StreamWriter SKOFile = new StreamWriter(@"D:\VSProjects\image-triangulation\image-triangulation\SKO.txt", true, System.Text.Encoding.Default))
                //{
                //    SKOFile.WriteLine(standartDeviationLabel.Text);
                //}

                return;
            }
        }
コード例 #2
0
        private void OpenTButton_Click(object sender, EventArgs e)
        {
            if (openTFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            ResetPivotPoints();
            ResetTriangulation();
            ResetShading();

            TExtension.Open(pivotPoints, openTFileDialog.FileName);
            SimpleIterativeTriangulation.Run(pivotPoints, triangulationSectionsList, trianglesHashSet);
            VerticesAverageBrightnessShader.Run(rebuiltImageBitmap, trianglesHashSet);
            rebuiltImagePictureBox.Image = rebuiltImageBitmap;

            // Выставляем элементы формы
            showHideImageGroupBox.Enabled         = false;
            showHidePPointsGroupBox.Enabled       = false;
            showHideGridGroupBox.Enabled          = false;
            pPointsControlsGroupBox.Enabled       = false;
            triangulationControlsGroupBox.Enabled = false;
            shadingControlsGroupBox.Enabled       = false;
            label8.Text  = "";
            label9.Text  = "";
            label10.Text = "";
            label13.Text = pivotPoints.Count.ToString();
            label14.Text = trianglesHashSet.Count.ToString();
            standartDeviationLabel.Text   = "";
            saveInPngButton.Enabled       = true;
            saveInTButton.Enabled         = false;
            originalImagePictureBox.Image = null;
        }