We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to Load an Image from Gallery in ImageEditor Xamarin.Android

Platform: Xamarin.Android |
Control: SfImageEditor

How to Load an Image from Gallery in ImageEditor Xamarin.Android?


This article explains you to load an Image from Gallery to the Image Editor.



  1. Create a Xamarin application and initialize SfImageEditor control in it by using the below code.


Import the SfImageEditor as shown below,




using Syncfusion.SfImageEditor.Android;





static Intent mainIntent;

private static int SELECT_FROM_GALLERY = 0;

internal static string Path { get; set; }

SfImageEditor editor;


protected override void OnCreate(Bundle bundle)



    editor = new SfImageEditor(this);





  1. Load an Image from Gallery to the image editor by call the InitializeMediaPicker method as shown in below.





public void InitializeMediaPicker()
    Intent = new Intent();
    StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), SELECT_FROM_GALLERY);






private string GetPathToImage(Android.Net.Uri uri)
    string imgId = "";
    using (var c1 = ContentResolver.Query(uri, null, null, null, null))
        string imageId = c1.GetString(0);
        imgId = imageId.Substring(imageId.LastIndexOf(":") + 1);
    string path = null;
    string selection = MediaStore.Images.Media.InterfaceConsts.Id + " =? ";
    using (var cursor = ContentResolver.Query(MediaStore.Images.Media.ExternalContentUri, null, selection, new string[] { imgId }, null))
        if (cursor == null) return path;
        var columnIndex = cursor.GetColumnIndexOrThrow(MediaStore.Images.Media.InterfaceConsts.Data);
        path = cursor.GetString(columnIndex);
    return path;



  1. Set the Captured image from Camera to the ImageEditor as Bitmap Only. So you need to set the Bitmap as shown in below


protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
    if (data == null) data = mainIntent;
    if ((resultCode != Result.Ok) || (data == null))
    if (resultCode == Result.Ok)
        var uri = data.Data;
        if (requestCode == SELECT_FROM_GALLERY)
                Path = GetPathToImage(uri);
                editor.Bitmap = BitmapFactory.DecodeFile(Path);
            catch (Exception ex)
        else return;


2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile