我需要使用以下代码将编码的base64字符串转换为图像Im:
- (UIImage *)decodeBase64ToImage:(NSString *)strEncodeData {
NSData *data = [[NSData alloc]initWithBase64EncodedString:strEncodeData options:NSDataBase64DecodingIgnoreUnknownCharacters];
return [UIImage imageWithData:data];
}
//但它只显示一张图片:(
在Android中我正在使用此代码:
public static Bitmap byteToImage(String byteArray)
{
Bitmap bitmap = null;
try {
byte[] decodedString = Base64.decode(byteArray,Base64.NO_WRAP);
InputStream inputStream = new ByteArrayInputStream(decodedString);
bitmap = BitmapFactory.decodeStream(inputStream);
} catch (Exception e) {
Log.e("byteToImage.EROOR.........", e.getMessage());
}
return bitmap;
}
有什么好主意或解决方案吗?
答案 0 :(得分:0)
这是我的android代码。它运作良好!
public static Bitmap byteToImage(String byteArray)
{
Bitmap bitmap = null;
try {
byte[] decodedString = Base64.decode(byteArray,Base64.NO_WRAP);
InputStream inputStream = new ByteArrayInputStream(decodedString);
bitmap = BitmapFactory.decodeStream(inputStream);
} catch (Exception e) {
Log.e("byteToImage.EROOR.........", e.getMessage());
}
return bitmap;
}