Esempio n. 1
0
        /// <summary>
        /// //////////////////////////////////////////////////////
        /// </summary>
        /// <param name="isFirst"></param>
        /// <returns></returns>
        public static async Task <StorageFile> LowLagCapturePhoto(bool isFirst)
        {
            var file = await AppPathHelper.GetTempPhotoFile(isFirst == true? -10 : 0);

            if (file == null)
            {
                return(null);
            }
            try
            {
                var rotation   = GetBitmapRotation();
                var directSave = true;
                if (rotation == BitmapRotation.None)
                {
                    if (IsHavePhotoStream == true && IsSupportHWZoom == false)
                    {
                        directSave = false;
                    }
                    else
                    {
                        directSave = true;
                    }
                }
                else
                {
                    directSave = false;
                }
                var photoData = await LowLagPhoto.CaptureAsync();

                var photoFrame = photoData.Frame;
                if (photoFrame.Size < 1)
                {
                    return(null);
                }
                using (var stream = photoFrame.CloneStream())
                {
                    //if (directSave == true)
                    {
                        using (var saveStream = await file.OpenStreamForWriteAsync())
                        {
                            await RandomAccessStream.CopyAndCloseAsync(stream, saveStream.AsOutputStream());
                        }
                    }
                    // else
                    {
                        //     await RotationZoomImage(stream, file, rotation, (int)AppHelper.CameraZoomNumber);
                    }
                }

                await Task.Delay(200);
            }
            catch (Exception ex)
            {
            }
            return(file);
        }
        public static async Task CloseLowLagPhoto()
        {
            try
            {
                if (LowLagPhoto != null)
                {
                    await LowLagPhoto.FinishAsync();

                    LowLagPhoto = null;
                }
            }
            catch (Exception ex)
            {
            }
        }