Page 1 of 1

Loading Image as a data url

Posted: Tue May 16, 2023 11:34 am
by EricS
Which method I need to load a image via a data url?
The image data ist stored in a database, as string.

Example: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAlgAAAEsCAYAAAAfPc2WAAAS2ElEQVR4Xu3dMYusZwEF4BOsbNSAnYWo6TWE" and lot more


Thank you
Eric

Re: Loading Image as a data url

Posted: Wed May 17, 2023 4:57 pm
by EricS
I solved it by some extra code:

Code: Select all

                var base64Data = Regex.Match(data, @"data:image/(?<type>.+?),(?<data>.+)").Groups["data"].Value;
                var binData = Convert.FromBase64String(base64Data);

                GdPictureImaging image = new GdPictureImaging();
                var imageId = image.CreateGdPictureImageFromByteArray(binData);

Re: Loading Image as a data url

Posted: Wed May 17, 2023 5:08 pm
by Hugo
Hi Eric,

Thanks for posting your message here aswell as contacting us on our helpdesk.

I am glad you managed to solve this issue here.

Have a great day.

Regards,
Hugo Cudd
Technical Support

Re: Loading Image as a data url

Posted: Fri Jun 23, 2023 5:29 pm
by EricS
I think so, I use it on Windows, written in C#.
But only basic functions are used, so it should work everywhere. Split up the data url to get the plain data without the header, convert it from base64 to binary, load it into GDPicture