How to save the image after cropping in ImageEditor?
This section explains how to save image after cropping the image in imageeditor.
Create SfImageEditor sample with all necessary assemblies.
Please refer the below link to create a simple SfImageEditor sample along with the ways to configure it.
https://help.syncfusion.com/xamarin/sfimageeditor/getting-started
Step 1: Add toggle cropping method in image loaded event to show the cropping window when image loads in image editor as like below code snippet
editor.ImageLoaded += CropEditor_ImageLoaded; private void CropEditor_ImageLoaded(object sender, ImageLoadedEventArgs args) { editor.ToggleCropping(); }
Step 2: To save the image after cropping, you need to perform operations such as Select crop toolbar item to crop the image and select save toolbar item to save the image.
To avoid this too many operations to perform save the image after cropping, you need to include the toolbar item selected event and then call save method in ok click event as like below code snippet
editor.ToolbarSettings.ToolbarItemSelected += ToolbarSettings_ToolbarItemSelected; private void ToolbarSettings_ToolbarItemSelected(object sender, ToolbarItemSelectedEventArgs e) { if (e.ToolbarItem.Name == "Ok") { Device.BeginInvokeOnMainThread(() => { if (Device.RuntimePlatform == Device.UWP) { Device.StartTimer(TimeSpan.FromMilliseconds(1000), () => { editor.Save(); return false; }); } else { editor.Save(); } }); } if (e.ToolbarItem.Name == "Cancel") { DisplayAlert("Cancel", "Crop Cancelled", "Ok"); } }
Sample Link: https://www.syncfusion.com/downloads/support/directtrac/general/ze/IESample278277967.zip