ExportToImage for saving diagram's image in database

2 posts, 0 answers
  1. Egemen
    Egemen avatar
    34 posts
    Member since:
    Apr 2012

    Posted 10 Jun 2013 Link to this post

    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
  2. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 12 Jun 2013 Link to this post

    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.

  3. DevCraft banner
Back to Top