private void ShrinkAndSaveNewImage(UIImage passedImage) { if (passedImage == null) { return; } UIImage smallerImage = AppUtils.ScaleAndRotateImage(passedImage, 800); NSData imageData = smallerImage.AsJPEG(0.8f); if (currentImagePath == null) { currentImagePath = Path.Combine(folderPath, "task_" + DateTime.UtcNow.ToString("s") + ".jpg"); } else if (!File.Exists(currentImagePath)) { File.Create(currentImagePath); } // save the image data to a folder ready for uploading if (imageData.Save(currentImagePath, true)) { Console.WriteLine("Saved photo to: " + currentImagePath); ImageService.Instance.InvalidateCacheEntryAsync(currentImagePath, FFImageLoading.Cache.CacheType.All, true); ImageService.Instance.LoadFile(currentImagePath).Into(AccompanyingImage); } else { Console.WriteLine("ERROR saving to " + currentImagePath); } UpdateLabels(); }
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); } }