示例#1
0
        // ReSharper disable once UnusedMember.Local
        private void PhotoCaptureComplete(AVCapturePhotoOutput captureOutput, CMSampleBuffer finishedPhotoBuffer, CMSampleBuffer previewPhotoBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            try
            {
                if (error != null)
                {
                    _cameraModule.ErrorMessage = error.ToString();
                }
                else if (finishedPhotoBuffer != null)
                {
                    LockPictureSpecificSettingsIfNothingCaptured();

                    using (var image = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(finishedPhotoBuffer, previewPhotoBuffer))
                        using (var imgDataProvider = new CGDataProvider(image))
                            using (var cgImage = CGImage.FromJPEG(imgDataProvider, null, false, CGColorRenderingIntent.Default))
                                using (var uiImage = UIImage.FromImage(cgImage, 1, GetOrientationForCorrection()))
                                {
                                    _cameraModule.CapturedImage = uiImage.AsJPEG().ToArray();
                                }
                }
            }
            catch (Exception e)
            {
                _cameraModule.ErrorMessage = e.ToString();
            }
        }
示例#2
0
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CoreMedia.CMSampleBuffer photoSampleBuffer, CoreMedia.CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            var imageData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);

            if (imageData != null)
            {
                var capturedImage = new UIImage(imageData);


                var storyboard      = UIStoryboard.FromName("Main", NSBundle.MainBundle);
                UIViewController vc = new UIViewController();
                if (came_from == Constants.personal)
                {
                    CropCameraViewController.currentImage = capturedImage;
                    vc = storyboard.InstantiateViewController(nameof(CropCameraViewController));
                }
                else if (came_from == Constants.company_logo)
                {
                    CropCompanyLogoViewController.currentImage = capturedImage;
                    vc = storyboard.InstantiateViewController(nameof(CropCompanyLogoViewController));
                }

                this.NavigationController.PushViewController(vc, true);
            }
        }
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput,
                                             CMSampleBuffer photoSampleBuffer,
                                             CMSampleBuffer previewPhotoSampleBuffer,
                                             AVCaptureResolvedPhotoSettings resolvedSettings,
                                             AVCaptureBracketedStillImageSettings bracketSettings,
                                             NSError error)
        {
            if (photoSampleBuffer == null || error != null)
            {
                Console.WriteLine("Error taking photo: " + error);
                return;
            }

            NSData imageData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);

            SetPaths(".jpg");

            UIImage formattedImg = AppUtils.ScaleAndRotateImage(UIImage.LoadFromData(imageData));

            imageData = formattedImg.AsJPEG(0.8f);

            if (imageData.Save(filePath, false, out NSError saveErr))
            {
                Console.WriteLine("Saved photo to: " + filePath);
                ReturnWithData(innerPath);
            }
            else
            {
                Console.WriteLine("ERROR saving to " + fileName + " because " + saveErr.LocalizedDescription);
            }
        }
示例#4
0
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {/*
          * try
          * {
          *     using (var pixelBuffer = photoSampleBuffer.GetImageBuffer() as CVPixelBuffer)
          *     {
          *         pixelBuffer.Lock(CVPixelBufferLock.None);
          *         var j = CIImage.FromImageBuffer(pixelBuffer);
          *         pixelBuffer.Unlock(CVPixelBufferLock.None);
          *     }
          *
          *     using(var t = photoSampleBuffer.GetImageBuffer())
          *     {
          *
          *     }
          *
          *
          *     //var i = new CGAffineTransform();
          *     //i.Rotate(90);
          *
          *     //u = lol.ImageByApplyingTransform(y);
          *
          *     //var filter = CIFilter.GetFilter("CIAffineTransform", );
          *
          *
          * }
          * catch(Exception ex)
          * {
          *
          * }*/
            var jpegData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
            var h        = UIImage.LoadFromData(jpegData);

            GoToDescription(h);
        }
示例#5
0
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            var jpegData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
            var h        = UIImage.LoadFromData(jpegData);

            GoToDescription(h);
        }
 public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
 {
     if (photoSampleBuffer != null)
     {
         photoData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
     }
     else
     {
         Console.WriteLine($"Error capturing photo: {error.LocalizedDescription}");
     }
 }
 public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
 {
     try
     {
         var jpegData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
         var photo    = UIImage.LoadFromData(jpegData);
         GoToDescription(photo, orientationOnPhoto);
     }
     catch (Exception ex)
     {
         AppSettings.Reporter.SendCrash(ex);
         ShowAlert(Core.Localization.LocalizationKeys.PhotoProcessingError);
     }
 }
示例#8
0
 public override void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput,
                                               CMSampleBuffer photoSampleBuffer,
                                               CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings,
                                               AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
 {
     if (photoSampleBuffer != null)
     {
         PhotoData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer,
                                                                         previewPhotoSampleBuffer);
     }
     else if (error != null)
     {
         Console.WriteLine($"photo capture delegate: error capturing photo: {error}");
         ProcessError = error;
     }
 }
示例#9
0
        public override void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput,
                                                      CMSampleBuffer photoSampleBuffer,
                                                      CMSampleBuffer previewPhotoSampleBuffer,
                                                      AVCaptureResolvedPhotoSettings resolvedSettings,
                                                      AVCaptureBracketedStillImageSettings bracketSettings,
                                                      NSError error)
        {
            if (photoSampleBuffer != null)
            {
                _photoData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Error capturing photo: {0}", error.LocalizedDescription));
            }

            PictureTaken?.Invoke(this, _photoData);
        }
        public void DidFinishProcessingPhoto(AVCapturePhotoOutput captureOutput, CMSampleBuffer photoSampleBuffer, CMSampleBuffer previewPhotoSampleBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            try
            {
                var jpegData = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(photoSampleBuffer, previewPhotoSampleBuffer);
                var photo    = UIImage.LoadFromData(jpegData);

                var inSampleSize = ImageHelper.CalculateInSampleSize(photo.Size, Core.Constants.PhotoMaxSize, Core.Constants.PhotoMaxSize);
                var deviceRatio  = Math.Round(UIScreen.MainScreen.Bounds.Width / UIScreen.MainScreen.Bounds.Height, 2);

                var x = ((float)inSampleSize.Width - Core.Constants.PhotoMaxSize * (float)deviceRatio) / 2f;
                photo = ImageHelper.CropImage(photo, x, 0, Core.Constants.PhotoMaxSize * (float)deviceRatio, Core.Constants.PhotoMaxSize, inSampleSize);
                GoToDescription(photo, orientationOnPhoto);
            }
            catch (Exception ex)
            {
                ShowAlert(new InternalException(Core.Localization.LocalizationKeys.PhotoProcessingError, ex));
            }
        }
        public void DidFinishProcessingPhoto(
            AVCapturePhotoOutput output,
            CMSampleBuffer buffer1,
            CMSampleBuffer buffer2,
            AVCaptureResolvedPhotoSettings resolvedPhotoSettings,
            AVCaptureBracketedStillImageSettings bracketedStillImageSettings,
            NSError error
            )
        {
            if (_photoCapturePath == null)
            {
                throw new ArgumentNullException(_photoCapturePath);
            }

            var data  = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(buffer1, buffer2);
            var bytes = data.ToArray();

            File.WriteAllBytes(_photoCapturePath, bytes);
            _photoCapturePath = null;
        }
示例#12
0
        // ReSharper disable once UnusedMember.Local
        private void PhotoCaptureComplete(AVCapturePhotoOutput captureOutput, CMSampleBuffer finishedPhotoBuffer, CMSampleBuffer previewPhotoBuffer, AVCaptureResolvedPhotoSettings resolvedSettings, AVCaptureBracketedStillImageSettings bracketSettings, NSError error)
        {
            try
            {
                if (error != null)
                {
                    _cameraModule.ErrorMessage = error.ToString();
                }
                else if (finishedPhotoBuffer != null)
                {
                    if (!(_cameraModule.BluetoothOperator.PairStatus == PairStatus.Connected &&
                          !_cameraModule.BluetoothOperator.IsPrimary))
                    {
                        LockPictureSpecificSettingsIfApplicable();
                    }

                    using (var image = AVCapturePhotoOutput.GetJpegPhotoDataRepresentation(finishedPhotoBuffer, previewPhotoBuffer))
                        using (var imgDataProvider = new CGDataProvider(image))
                            using (var cgImage = CGImage.FromJPEG(imgDataProvider, null, false, CGColorRenderingIntent.Default))
                                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();
            }
        }