コード例 #1
0
        private void OnEventImage()
        {
            BitmapData bdata    = liveBm.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
            uint       bmWidth  = 0;
            uint       bmHeight = 0;
            bool       retVal   = myCamera.PullImage(bdata.Scan0, 24, out bmWidth, out bmHeight);

            liveBm.UnlockBits(bdata);
            image_pbx.Image = liveBm;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: vladzvx/PhaseImageRecorder
        private void OnEventImage()
        {
            if (bmp_ != null)
            {
                BitmapData bmpdata = bmp_.LockBits(new Rectangle(0, 0, bmp_.Width, bmp_.Height), ImageLockMode.WriteOnly, bmp_.PixelFormat);

                uint nWidth = 0, nHeight = 0;
                toupcam_.PullImage(bmpdata.Scan0, 24, out nWidth, out nHeight);

                bmp_.UnlockBits(bmpdata);

                pictureBox1.Image = bmp_;
                pictureBox1.Invalidate();
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: vladzvx/PhaseImageRecorder
        private void OnEventImage()
        {
            try
            {
                if (bmp_ != null)
                {
                    if (this.tabControl1.SelectedIndex != 0)
                    {
                        return;
                    }
                    uint nWidth = 0, nHeight = 0;
                    if (radioButton2.Checked)
                    {
                        byte[,,] arr = new byte[bmp_.Height, bmp_.Width, 3];
                        IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(arr, 0);

                        toupcam_.PullImage(pointer, 24, out nWidth, out nHeight);
                        int x = trackBar4.Value;
                        int y = trackBar5.Value;
                        int w = int.Parse(comboBox2.Text);
                        int h = int.Parse(comboBox3.Text);;
                        //Marshal.Copy(pointer, arr2, 0, arr.Length);
                        for (int i = y; i < h + y; i++)
                        {
                            arr[i, x, 1]         = 255;
                            arr[i, x + 1, 1]     = 255;
                            arr[i, x + 2, 1]     = 255;
                            arr[i, x + w, 1]     = 255;
                            arr[i, x + w - 1, 1] = 255;
                            arr[i, x + w - 2, 1] = 255;
                        }
                        for (int j = x; j < w + x; j++)
                        {
                            arr[y, j, 1]         = 255;
                            arr[y + 1, j, 1]     = 255;
                            arr[y + 2, j, 1]     = 255;
                            arr[y + h, j, 1]     = 255;
                            arr[y + h - 1, j, 1] = 255;
                            arr[y + h - 2, j, 1] = 255;
                        }
                        pictureBox1.Image = new Bitmap((int)nWidth, (int)nHeight, (int)nWidth * 3, PixelFormat.Format24bppRgb,
                                                       Marshal.UnsafeAddrOfPinnedArrayElement(arr, 0));
                        pictureBox1.Update();
                        label5.Text = Math.Round(fPSCounter.Count(), 2).ToString();
                        label5.Update();
                    }
                    else if (radioButton1.Checked)
                    {
                        if (checkBox4.Checked)
                        {
                            byte[,,] arr1 = new byte[bmp_.Height, bmp_.Width, 3];
                            IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(arr1, 0);
                            toupcam_.PullImage(pointer, 24, out nWidth, out nHeight);

                            int x = trackBar4.Value;
                            int y = trackBar5.Value;
                            int w = int.Parse(comboBox2.Text);
                            int h = int.Parse(comboBox3.Text);;

                            byte[,,] arr = new byte[h, w, 3];

                            for (int i = y; i < h + y; i++)
                            {
                                for (int j = x; j < w + x; j++)
                                {
                                    arr[i - y, j - x, 0] = arr1[i, j, 0];
                                    arr[i - y, j - x, 1] = arr1[i, j, 1];
                                    arr[i - y, j - x, 2] = arr1[i, j, 2];
                                }
                            }
                            //if (checkBox2.Checked)
                            //{
                            calculator.PutImage(arr,
                                                level: (int)numericUpDown2.Value,
                                                unwrap: checkBox3.Checked,
                                                wavelength: settings.wavelength,
                                                smooth: checkBox5.Checked,
                                                summDepth: checkBox6.Checked ? (int)numericUpDown1.Value : 0,
                                                calc: checkBox2.Checked,
                                                delTrend: checkBox7.Checked);

                            var buff = calculator.GetImage();
                            if (buff != null)
                            {
                                hpi2 = buff;
                            }
                            if (hpi2 != null)
                            {
                                arr = hpi2._images[0];
                                pictureBox1.Image = new Bitmap((int)w, (int)h, (int)w * 3, PixelFormat.Format24bppRgb,
                                                               Marshal.UnsafeAddrOfPinnedArrayElement(arr, 0));
                                pictureBox1.Update();
                                label5.Text = Math.Round(fPSCounter.Count(), 2).ToString();
                                label5.Update();
                            }
                            //}
                            //else
                            //{
                            //    pictureBox1.Image = new Bitmap((int)w, (int)h, (int)w * 3, PixelFormat.Format24bppRgb,
                            //        Marshal.UnsafeAddrOfPinnedArrayElement(arr, 0));
                            //    pictureBox1.Update();
                            //    label5.Text = Math.Round(fPSCounter.Count(), 2).ToString();
                            //    label5.Update();
                            //}
                        }
                        else
                        {
                            byte[,,] arr1 = new byte[bmp_.Height, bmp_.Width, 3];
                            IntPtr pointer = Marshal.UnsafeAddrOfPinnedArrayElement(arr1, 0);
                            toupcam_.PullImage(pointer, 24, out nWidth, out nHeight);
                            pictureBox1.Image = new Bitmap(bmp_.Width, bmp_.Height, bmp_.Width * 3, PixelFormat.Format24bppRgb,
                                                           Marshal.UnsafeAddrOfPinnedArrayElement(arr1, 0));
                            pictureBox1.Update();
                            label5.Text = Math.Round(fPSCounter.Count(), 2).ToString();
                            label5.Update();
                        }
                    }


                    //button4_Click(null, null);
                }
            }
            catch { }
        }