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

Convert to byte[] for database upload

1 Answer 36 Views
ImageEditor
This is a migrated thread and some comments may be shown as answers.
Jessica B.
Top achievements
Rank 1
Jessica B. asked on 10 Jan 2019, 09:58 PM

I was able to successfully convert FROM byte[] to MemoryStream to load an image from the database into the editor, but now when it comes to saving I am not able to convert the image TO byte[].

Using

Telerik.Web.UI.ImageEditor.EditableImage newimg = args.Image;

 

 does not result in a type that can be converted to byte[]. Or does it? I can't even seem to convert it to a Stream.

1 Answer, 1 is accepted

Sort by
0
Jessica B.
Top achievements
Rank 1
answered on 16 Jan 2019, 08:56 PM

I was able to accomplish this with the following code:

Telerik.Web.UI.ImageEditor.EditableImage newimg = args.Image;
 
                using (var stream = new MemoryStream())
                {
                    newimg.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    newByte = stream.ToArray();
                }
 
                image.Content = newByte;
               mydatabase.SaveChanges();
Tags
ImageEditor
Asked by
Jessica B.
Top achievements
Rank 1
Answers by
Jessica B.
Top achievements
Rank 1
Share this question
or