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 retrieve a edited image as a stream in an image editor

Platform: WPF |
Control: SfImageEditor

This section explains how to retrieve the stream of the edited image. This retrieved stream can be used for exporting functions.

To retrieve the stream of the edited image, follow the below steps.

Step 1: Initialize the image editor.

XAML

    <editor:SfImageEditor x:Name="editor" 
                               ImageSource="Assets\RoadView.jpeg" >
        </editor:SfImageEditor>

 

Step 2:  By default, on clicking the save icon in the toolbar, picker will be opened to pick the desired the saving location, to hide this functionality invoke the ToolbarItemSelected event and set Cancel to true for the save item alone in the arguments as shown in the below snippet.

XAML

  <editor:SfImageEditor.ToolbarSettings>
                <editor:ToolbarSettings ToolbarItemSelected="ToolbarSettings_ToolbarItemSelected"></editor:ToolbarSettings>
            </editor:SfImageEditor.ToolbarSettings>

C#

        /// <summary>
        /// Invoked when toolbar item is clicked.
        /// </summary>
        /// <param name="sender">Toolbar item</param>
        /// <param name="e">event arguments</param>
        private void ToolbarSettings_ToolbarItemSelected(object sender, ToolbarItemSelectedEventArgs e)
        {
            /// Cancel the default functionality only for save icon.
            if (e.ToolbarItem.Name == "Save")
            {
                e.Cancel = true;
                editor.Save();
            }
        }

 

Step 3: Invoke ImageSaving event to retrieve the current stream of the edited image as in the below snippet.

XAML

   <editor:SfImageEditor x:Name="editor" ImageSaving="Editor_ImageSaving" 
>
        </editor:SfImageEditor>
 

C#

        /// <summary>
        /// Invoked before image getting saved.
        /// </summary>
        /// <param name="sender">Image editor</param>
        /// <param name="e">event arguments</param>
        private void Editor_ImageSaving(object sender, ImageSavingEventArgs e)
        {
            e.Cancel = true;
            e.Stream.Seek(0, 0);
            BitmapImage bitmapImage = new BitmapImage();
            bitmapImage.BeginInit();
            bitmapImage.StreamSource = e.Stream;
            bitmapImage.EndInit();
            image.Source = bitmapImage;
        }
 

 

You can use the retrieved stream for exporting purpose. In this demonstration retrieved stream is set to source for Image control on the right side as shown in the below image.

Screenshot:

Retrieve the stream

Sample for retrieving the stream of the edited image can be referred here.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
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