Esempio n. 1
0
        private async void CreateOpacityMap()
        {
            DisableControls(true);
            opacityMapInfoLabel.Visible = true;

            try
            {
                string filePath      = filePathTextBox.Text;
                string resultDirPath = GlobalData.ResultFileDirectory;
                FileDataManager.CreateDirectoryIfNotExists(resultDirPath);

                ArgbProcessor argbProc           = new ArgbProcessor(filePath);
                PacketObjMsg  fileCreationPacket = await argbProc.CreateOpacityMapAndNonTransparentImageTaskStart(resultDirPath);

                bool success = (bool)fileCreationPacket.Obj;

                if (!String.IsNullOrEmpty(fileCreationPacket.Msg))
                {
                    MessageBox.Show(fileCreationPacket.Msg);
                }

                if (success)
                {
                    MessageBox.Show("Pomyślnie utworzono pliki!");
                    Process.Start(resultDirPath);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Błąd tworzenia mapy przezroczystości: {exception.Message}");
            }

            opacityMapInfoLabel.Visible = false;
            DisableControls(false);
        }
        private void SaveResultImage()
        {
            try
            {
                if (this.resultBitmap == null)
                {
                    throw new Exception("nie wygenerowano obrazu (NULL)!");
                }

                string resultDirPath = GlobalData.ResultFileDirectory;
                FileDataManager.CreateDirectoryIfNotExists(resultDirPath);
                string filePath = $"{resultDirPath}\\hairTex_{DateTime.Now.ToString("yyyy_MM_dd_HH-mm-ss")}.png";
                this.resultBitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);

                MessageBox.Show("Pomyślnie zapisano obraz!");
                Process.Start(resultDirPath);
            }
            catch (Exception exception)
            {
                MessageBox.Show($"Błąd zapisu obrazu wynikowego: {exception.Message}");
            }
        }