コード例 #1
0
        public void DoAsyn(NRPhotoCapture.OnCapturedToMemoryCallback oncapturedcallback)
        {
            if (!m_IsInit)
            {
                if (oncapturedcallback != null)
                {
                    var result = new NRPhotoCapture.PhotoCaptureResult();
                    result.resultType = NRPhotoCapture.CaptureResultType.UnknownError;
                    oncapturedcallback(result, null);
                }
                return;
            }
            var captureTask = new CaptureTask();

            captureTask.Width         = m_CameraParameters.cameraResolutionWidth;
            captureTask.Height        = m_CameraParameters.cameraResolutionHeight;
            captureTask.BlendMode     = m_CameraParameters.blendMode;
            captureTask.CaptureFormat = m_CameraParameters.pixelFormat == CapturePixelFormat.PNG ? PhotoCaptureFileOutputFormat.PNG : PhotoCaptureFileOutputFormat.JPG;
            captureTask.OnReceive    += (task, data) =>
            {
                if (oncapturedcallback != null)
                {
                    var result = new NRPhotoCapture.PhotoCaptureResult();
                    result.resultType = NRPhotoCapture.CaptureResultType.Success;
                    CapturePixelFormat format = task.CaptureFormat == PhotoCaptureFileOutputFormat.PNG ? CapturePixelFormat.PNG : CapturePixelFormat.JPEG;
                    PhotoCaptureFrame  frame  = new PhotoCaptureFrame(format, data);
                    oncapturedcallback(result, frame);
                }
            };

            this.DoAsyn(captureTask);
        }
コード例 #2
0
        /// <summary>
        /// Capture a image Asyn. if system supports AsyncGPUReadback, using AsyncGPUReadback to get the
        /// captured image, else getting the image by synchronization way. </summary>
        /// <param name="oncapturedcallback"> The oncapturedcallback.</param>
        public void DoAsyn(NRPhotoCapture.OnCapturedToMemoryCallback oncapturedcallback)
        {
            var captureTask = new CaptureTask();
            var cameraParam = this.GetContext().RequestCameraParam();

            captureTask.Width         = cameraParam.cameraResolutionWidth;
            captureTask.Height        = cameraParam.cameraResolutionHeight;
            captureTask.CaptureFormat = cameraParam.pixelFormat == CapturePixelFormat.PNG ? PhotoCaptureFileOutputFormat.PNG : PhotoCaptureFileOutputFormat.JPG;
            captureTask.OnReceive    += (task, data) =>
            {
                if (oncapturedcallback != null)
                {
                    var result = new NRPhotoCapture.PhotoCaptureResult();
                    result.resultType = NRPhotoCapture.CaptureResultType.Success;
                    CapturePixelFormat format = task.CaptureFormat == PhotoCaptureFileOutputFormat.PNG ? CapturePixelFormat.PNG : CapturePixelFormat.JPEG;
                    PhotoCaptureFrame  frame  = new PhotoCaptureFrame(format, data);
                    oncapturedcallback(result, frame);
                }
            };

            this.DoAsyn(captureTask);
        }