Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android高分辨率图像base64编解码中的问题_Android_Encoding_Base64_Decoding - Fatal编程技术网

Android高分辨率图像base64编解码中的问题

Android高分辨率图像base64编解码中的问题,android,encoding,base64,decoding,Android,Encoding,Base64,Decoding,我使用Base64将图像转换为字符串,我使用下面的代码来实现这一点 Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.facebook); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG,100 , st

我使用Base64将图像转换为字符串,我使用下面的代码来实现这一点

 Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.facebook);  
         ByteArrayOutputStream stream = new ByteArrayOutputStream();
            bitmap.compress(Bitmap.CompressFormat.PNG,100 , stream);
            byte [] byte_arr = stream.toByteArray();
            String image_str = Base64.encodeToString(byte_arr, Base64.NO_WRAP);
通过使用名称-值对,我会将此图像发送到服务器,在另一个活动中,我需要获取此图像,并使用以下代码对图像进行解码

byte[] decodedString = Base64.decode(imageStr, Base64.NO_WRAP);
                Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);


                System.out.println("bitmap "+decodedByte);
                imageViewProfile.setImageBitmap(decodedByte);   
当我打印此解码字节时,它将给出null


如果图像的分辨率很小,它会工作得很好,感谢您的帮助

尝试将Base64.NO\u WRAP更改为Base64.DEFAULTya我尝试过,但没有更改,它将返回null。实际上我想把照片上传到高分辨率的服务器上。你上传图像也失败了吗?你不应该用这种方法用base64编码大图像。你会有内存问题。您不应该对图像进行编码或使用流编码器。@carnal图像已成功上载,但使用json解析获取图像iam,而am GETT字符串是服务器中存在字符串的一半