Click to See Complete Forum and Search --> : Need help loading a bitmap from XML file


msuttorp
June 4th, 2002, 02:19 AM
I need to read a base64 encoded (XmlTextWriter.WriteBase64) image from an XML file.
Since I treat the XML file as an XmlDocument, I have direct access to the elements and I have no problem to read the XML fragment itself.

My problem is:
I cannot find a way to properly create the image from the XML fragment. I have tried reading the relevant Xml fragment into a stream via XmlTextReader (because I need to decode with ReadBase64) and then create a Bitmap from that stream, but that doesn't work.

Also as a traditional C++ programmer with strong C roots I find it rather unelegant to keep copying data back and forth into different type of buffers all the time (XmlDocument->byte[]->Stream->Bitmap) , just because the language uses strong typing. I'm feeling quite uncomfortable with such inefficiency. But if this is the only way, I guess I just have to live with that.

Can you help?
Thanx.