none
如何將CCD的畫面存在另一個Picturebox上 RRS feed

所有回覆

  • 利用 pictureBox1.Image.Save("FilePath to Save") 方法就可以把圖片儲存到檔案路徑...

     

    再利用 pictureBox2.Image = Image.FromFile("FilePath to Load") 就可以讀取圖片檔案指定到 pictureBox 上顯示...

     

     

     

    2007年10月23日 下午 03:12
  • 哪如果我現在要存成BMP要存成陣列來處理要怎麼做呢?

    我這樣run出現"錯誤 1 無法將方法群組 'Save' 轉換為非委派型別 'System.Drawing.Bitmap'。您是否想要叫用這個方法?"

    紅色字的地方

    程式碼如下:

     

     

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;

    namespace Webcam_Test
    {
     /// <summary>
     /// Summary description for Form1.
     /// </summary>
     public class Form1 : System.Windows.Forms.Form
     {
      private WebCam_Capture.WebCamCapture UserControl1;
      private WebCam_Capture.WebCamCapture WebCamCapture;
      private System.Windows.Forms.PictureBox pictureBox1;
      private System.Windows.Forms.Button cmdStart;
      private System.Windows.Forms.Button cmdStop;
      private System.Windows.Forms.Button cmdContinue;
      private System.Windows.Forms.NumericUpDown numCaptureTime;
      private System.Windows.Forms.Label label1;
            private PictureBox pictureBox2;
            private Button button1;

      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.ComponentModel.Container components = null;

      public Form1()
      {
       //
       // Required for Windows Form Designer support
       //
       InitializeComponent();

       //
       // TODO: Add any constructor code after InitializeComponent call
       //
      }

      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      protected override void Dispose( bool disposing )
      {
       if( disposing )
       {
        if (components != null)
        {
         components.Dispose();
        }
       }
       base.Dispose( disposing );
      }

      #region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
                this.WebCamCapture = new WebCam_Capture.WebCamCapture();
                this.pictureBox1 = new System.Windows.Forms.PictureBox();
                this.cmdStart = new System.Windows.Forms.Button();
                this.cmdStop = new System.Windows.Forms.Button();
                this.cmdContinue = new System.Windows.Forms.Button();
                this.numCaptureTime = new System.Windows.Forms.NumericUpDown();
                this.label1 = new System.Windows.Forms.Label();
                this.pictureBox2 = new System.Windows.Forms.PictureBox();
                this.button1 = new System.Windows.Forms.Button();
                ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.numCaptureTime)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
                this.SuspendLayout();
                //
                // WebCamCapture
                //
                this.WebCamCapture.CaptureHeight = 240;
                this.WebCamCapture.CaptureWidth = 320;
                this.WebCamCapture.FrameNumber = ((ulong)(0ul));
                this.WebCamCapture.Location = new System.Drawing.Point(17, 17);
                this.WebCamCapture.Name = "WebCamCapture";
                this.WebCamCapture.Size = new System.Drawing.Size(342, 252);
                this.WebCamCapture.TabIndex = 0;
                this.WebCamCapture.TimeToCapture_milliseconds = 100;
                this.WebCamCapture.ImageCaptured += new WebCam_Capture.WebCamCapture.WebCamEventHandler(this.WebCamCapture_ImageCaptured);
                //
                // pictureBox1
                //
                this.pictureBox1.Location = new System.Drawing.Point(6, 7);
                this.pictureBox1.Name = "pictureBox1";
                this.pictureBox1.Size = new System.Drawing.Size(320, 277);
                this.pictureBox1.TabIndex = 0;
                this.pictureBox1.TabStop = false;
                this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
                //
                // cmdStart
                //
                this.cmdStart.Location = new System.Drawing.Point(6, 305);
                this.cmdStart.Name = "cmdStart";
                this.cmdStart.Size = new System.Drawing.Size(78, 27);
                this.cmdStart.TabIndex = 1;
                this.cmdStart.Text = "Start";
                this.cmdStart.Click += new System.EventHandler(this.cmdStart_Click);
                //
                // cmdStop
                //
                this.cmdStop.Location = new System.Drawing.Point(102, 305);
                this.cmdStop.Name = "cmdStop";
                this.cmdStop.Size = new System.Drawing.Size(78, 27);
                this.cmdStop.TabIndex = 2;
                this.cmdStop.Text = "Stop";
                this.cmdStop.Click += new System.EventHandler(this.cmdStop_Click);
                //
                // cmdContinue
                //
                this.cmdContinue.Location = new System.Drawing.Point(198, 305);
                this.cmdContinue.Name = "cmdContinue";
                this.cmdContinue.Size = new System.Drawing.Size(78, 27);
                this.cmdContinue.TabIndex = 3;
                this.cmdContinue.Text = "Continue";
                this.cmdContinue.Click += new System.EventHandler(this.cmdContinue_Click);
                //
                // numCaptureTime
                //
                this.numCaptureTime.Location = new System.Drawing.Point(162, 353);
                this.numCaptureTime.Maximum = new decimal(new int[] {
                32000,
                0,
                0,
                0});
                this.numCaptureTime.Minimum = new decimal(new int[] {
                1,
                0,
                0,
                0});
                this.numCaptureTime.Name = "numCaptureTime";
                this.numCaptureTime.Size = new System.Drawing.Size(66, 22);
                this.numCaptureTime.TabIndex = 4;
                this.numCaptureTime.Value = new decimal(new int[] {
                20,
                0,
                0,
                0});
                this.numCaptureTime.ValueChanged += new System.EventHandler(this.numCaptureTime_ValueChanged);
                //
                // label1
                //
                this.label1.Location = new System.Drawing.Point(6, 360);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(150, 21);
                this.label1.TabIndex = 5;
                this.label1.Text = "Capture Time (Milliseconds)";
                this.label1.Click += new System.EventHandler(this.label1_Click);
                //
                // pictureBox2
                //
                this.pictureBox2.Location = new System.Drawing.Point(345, 7);
                this.pictureBox2.Name = "pictureBox2";
                this.pictureBox2.Size = new System.Drawing.Size(323, 277);
                this.pictureBox2.TabIndex = 6;
                this.pictureBox2.TabStop = false;
                this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
                //
                // button1
                //
                this.button1.Location = new System.Drawing.Point(300, 305);
                this.button1.Name = "button1";
                this.button1.Size = new System.Drawing.Size(84, 27);
                this.button1.TabIndex = 7;
                this.button1.Text = "display";
                this.button1.UseVisualStyleBackColor = true;
                this.button1.Click += new System.EventHandler(this.button1_Click);
                //
                // Form1
                //
                this.AutoScaleBaseSize = new System.Drawing.Size(5, 15);
                this.ClientSize = new System.Drawing.Size(692, 386);
                this.Controls.Add(this.button1);
                this.Controls.Add(this.pictureBox2);
                this.Controls.Add(this.label1);
                this.Controls.Add(this.numCaptureTime);
                this.Controls.Add(this.cmdContinue);
                this.Controls.Add(this.cmdStop);
                this.Controls.Add(this.cmdStart);
                this.Controls.Add(this.pictureBox1);
                this.Name = "Form1";
                this.Text = "WebCam Capture";
                this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
                this.Load += new System.EventHandler(this.Form1_Load);
                ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.numCaptureTime)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
                this.ResumeLayout(false);

      }
      #endregion

      /// <summary>
      /// The main entry point for the application.
      /// </summary>
      [STAThread]
      static void Main()
      {
       Application.Run(new Form1());
      }

      private void Form1_Load(object sender, System.EventArgs e)
      {
       // set the image capture size
       this.WebCamCapture.CaptureHeight = this.pictureBox1.Height;
       this.WebCamCapture.CaptureWidth = this.pictureBox1.Width;
      }

      private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
      {
       // stop the video capture
       this.WebCamCapture.Stop();
      }

      /// <summary>
      /// An image was capture
      /// </summary>
      /// <param name="source">control raising the event</param>
      /// <param name="e">WebCamEventArgs</param>
      private void WebCamCapture_ImageCaptured(object source, WebCam_Capture.WebcamEventArgs e)
      {
       // set the picturebox picture
       this.pictureBox1.Image = e.WebCamImage;
      }

      private void cmdStart_Click(object sender, System.EventArgs e)
      {
       
                // change the capture time frame
       this.WebCamCapture.TimeToCapture_milliseconds = (int) this.numCaptureTime.Value;

       // start the video capture. let the control handle the
       // frame numbers.
       this.WebCamCapture.Start(0);
              
      }

      private void cmdStop_Click(object sender, System.EventArgs e)
      {
              
                // stop the video capture
       this.WebCamCapture.Stop();
      }

      private void cmdContinue_Click(object sender, System.EventArgs e)
      {
       // change the capture time frame
       this.WebCamCapture.TimeToCapture_milliseconds = (int) this.numCaptureTime.Value;

       // resume the video capture from the stop
       this.WebCamCapture.Start(this.WebCamCapture.FrameNumber);
      }

            private void pictureBox2_Click(object sender, EventArgs e)
            {
              
            }

            private void pictureBox1_Click(object sender, EventArgs e)
            {
              
            }

            private void numCaptureTime_ValueChanged(object sender, EventArgs e)
            {

            }

            private void label1_Click(object sender, EventArgs e)
            {

            }

            private void button1_Click(object sender, EventArgs e)
            {
                Bitmap bmp = pictureBox1.Image.Save;
                pictureBox2.Image = bmp;

                

           }
     }
    }

    2007年10月28日 下午 02:13
  •  

    程式碼區塊
            private void button1_Click(object sender, EventArgs e)
            {
                WebCamCapture.Stop();
                pictureBox2.Image = pictureBox1.Image;
                WebCamCapture.Start(WebCamCapture.FrameNumber);
            }

     

     

    2007年10月28日 下午 02:16
  • 我要把他存成BTMP,就是二維陣列(PS.我要做影像處理的)

    感激~

    2007年10月28日 下午 02:30
  • 程式碼區塊

            private void button1_Click(object sender, EventArgs e)
            {
                WebCamCapture.Stop();
                Bitmap b = new Bitmap(pictureBox1.Image);
                pictureBox2.Image = b;

                WebCamCapture.Start(WebCamCapture.FrameNumber);
            }

     

     

    2007年10月28日 下午 03:02
  • 上面不是已有回覆存圖的方法?!

    [利用 pictureBox1.Image.Save("FilePath to Save") 方法就可以把圖片儲存到檔案路徑...]

     

    pictureBox1.Image.Save("c:\test.bmp");

     

    http://msdn2.microsoft.com/zh-tw/library/system.drawing.image.save(VS.80).aspx

    2007年10月28日 下午 11:49
  •  

    感謝各位大大的幫忙,就是我還有一個問題,因為我是再做影像處理的程式,像是內建的函式很多都不清楚,可以推薦幾本書或是網站給我嗎,感激~
    2007年10月29日 上午 03:44