如何将图像转换成的base64串转换成、如何将、图像

2023-09-04 11:52:15 作者:别脏我唇.

我想转换形象立足64 EN code字符串。从发送给服务器 oma_status图标 XML格式。

但我正在逐渐不受支持的编码来自服务器的响应......

是那里图像转换为Base64字符串??

任何其他方式

plz..help ...

我的code是:

 位图bitmapOrg = BitmapFactory.de codeResource(getResources(),R.drawable.image);

        ByteArrayOutputStream宝=新ByteArrayOutputStream();
        bitmapOrg.com preSS(Bitmap.Com pressFormat.JPEG,100,宝);
        byte []的BA = bao.toByteArray();

         字符串BA1 = Base64.en codeBytes(BA);
 

解决方案

请使用code ..

 位图bitmapOrg = BitmapFactory.de codeResource(getResources(),R.drawable.image);
ByteArrayOutputStream宝=新ByteArrayOutputStream();
bitmapOrg.com preSS(Bitmap.Com pressFormat.JPEG,100,宝);
byte []的BA = bao.toByteArray();
字符串BA1 = Base64.en codeToString(BA,Base64.DEFAULT);
 

请输入

 进口android.util.Base64;
 
批量将图片转换成base64工具开发

I want to convert image to base 64 encode to string. from that to send to server with oma_status-icon xml format.

but I am getting unsupported encoding from the server response....

is there any other way to convert image to base64 string??

plz..help...

my code is:

        Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),  R.drawable.image);

        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 100, bao);
        byte [] ba = bao.toByteArray();

         String ba1=Base64.encodeBytes(ba);

解决方案

Please use this code..

Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),  R.drawable.image);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bitmapOrg.compress(Bitmap.CompressFormat.JPEG, 100, bao);
byte [] ba = bao.toByteArray();
String ba1=Base64.encodeToString(ba,Base64.DEFAULT);

Please import

import android.util.Base64;