Exemple #1
0
        private void CameraGrabberSaveImageComplete2(
            IntPtr Grabber,
            IntPtr Image,       // 需要调用CameraImage_Destroy释放
            CameraSdkStatus Status,
            IntPtr Context)
        {
            if (Image != IntPtr.Zero)
            {
                tSdkCameraDevInfo devInfo;
                MvApi.CameraGrabber_GetCameraDevInfo(Grabber, out devInfo);

                Encoding myEncoding = Encoding.GetEncoding("utf-8");
                string   sData      = myEncoding.GetString(devInfo.acSn);
                sData = sData.TrimEnd('\0');
                sData = sData.Substring(0, 12);

                string filename = System.IO.Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory.ToString(),
                    string.Format("{0}-{1}-{2}.jpg", System.Environment.TickCount, sData, devInfo.uInstance));

                MvApi.CameraImage_SaveAsJpeg(Image, filename, 90);

                m_saveFilenames += filename + "\r\n";
                m_countFiles++;
            }
            if (m_countFiles == CAMERA_NUM)
            {
                MessageBox.Show(m_saveFilenames);
            }


            MvApi.CameraImage_Destroy(Image);
        }
        private void CameraGrabberSaveImageComplete(
            IntPtr Grabber,
            IntPtr Image,       // 需要调用CameraImage_Destroy释放
            CameraSdkStatus Status,
            IntPtr Context)
        {
            if (Image != IntPtr.Zero)
            {
                string filename = System.IO.Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory.ToString(),
                    string.Format("{0}.bmp", System.Environment.TickCount));

                MvApi.CameraImage_SaveAsBmp(Image, filename);

                MessageBox.Show(filename);
            }

            MvApi.CameraImage_Destroy(Image);
        }
        private void buttonSnap_Click(object sender, EventArgs e)
        {
            if (m_Grabber != IntPtr.Zero)
            {
                IntPtr Image;
                if (MvApi.CameraGrabber_SaveImage(m_Grabber, out Image, 2000) == CameraSdkStatus.CAMERA_STATUS_SUCCESS)
                {
                    string filename = System.IO.Path.Combine(
                        AppDomain.CurrentDomain.BaseDirectory.ToString(),
                        string.Format("{0}.bmp", System.Environment.TickCount));

                    MvApi.CameraImage_SaveAsBmp(Image, filename);

                    MvApi.CameraImage_Destroy(Image);

                    MessageBox.Show(filename);
                }
                else
                {
                    MessageBox.Show("Snap failed");
                }
            }
        }