diff --git a/ISCamRecorder/ISCamera.cs b/ISCamRecorder/ISCamera.cs index a3434dd..73ece90 100644 --- a/ISCamRecorder/ISCamera.cs +++ b/ISCamRecorder/ISCamera.cs @@ -62,8 +62,7 @@ // 表示設定 _Cam.LiveDisplayDefault = false; - _Cam.LiveDisplayHeight = _Cam.Height; - _Cam.LiveDisplayWidth = _Cam.Width; + SetDisplaySize(); // ic.ImageRingBufferSize = 2; _Trigger = _Cam.VCDPropertyItems.Find( VCDGUIDs.VCDID_TriggerMode, VCDGUIDs.VCDElement_SoftwareTrigger); @@ -75,6 +74,28 @@ } /// + /// 表示サイズ設定 + /// + public void SetDisplaySize() { + if (!_Cam.DeviceValid) return; + + var vf = _Cam.VideoFormatCurrent; + if (vf.Height * _Cam.Width < vf.Width * _Cam.Height) { + _Cam.LiveDisplayLeft = 0; + _Cam.LiveDisplayWidth = _Cam.Width; + var h = vf.Height * _Cam.Width / vf.Width; + _Cam.LiveDisplayTop = (_Cam.Height - h) / 2; + _Cam.LiveDisplayHeight = h; + } else { + _Cam.LiveDisplayTop = 0; + _Cam.LiveDisplayHeight = _Cam.Width; + var w = vf.Width * _Cam.Height / vf.Height; + _Cam.LiveDisplayLeft = (_Cam.Width - w) / 2; + _Cam.LiveDisplayWidth = w; + } + } + + /// /// フレーム取得時 /// /// diff --git a/ISCamRecorder/MainForm.Designer.cs b/ISCamRecorder/MainForm.Designer.cs index e35aef1..f02d6b1 100644 --- a/ISCamRecorder/MainForm.Designer.cs +++ b/ISCamRecorder/MainForm.Designer.cs @@ -132,6 +132,8 @@ // // TxtTop // + this.TxtTop.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.TxtTop.Location = new System.Drawing.Point(4, 3); this.TxtTop.Name = "TxtTop"; this.TxtTop.ReadOnly = true; @@ -173,6 +175,8 @@ // // TxtLeft // + this.TxtLeft.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.TxtLeft.Location = new System.Drawing.Point(3, 3); this.TxtLeft.Name = "TxtLeft"; this.TxtLeft.ReadOnly = true; @@ -215,6 +219,8 @@ // // TxtFront // + this.TxtFront.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.TxtFront.Location = new System.Drawing.Point(3, 3); this.TxtFront.Name = "TxtFront"; this.TxtFront.ReadOnly = true; @@ -238,6 +244,8 @@ // // TxtRight // + this.TxtRight.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.TxtRight.Location = new System.Drawing.Point(1, 3); this.TxtRight.Name = "TxtRight"; this.TxtRight.ReadOnly = true; @@ -271,6 +279,7 @@ this.Text = "マルチカメラ撮影ソフトウェア by フロンティア医工学センター"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing); this.Load += new System.EventHandler(this.MainForm_Load); + this.SizeChanged += new System.EventHandler(this.MainForm_SizeChanged); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); diff --git a/ISCamRecorder/MainForm.cs b/ISCamRecorder/MainForm.cs index 161b628..ea29953 100644 --- a/ISCamRecorder/MainForm.cs +++ b/ISCamRecorder/MainForm.cs @@ -104,5 +104,14 @@ private void ChkTrigger_CheckedChanged(object sender, EventArgs e) { _Cameras.ForEach(c => c.SetTriggerMode(((CheckBox)sender).Checked)); } + + /// + /// サイズ変更時 + /// + /// + /// + private void MainForm_SizeChanged(object sender, EventArgs e) { + _Cameras.ForEach(c => c.SetDisplaySize()); + } } }