This is a migrated thread and some comments may be shown as answers.

How to Save the Image in RadImageEditor to Byte Array

2 Answers 157 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
samjayander
Top achievements
Rank 1
samjayander asked on 17 Dec 2013, 01:34 PM
I want to save the image in the Image Editor to byte[]. How to achieve this? Is there any example available?

Thanks in Advance,

SamJayander.

2 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 20 Dec 2013, 11:22 AM
Hi SamJayander,

You can use one of the format providers that come with the control to export the image in the control. More information is available here. Additionally to creating a stream as demonstrated in the snippets, the format providers have an overload which returns a byte array which you could use.

Let me know if you need further assistance.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
samjayander
Top achievements
Rank 1
answered on 21 Dec 2013, 06:24 AM
Hi,

Thanks, I used the below code to save the image to a Byte Array.

byte[] _selectedPhoto = null;
IImageFormatProvider formatProvider = ImageFormatProviderManager.GetFormatProviderByExtension(".png");
using (MemoryStream memStrm = new MemoryStream())
{
    formatProvider.Export(ImageEditorUI.Image, memStrm);
 
    if (memStrm.Length > int.MaxValue)
    {
        throw new ApplicationException("Image is too large.");
    }
    _selectedPhoto = new byte[memStrm.Length];
    memStrm.Position = 0;
    memStrm.Read(_selectedPhoto, 0, (Int32)memStrm.Length);
}



Thanks and Regards,

SamJayander T.
Tags
ImageEditor
Asked by
samjayander
Top achievements
Rank 1
Answers by
Petya
Telerik team
samjayander
Top achievements
Rank 1
Share this question
or