コード例 #1
0
        private void CommitResult(Texture2D texture, CaptureTask task)
        {
            if (task.OnReceive == null)
            {
                return;
            }

            if (texture == null)
            {
                task.OnReceive(task, null);
                return;
            }

            byte[] result = null;
            switch (task.CaptureFormat)
            {
            case PhotoCaptureFileOutputFormat.JPG:
                result = texture.EncodeToJPG();
                break;

            case PhotoCaptureFileOutputFormat.PNG:
                result = texture.EncodeToPNG();
                break;

            default:
                break;
            }
            task.OnReceive(task, result);
        }
コード例 #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="task"> The task.</param>
 private void DoAsyn(CaptureTask task)
 {
     if (SystemInfo.supportsAsyncGPUReadback)
     {
         this.ImageEncoder.Commit(task);
     }
     else
     {
         var data = ImageEncoder.Encode(task.Width, task.Height, task.CaptureFormat);
         if (task.OnReceive != null)
         {
             task.OnReceive(task, data);
         }
     }
 }
コード例 #3
0
        /**
         * @brief Capture a image Asyn.
         *
         * if system supports AsyncGPUReadback, using AsyncGPUReadback to get the captured image.
         * else getting the image by synchronization way.
         */
        public void DoAsyn(CaptureTask task)
        {
            if (!m_IsInit)
            {
                return;
            }

            if (SystemInfo.supportsAsyncGPUReadback)
            {
                m_CameraInput.Capture(task);
            }
            else
            {
                var data = Do(task.Width, task.Height, task.BlendMode, task.CaptureFormat);
                if (task.OnReceive != null)
                {
                    task.OnReceive(task, data);
                }
            }
        }