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.
Unfortunately, activation email could not send to your email. Please try again.

How to convert images to stream and byte array?

This article explains you on how to convert image to byte array, stream to byte array, bytearray to stream and load them as image.

Import the SfImageEditor namespace as shown below,

 

Xaml

 

 

 

  1. How to get the image as stream?

 

Create a Xamarin application and initialize SfImageEditor control in it. Provide the Source for the image as in the below code snippet.

 

Xaml

 

 

Use the inbuilt ImageSaving event of the SfImageEditor to get the stream of the image being saved. The stream can be obtained from the ImageSavingEventArgs

Xaml

 

 

Add the corresponding ImageSaving event implementations in the adjacent .xaml.cs file.

 

C#

 

 

The above code snippet obtains the current stream of the image being saved.

 

  1. How to convert the image stream to byte array?

 

To convert the image stream as bytearray, use the stream obtained from the ImageSavingEventArgs from the ImageSaving event as in the below code snippet:

 

 

 

For a better understanding of the conversion of images to streams, streams to bytearray, image to bytearray, bytearray to stream and finally show them as an Image, please refer the below sample link:

 

http://www.syncfusion.com/downloads/support/directtrac/general/ze/HOWTOC~11143924326.zip

 

 

 

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
8887 06/28/2018 07/05/2018 Xamarin.Forms SfImageEditor
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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.