【发布时间】:2015-06-03 06:20:28
【问题描述】:
我正在开发一个应用程序,它从 php-server 下载图像并在图像视图中显示图像..但是当我从 php 页面接收图像时
if (!empty($result)) {
if (mysql_num_rows($result) > 0) {
$result = mysql_fetch_array($result);
$user = array();
$user["image"] = base64_encode($result["image"]);
$response["success"] = 1;
$response["image_table"] = array();
array_push($response["image_table"], $user);
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "No Image found";
echo json_encode($response);
}
它给了我这样的json响应
03-30 04:43:44.013: D/Image:(2770): {"success":1,"image_table": [{"image":"\/9j\/4VeRRXhpZgAASUkqAAgAAAAMAAABBAABAAAA..........
03-30 04:43:44.253: D/skia(2770): --- decoder->decode returned false
我正在将此图像字符串解码为这样的位图....
json= jsonParser.makeHttpRequest(url_img_address, "GET", params);
Log.d("Image: ", json.toString());
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
address = json.getJSONArray(TAG_IMAGE_TABLE);
for (int i = 0; i < address.length(); i++) {
JSONObject c = address.getJSONObject(i);
image = c.getString(TAG_IMAGE);
byte[] dwimage = Base64.decode(image.getBytes());
System.out.println(dwimage);
bmp = BitmapFactory.decodeByteArray(dwimage, 0, dwimage.length);
}
} else {
}
} catch (JSONException | IOException e) {
e.printStackTrace();
}
我使用这个 bm 到 onotherclass 将 bmp 设置为 imageview
ivProperty.setImageBitmap(bmp);
但它没有显示任何内容......我的 asynck 任务活动没有完成,它继续运行...... 我的问题是如何将 bmp 显示到 imageview 以及为什么我的 asyncktask 没有完成........thx 提前....
【问题讨论】:
-
朋友们,我需要你的帮助.......帮帮我
-
byte[] decodedString = Base64.decode(encodedImage, Base64.DEFAULT);位图decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
-
嘿@signare 不工作....
标签: php android mysql json android-bitmap