How to Set Different Image Sources in the .NET MAUI Image Editor (SfImageEditor)?
The Syncfusion® .NET MAUI Image Editor (SfImageEditor) supports setting various image sources, such as Stream, URI, File, and Resource images. This guide explains how to configure different image sources using the Source property.
Load an image into the image editor using the Source property through the following image sources.
- Stream
- URL
- Local file
- Resource file.
Stream:
To load an image into the image editor using a Stream, you can follow this code sample:
public MainPage()
{
InitializeComponent();
SfImageEditor imageEditor = new SfImageEditor();
Assembly assembly = Assembly.GetExecutingAssembly();
imageEditor.Source = ImageSource.FromStream(() => assembly.GetManifestResourceStream("DifferentImageSources.Resources.Images.buildingimage.jpeg"));
this.Content = imageEditor;
}
URL:
To load an image from a URL into the image editor, use the following approach:
<ContentPage>
<imageEditor:SfImageEditor Source="https://dummyimage.com/300x200/000/fff.png"/>
</ContentPage>
Local file:
To load an image from a local file path into the image editor, use this sample code:
<ContentPage>
<imageEditor:SfImageEditor Source="D:\KB\buildingimage.jpeg"/>
</ContentPage>
Resource file:
Follow these steps to load an image into the image editor through the resource file.
- Add the image to the Resources folder in the .NET MAUI project using the drag-and-drop option.
- Provide the image name with its extension to the Source property.
<ContentPage>
<imageEditor:SfImageEditor Source="buildingimage.jpeg"/>
</ContentPage>
Output:
Conclusion
I hope you enjoyed learning how to set different image sources in the .NET MAUI Image Editor (SfImageEditor).
Refer to our .NET MAUI Image Editor feature tour page for other groundbreaking feature representations. You can also explore our .NET MAUI Image Editor documentation to understand how to present and manipulate data.
For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Image Editor and other .NET MAUI components.
Please let us know in the following comment section if you have any queries or require clarification. Contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!