예제 #1
0
        public static void ProceedSelectedImage(Android.Net.Uri uri)
        {
            var path = uri.Path.StartsWith("file://") ? uri.Path : uri.GetRealPathFromUri(CrossCurrentActivity.Current.AppContext);

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            var fileName   = System.IO.Path.GetFileNameWithoutExtension(path);
            var ext        = System.IO.Path.GetExtension(path) ?? string.Empty;
            var thumbImage = ImageHelpers.RotateImage(path, 0.25f);

            var thumbnailImagePath =
                MediaFileHelper.GetOutputPath(MediaFileType.Image, "TmpMedia",
                                              $"{fileName}-THUMBNAIL{ext}");

            File.WriteAllBytes(thumbnailImagePath, thumbImage);

            var mediaFile = new MediaFile
            {
                Path        = path,
                PreviewPath = thumbnailImagePath,
                Type        = MediaFileType.Image
            };

            MediaChooser.Current.Success?.Invoke(new List <MediaFile> {
                mediaFile
            });
        }