【发布时间】:2020-09-10 19:48:54
【问题描述】:
if (!CrossMedia.Current.IsPickPhotoSupported)
{
await Application.Current.MainPage.DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
return;
}
var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
});
if (file == null)
return;
var tmpSrc = ImageSource.FromStream(() =>
{
var stream = file.GetStream();
file.Dispose();
return stream;
});
ImageSource toBeConverted = tmpSrc;
- 我希望将变量 toBeConverted 转换为 Byte[] 所以 我可以将它发送到我的 webapi ...
【问题讨论】:
-
File.ReadAllBytes(file.Path); -
可以吗?
标签: c# arrays xamarin.forms imagesource