将图像转换为字节并保存在Xml中 [英] Convert Image to Bytes and save in Xml

查看:153
本文介绍了将图像转换为字节并保存在Xml中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将图像的byte []转换为可以保存在xml中的格式。
我试图转换为字符串但没有工作。
保存5张图片后的xml文件大小约为50mb!
我需要转换为更简单的格式,这个xml文件不能太重。

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.

推荐答案

考虑使用 Base64 格式 - 您会失去一些效率,但数据将被封装。例如

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

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

您可以使用 Convert.ToBase64

You can convert to Base64 using Convert.ToBase64

这篇关于将图像转换为字节并保存在Xml中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆