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

ExportToImage for saving diagram's image in database

1 Answer 51 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Egemen
Top achievements
Rank 1
Egemen asked on 10 Jun 2013, 02:36 PM
Hi,

I'd like to export and save the image of diagram in database.
I try to do this...

 Byte[] bytes = null;
            using (var stream = new MemoryStream())
            {
                diagram.ExportToImage(stream, null, new Rect(0, 0, 400, 400), new Size(200, 200), backgroundBrush: new     SolidColorBrush(Colors.White));
                bytes = new Byte[stream.Length];
                stream.Read(bytes, 0, bytes.Length);
            }

Here is the result   0x000000000000000000000000000000000000......................................

Thank you

1 Answer, 1 is accepted

Sort by
0
Miro Miroslavov
Telerik team
answered on 12 Jun 2013, 07:04 AM
Hello Egemen,

 You have to re-position the Stream to its beginning before reading it or you can use some special StreamReader for example.

Byte[] bytes = null;
            using (var stream = new MemoryStream())
            {
                TemplateEditorDiagram.ExportToImage(stream, null, new Rect(0, 0, 400, 400), new Size(200, 200), backgroundBrush: new SolidColorBrush(Colors.White));
                bytes = new Byte[stream.Length];
                stream.Position = 0;               
                stream.Read(bytes, 0, bytes.Length);
            }

Regards,
Miro Miroslavov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Diagram
Asked by
Egemen
Top achievements
Rank 1
Answers by
Miro Miroslavov
Telerik team
Share this question
or