将图像序列化为字符串 [英] Serialize image to a String

查看:97
本文介绍了将图像序列化为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

论坛的好朋友.

我一直在搜索很多东西,但找不到如何序列化图像并将其传递给android中的String.

I've been searching a lot, and I could not find how to serialize an image and pass it to a String in android.

可能不是这样,如果有人知道并想告诉我,我将非常感谢!.

as might be not so, If someone knows and wants to inform me I would appreciate very much!.

推荐答案

Base64将是可靠地以字符串形式传输二进制数据(例如图像)的最有效方法.

Base64 will be the most efficient way to reliably transfer binary data (such as an image) in a string.

但是,由于请求的内容较小,因此您可以考虑对图像进行base64编码,然后压缩结果字符串,然后对base64进行编码...

However, since you are requesting something smaller, you may consider base64 encoding your image, then compressing the resultant string, then base64 encoding that...

它可以为您节省一些字节,但不会节省很多.在某些情况下,甚至可能使结果更大.

It saves you a few bytes, but not many. And in some cases it may even make the result larger.

如果您同时控制服务器和客户端,则应考虑创建另一个允许发送字节的接口.

If you have control of both the server and the client, you should consider creating another interface that would allow you to send bytes.

这篇关于将图像序列化为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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