예제 #1
0
        private void OpenImageButton_Click(object sender, EventArgs e)
        {
            if (OpenImageDialog.FileName != null && OpenImageDialog.FileName.Length > 0)
            {
                OpenImageDialog.InitialDirectory = System.IO.Path.GetDirectoryName(OpenImageDialog.FileName);
            }

            if (OpenImageDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    SpatialLightModulatorForm.RemoveBitmap("Target");

                    var src = new Bitmap(OpenImageDialog.FileName);

                    Free(Images.InputBitmap);

                    Images.InputBitmap = ConvertTo24bpp(src);

                    Free(src);

                    RenderBitmap(Images.InputBitmap, TargetImage);

                    SpatialLightModulatorForm.AddBitmap("Target", Images.InputBitmap);

                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }
예제 #2
0
        private void CalculateButton_Click(object sender, EventArgs e)
        {
            CalculateButton.Enabled    = false;
            SaveHologramButton.Enabled = false;

            SLM.RemoveBitmap("Computed Hologram");

            PhaseForm.Text = "Computing Hologram ...";

            GerchbergSaxton.CopyParameters(this);

            GetInput();

            GerchbergSaxton.Free(Images.PhaseBitmap);

            Images.PhaseBitmap = GerchbergSaxton.Compute(Target);

            if (Images.PhaseBitmap != null)
            {
                RenderBitmap(ref Images.PhaseBitmap);
                SaveHologramButton.Enabled = true;

                SLM.AddBitmap("Computed Hologram", Images.PhaseBitmap);
            }

            CalculateButton.Enabled = true;
            PhaseForm.Text          = "ImageGS";
        }
예제 #3
0
        public ImageGSForm()
        {
            InitializeComponent();

            Initialize();
            InitializeBitmaps();
            InitializePhaseForm();

            SpatialLightModulator.Initialize();

            SpatialLightModulatorForm = new frmSpatialLightModulator();
            SpatialLightModulatorForm.SetLimits();
            SpatialLightModulatorForm.SetParameters();

            SpatialLightModulatorForm.AddBitmap("Target", Images.InputBitmap);

            GerchbergSaxtonForm = new frmGerchbergSaxton();
            GerchbergSaxtonForm.SetLimits();

            GerchbergSaxtonForm.SetTarget(this, PhaseImage, SpatialLightModulatorForm);
        }