安卓:使用Base64编码为en code图像为String [英] Android: using Base64 to encode an Image to String

查看:244
本文介绍了安卓:使用Base64编码为en code图像为String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了 Base64.java 从这里开始:

<一个href=\"http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.2_r1.1/android/util/Base64.java\" rel=\"nofollow\">http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.2_r1.1/android/util/Base64.java

包含方法的连接codeToString(),但其非常低的规模相比,现在我有previously。它只是一些750线code的。

which contains method encodeToString() but its very low sized compared to what i had previously. Its just some 750 lines of code.

在previous 1从这里下载:

the previous 1 was downloaded from here:

http://sourceforge.net/projects/iharder/files/

拥有2064线code,但不具有法的连接codeToString(),而不是它只有连接codeToFile()方法。

which has 2064 lines of code but doesn't have the method encodeToString() instead it has only encodeToFile() method.

哪一个是更可靠的?

我使用的目的的Base64 是转换的ByteArray 我从照相机API获取并将其发送到服务器(带连接codeD字符串)。

My purpose of using Base64 is to convert a ByteArray i get from Camera Api and send it to a Server(the encoded string).

感谢您

推荐答案

好吧,如果你想将EN codeD图像发送到您的服务器,你应该带code它变成一个字符串

Well, if you want to send the encoded image to your server, you should encode it into a String:

byte[] imageBytes = yourByteArray;
String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);

这篇关于安卓:使用Base64编码为en code图像为String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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