Reputation: 95
I am using the Plugin. Media to pick a photo from my gallery. I would like to provide the users an option to rotate the image when they click on it.
When I use the rotate property, I am able to rotate the image once. But, I would like to rotate it by 90 degrees every time the user clicks on a button.
if (!CrossMedia.Current.IsPickPhotoSupported)
{
await DisplayAlert("Photos Not Supported", "Permission not granted
to photos", "OK");
return;
}
var file = Plugin.Media.CrossMedia.Current.PickPhotoAsync(new
Plugin.Media.Abstractions.PickMediaOptions
{
PhotoSize = Plugin.Media.Abstractions.PhotoSize.Small
});
if (file == null)
return;
imageProfile.Source = ImageSource.FromStream(() =>
{
var stream = file.Result.GetStream();
file.Result.Dispose();
return stream;
});
public void rotateButton_Clicked(object sender, Event args e) {
imageProfile.RotateX(90);
// This event allows me to rotate the image only once.
}
Upvotes: 1
Views: 2784
Reputation: 89102
int angle = 0;
public void rotateButton_Clicked(object sender, Event args e) {
angle += 90;
imageProfile.RotateX(angle);
}
Upvotes: 3