protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_CAMERA_CAPTURE: if (resultCode == Result.Ok) { Console.WriteLine(mCurrentPhotoPath); Task.Delay(100).ContinueWith((arg) => { var item = new GalleryImageXF() { OriginalPath = mCurrentPhotoPath }; var bitmap = item.OriginalPath.GetOriginalBitmapFromPath(new DependencyService.SyncPhotoOptions() { Width = 300, Height = 300 }); using (var streamBitmap = new MemoryStream()) { bitmap.Compress(Bitmap.CompressFormat.Jpeg, 80, streamBitmap); item.ImageSourceXF = ImageSource.FromStream(() => new MemoryStream(streamBitmap.ToArray().ToArray())); bitmap.Recycle(); } var result = new List <GalleryImageXF>() { item }; MessagingCenter.Send <GalleryPickerActivity, List <GalleryImageXF> >(this, Utils.SubscribeImageFromGallery, result); }); Finish(); } break; default: break; } }
public PhotoSetNative() { galleryImageXF = new GalleryImageXF(); galleryImageXF.Checked = false; galleryImageXF.CloudStorage = true; }
public async Task <GalleryImageXF> IF_SyncPhotoFromCloud(IGalleryPickerResultListener galleryPickerResultListener, GalleryImageXF imageSet, SyncPhotoOptions options) { try { bool FinishSync = false; Debug.WriteLine(imageSet.OriginalPath); var sortOptions = new PHFetchOptions(); sortOptions.SortDescriptors = new NSSortDescriptor[] { new NSSortDescriptor("creationDate", false) }; var FeechPhotoByIdentifiers = PHAsset.FetchAssetsUsingLocalIdentifiers( new string[] { imageSet.OriginalPath }, sortOptions).Cast <PHAsset>().FirstOrDefault(); if (FeechPhotoByIdentifiers != null) { var requestOptions = new PHImageRequestOptions() { NetworkAccessAllowed = true, DeliveryMode = PHImageRequestOptionsDeliveryMode.HighQualityFormat, ResizeMode = PHImageRequestOptionsResizeMode.None, }; var requestSize = new CoreGraphics.CGSize(options.Width, options.Height); requestSize = PHImageManager.MaximumSize; PHImageManager.DefaultManager.RequestImageForAsset(FeechPhotoByIdentifiers, requestSize, PHImageContentMode.AspectFit, requestOptions, (result, info) => { if (result != null) { var newImage = result.ResizeImage(options); imageSet.ImageRawData = newImage.AsJPEG(options.Quality).ToArray(); } FinishSync = true; }); do { if (FinishSync) { return(imageSet); } await Task.Delay(1000); } while (!FinishSync); } return(imageSet); } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); return(imageSet); } }
public Task <GalleryImageXF> IF_SyncPhotoFromCloud(IGalleryPickerResultListener galleryPickerResultListener, GalleryImageXF imageSet, SyncPhotoOptions options) { var bitmap = imageSet.OriginalPath.GetOriginalBitmapFromPath(options); using (var streamBitmap = new MemoryStream()) { bitmap.Compress(Bitmap.CompressFormat.Jpeg, (int)(options.Quality * 100), streamBitmap); imageSet.ImageRawData = streamBitmap.ToArray().ToArray(); bitmap.Recycle(); return(Task.FromResult <GalleryImageXF>(imageSet)); } }