Articles in this section
Category / Section

How to retrieve an image from the saved location in UWP?

2 mins read

Description:

In image editor, by default, the image is saved into the Pictures directory. You can retrieve and display the image stored in the location using the following steps:

 

Step 1: Create an image editor sample with all the necessary assemblies.

 

Please refer to this getting started documentation to create a simple SfImageEditor sample and configure it.

 

Step 2: The ImageSavedEventArgs is used to get the saved image location as its argument. Using this location, you can load an image to the image editor.

 

The following code sample demonstrates how to retrieve an image from the saved location.

C#

private void Editor_ImageSaved(object sender, ImageSavedEventArgs args)
{
    var location = args.Location; // gets the imaged saved location
    RetriveImageFromLocation(location, retrivedImage); // load the image from saved location
}
 
public async void RetriveImageFromLocation(string location, Image image)
{
    var file = await StorageFile.GetFileFromPathAsync(@"" + location);
    var stream = await file.OpenStreamForReadAsync();
    var bitMap = new BitmapImage();
    IRandomAccessStream randomAccessStream = stream.AsRandomAccessStream();
    await bitMap.SetSourceAsync(randomAccessStream);
    image.Source = bitMap;
}

 

You can find the sample for retrieving image from saved location in this link: Sample.

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied