IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Loading images from base64 encoded strings
idtluc0210726780
post May 9 2019, 11:29 PM
Post #1


Member
**

Group: Members
Posts: 10
Joined: 8-June 17
Member No.: 63629



So, I'm trying to display images in a report that are encoded in a database as base64 encoded strings.

I've tried a couple of options, neither of which work. I just get a blank picture and no errors;

Both of these options were placed into the _BeforePrint handler.

CODE
// Just use image location as per a couple of stack overflow answers
picture.ImageLocation = (string)Report.GetColumnValue("Data.image");

// Load the image into an Image object and assign that to the image property.
Image i;
byte[] image = Convert.FromBase64String((string)Report.GetColumnValue("Data.image"));
using (var ms = new MemoryStream(image, 0, image.Length)){
i = Image.FromStream(ms, true);
}
picture.Image = i;


Anyone have any ideas? This has been asked before, and I found an example in the forum, but the example file is no longer available. And since the question was quite old I didn't want to necro it.


Thanks,
L.
Go to the top of the page
 
+Quote Post
idtluc0210726780
post May 12 2019, 08:00 PM
Post #2


Member
**

Group: Members
Posts: 10
Joined: 8-June 17
Member No.: 63629



Ok, never mind. After a lot of trial and error, it turns out this was not working because I still had the DataColumn property set on the image. This does not appear to be overridden, unlike other controls such as text (such as when you TextControl.Text = "some text").
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Time is now: 20th June 2019 - 01:44 PM