Pasting an image into a Infopath rich text box and submitting the form results in an xml inline image of the format
<img style=".." src="msoInline/f4b19f6546fa4081" xd:inline="...." />
Using System.Convert.FromBase64String the xd:inline innertext can be converted to an image.
However how do I convert the src innertext to something readable. And does it contain the mime type of the image ?
There actually isn't a MIME type stored with the image anywhere. The src
data isn't good to anyone besides InfoPath, probably.
The image should be of type GIF or JPG, which you can get at by sniffing the
first few bytes of the converted Base64. I don't believe we keep BMP or PNG
formats, but instead convert them to a universal web format.
Thanks,
Brian
> Pasting an image into a Infopath rich text box and submitting the form
> results in an xml inline image of the format
[quoted text clipped - 6 lines]
> However how do I convert the src innertext to something readable. And does
> it contain the mime type of the image ?
vveen - 23 Jul 2004 10:02 GMT
Thanks for your quick reply Brian
I tried reading the first 16 bytes of the converted Base64 and converted these into a GUID which I used to construct a System.Drawing.Imaging.ImageFormat.
However the System.Drawing.Imaging.ImageFormat does not return any of the available image types.
What am i doing wrong ?
> There actually isn't a MIME type stored with the image anywhere. The src
> data isn't good to anyone besides InfoPath, probably.
[quoted text clipped - 16 lines]
> > However how do I convert the src innertext to something readable. And does
> > it contain the mime type of the image ?
vveen - 23 Jul 2004 11:24 GMT
Ok found the solution myself, I am new to the System.drawing class so thats why i was lost.
Sniffing the first bytes did not help me, but, reading the complete image into a bitmap object did the job for me.
I did the following:
Dim objMemStream As New MemoryStream(System.Convert.FromBase64String(Base64String))
Dim objBitMap As New System.Drawing.Bitmap(objMemStream)
Dim objImageFormat As New System.Drawing.Imaging.ImageFormat(objBitMap.RawFormat.Guid)
strMimeType = ImageFormatName(objImageFormat)
Where ImageFormatName is a function using the equal() the determine the mime type, see: http://www.codeproject.com/cs/database/albumviewer.asp?msg=620693#xx620693xx
Thanks for all your help
> Thanks for your quick reply Brian
>
[quoted text clipped - 24 lines]
> > > However how do I convert the src innertext to something readable. And does
> > > it contain the mime type of the image ?
Andrew Ma [MSFT] - 23 Jul 2004 19:17 GMT
We have a blog entry about decoding base64 using managed code:
http://blogs.msdn.com/infopath/archive/2004/04/21/117600.aspx
It's pretty similar if you are trying to encode. Just copy everything into a
memory stream and then use GetBuffer()

Signature
Andrew J. Ma
Software Test Engineer
Microsoft Office InfoPath
http://blogs.msdn.com/ajma
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias. This alias is for
newsgroup purposes only.
> Ok found the solution myself, I am new to the System.drawing class so
> thats why i was lost.
[quoted text clipped - 53 lines]
>> > > does
>> > > it contain the mime type of the image ?