Picture Box Loaded from Web Service Data Source

4 posts, 0 answers
  1. Eric
    Eric avatar
    2 posts
    Member since:
    May 2011

    Posted 09 Jul Link to this post

         I am attempting to use the standalone report designer to populate a report from a Web Service Data Source.  The source will return an image as a byte array (byte[] someImage {get;set;}.  I can see the bytes coming from the web service just fine but when I set the bindings to bind the value to the byte array from the web service the report throws an exception that indicates: "Could not find a part of the path...(encoded byte array here".  I am sending in bytes but the picture box is interpreting the value property as only the path and not the bytes.  Is this possible?  Am I doing this incorrectly?  Do I need to use the Visual Studio designer instead?  Any help or guidance would be appreciated...thanks in advance.

  2. Nasko
    Admin
    Nasko avatar
    1023 posts

    Posted 10 Jul Link to this post

    Hello Eric,

    If the a data field contains a base64 string you will need to programmatically convert the base64 string to binary image data before assigning it to the PictureBox item. The approach to convert the base64 string to binary image data is to use a user function in the PictureBox.Value expression:

    PictureBox.Value = GetImageFromBase64String(Fields.ImageData)

    where the GetImageFromBase64String user function definition would be similar to this code snippet:
    namespace UserFunctions
    {
        public static class ImageHelper
        {
            public static Image GetImageFromBase64String(string base64String)
            {
                byte[] imageBytes = Convert.FromBase64String(base64String);
                Image image;
                using (System.IO.MemoryStream ms = new System.IO.MemoryStream(imageBytes))
                {
                    image = Image.FromStream(ms);
                }
         
                return image;
            }
        }
    }

    For more information, please refer to the User Functions help article.

    Regards,
    Nasko
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Eric
    Eric avatar
    2 posts
    Member since:
    May 2011

    Posted 10 Jul in reply to Nasko Link to this post

    Can this be done from the Standalone Report Designer?
  4. Nasko
    Admin
    Nasko avatar
    1023 posts

    Posted 11 Jul Link to this post

    Hello Eric,

    Yes, user functions are supported in the Standalone Report Designer by extending its configuration: Extending Report Designer.

    Regards,
    Nasko
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top