我想裁剪使用Xamarin表格拍摄的照片,但它在IOS,Android和Windows上对我不起作用。此外,当图片保存到本地存储器时,它会旋转,当我用前置摄像头拍照时会发生这种情况。
以下是我的源代码。
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable)
{
await DisplayAlert("Camera not available", "", "Cancel");
return;
}
StoreCameraMediaOptions mediaOption = new StoreCameraMediaOptions();
mediaOption.AllowCropping = true;
mediaOption.SaveToAlbum = true;
file = await CrossMedia.Current.TakePhotoAsync(mediaOption);
if (file != null)
{
Stream stream = null;
using (var memoryStream = new MemoryStream())
{
stream = file.GetStream();
stream.CopyTo(memoryStream);
byteFile = null;
byteFile = memoryStream.ToArray();
}
if (stream != null)
stream.Dispose();
file.Dispose();
file = null;
}