public override void DidFinishProcessingPhoto(AVCapturePhotoOutput output, AVCapturePhoto photo, NSError error)
 {
     if (error != null)
     {
         Console.WriteLine($"Error capturing photo: {error.LocalizedDescription}");
     }
     else
     {
         photoData = photo.FileDataRepresentation;
     }
 }
Пример #2
0
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput output, AVCapturePhoto photo, NSError error)
        {
            var imageData = photo.FileDataRepresentation;

            if (imageData != null)
            {
                var previewImage = new UIImage(imageData);
                previewImage.SaveToPhotosAlbum((img, err) =>
                {
                    if (err == null)
                    {
                        App.Current.MainPage.DisplayAlert("", "Saved image to photos", "OK");
                    }
                    else
                    {
                        App.Current.MainPage.DisplayAlert("", "Save image to photos Fail", "OK");
                    }
                });
                delege?.ImageTake(previewImage);
            }
        }
Пример #3
0
        override public void DidFinishProcessingPhoto(AVCapturePhotoOutput output, AVCapturePhoto photo, NSError error)
        {
            string localFolder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            var    localPath   = System.IO.Path.Combine(localFolder, $"Photo_{DateTime.Now.ToString("yyMMdd_hhmmss")}.jpg");
            var    errMsg      = error?.Description;

            try
            {
                System.IO.File.WriteAllBytes(localPath, photo.FileDataRepresentation.ToArray()); // write to local storage
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
            }
            finally
            {
                if (SavedPhoto != null)
                {
                    SavedPhoto(this, new ListEventArgs(localPath, errMsg));
                }
            }
        }
Пример #4
0
        // ReSharper disable once UnusedMember.Local
        private void PhotoCaptureComplete(AVCapturePhotoOutput captureOutput, AVCapturePhoto photo, NSError error)
        {
            try
            {
                if (error != null)
                {
                    _cameraModule.ErrorMessage = error.ToString();
                }
                else if (photo != null)
                {
                    if (!(_cameraModule.BluetoothOperator.PairStatus == PairStatus.Connected &&
                          !_cameraModule.BluetoothOperator.IsPrimary))
                    {
                        LockPictureSpecificSettingsIfApplicable();
                    }

                    using (var cgImage = photo.CGImageRepresentation)
                        using (var uiImage = UIImage.FromImage(cgImage, 1, GetOrientationForCorrection()))
                        {
                            var imageBytes = uiImage.AsJPEG().ToArray();
                            if (_cameraModule.BluetoothOperator.PairStatus == PairStatus.Connected &&
                                !_cameraModule.BluetoothOperator.IsPrimary)
                            {
                                _cameraModule.BluetoothOperator.SendCapture(imageBytes);
                            }
                            else
                            {
                                _cameraModule.CapturedImage = imageBytes;
                            }
                        }
                }
            }
            catch (Exception e)
            {
                _cameraModule.ErrorMessage = e.ToString();
            }
        }
Пример #5
0
        // ReSharper disable once UnusedMember.Local
        private void PhotoCaptureComplete(AVCapturePhotoOutput captureOutput, AVCapturePhoto photo, NSError error)
        {
            try
            {
                if (error != null)
                {
                    _cameraModule.ErrorMessage = error.ToString();
                }
                else if (photo != null)
                {
                    LockPictureSpecificSettingsIfNothingCaptured();

                    using (var cgImage = photo.CGImageRepresentation)
                        using (var uiImage = UIImage.FromImage(cgImage, 1, GetOrientationForCorrection()))
                        {
                            _cameraModule.CapturedImage = uiImage.AsJPEG().ToArray();
                        }
                }
            }
            catch (Exception e)
            {
                _cameraModule.ErrorMessage = e.ToString();
            }
        }
Пример #6
0
 public override void DidFinishProcessingPhoto(AVCapturePhotoOutput output, AVCapturePhoto photo, NSError error)
 {
     Picture = photo.CGImageRepresentation;
     FinishedProcessing?.Invoke(this, null);
 }
Пример #7
0
 public static NSData FileDataRepresentation(this AVCapturePhoto This)
 {
     return(Runtime.GetNSObject <NSData>(global::ApiDefinition.Messaging.IntPtr_objc_msgSend(This.Handle, Selector.GetHandle("fileDataRepresentation"))));
 }
Пример #8
0
 public virtual void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, AVCapturePhoto photo, NSError error)
 {
     if (error != null)
     {
         Console.WriteLine($"Error capturing photo: {error}", error);
         return;
     }
     PhotoData = photo.FileDataRepresentation();
 }
        public virtual void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, AVCapturePhoto photo, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"Error capturing photo: {error}", error);
                return;
            }

            PhotoData = photo.FileDataRepresentation();

            imageBytes = new byte[PhotoData.Length];
            System.Runtime.InteropServices.Marshal.Copy(PhotoData.Bytes, imageBytes, 0, Convert.ToInt32(PhotoData.Length));
        }
Пример #10
0
 public override void DidFinishProcessingPhoto(AVCapturePhotoOutput output, AVCapturePhoto photo,
                                               NSError error)
 {
     Debug.WriteLine(error);
     handler(photo);
 }
Пример #11
0
        public virtual void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, AVCapturePhoto photo, NSError error)
        {
            if (error != null)
            {
                Console.WriteLine($"Error capturing photo: {error}", error);
                return;
            }

            PhotoData = photo.FileDataRepresentation();

            DataManager.SheduleAddMachinePhotoRequest(Application.selectedMachine.ID, PhotoData.ToArray(), null);
        }