Convert Image to Bytes and save in Xml

2019-03-05 22:29发布

I need to convert byte [] of an image to a format that can be saved in a xml. I tried to convert to a string but not worked. The xml file after 5 images saved was about the size of 50mb! I need to convert to a simpler format for this xml file can not be too heavy.

2条回答
你好瞎i
2楼-- · 2019-03-05 23:13

Consider using a Base64 format - you lose some efficiency but the data will be encapsulated. For example

<image name="MyPhoto.jpg">WFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbm</image>

You can convert to Base64 using Convert.ToBase64

查看更多
姐就是有狂的资本
3楼-- · 2019-03-05 23:30

Try compressing the byte array and hope the size will be smaller :). For example check :DeflateStream and hope the size will be reduced :)

查看更多
登录 后发表回答