**$sql = 'select * from dish_category';
$results =$conn->query($sql);
$spots = array(); //array to parse jason from
while($spot = $results->fetch_assoc()){
$spots[] = $spot;
}
foreach($spots as $key=>$value){
$newArrData[$key] = $spots[$key];
$newArrData[$key]['Cat_Image'] = base64_encode($spots[$key]['Cat_Image']);
}
header('Content-type: application/json');
echo json_encode($newArrData);**
上面是PHP代码,它工作得很好并返回JSON字符串,现在我很困惑如何解析android中的图像(解码base64)?
答案 0 :(得分:0)
你应该逐一做到:
ByteArrayInputStream
using the byte array. BitmapFactory.decodeStream(inputStream)
答案 1 :(得分:0)
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0,
decodedString.length);