我在将字节数组转换为位图时遇到问题。现在我想要实现的是我将图像作为字节数组并尝试转换为位图,以便我可以显示图像。但在我的位图输出中运行以下代码后,我得到空值。
String t= "byte array of the image";
byte[] temp = t.getBytes() ;
Bitmap bmp = BitmapFactory.decodeByteArray(temp, 0, temp.length);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
System.out.println("bitmap output"+bmp);
我用谷歌搜索了很多,发现这段代码适用于每个人。请有人告诉我我哪里做错了。
提前致谢
最佳答案
In my case this is working
String result = "here imge;
if (result != "") {
byte[] bloc = Base64.decode(result);
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 8;
Bitmap b = BitmapFactory.decodeByteArray(bloc, 0, bloc.length);
关于java - 将字节数组显示为位图以在 Android 中获取图像的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18799394/