【问题标题】:skia decoder->decode returned false when download image and display in imageview下载图像并在图像视图中显示时,skia解码器->解码返回false
【发布时间】:2015-06-04 19:51:06
【问题描述】:

我有一个 php 页面,它以 json 格式从 php 页面返回图像

 $result = mysql_query("SELECT image FROM image_table WHERE email_id = '$email'");

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);
    }

返回给我类似的东西

  {"success":1,"image_table":[{"image":"iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD\/gAIDAAAAA3NCSVQFBgUzC42AAAAgAElEQVR4nDS70Y8c2XXm+WXUiewTyYhi3GIGO4Nkkgx2J1tZraLMsptyU6sWRMGtdQte2dLsGB4NsLPQww4wuy8LP

当我在我的班级 imageview 中使用它时,会显示我的图像......并且 asynctask 活动继续运行......

 class LoadImage extends AsyncTask<String, String, String> {
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(MainActivityMap.this);
        pDialog.setMessage("Loading Image. Please wait...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }
    protected String doInBackground(String... args) {
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("username", email));
            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);
                         InputStream stream = new ByteArrayInputStream(Base64.decode(image.getBytes(), Base64.DEFAULT));
                         bmp=BitmapFactory.decodeStream(stream); 


                    } 
                } else {

                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        return null;
    }

protected void onPostExecute(String file_url) {
        pDialog.dismiss();
        ivProperty.setImageBitmap(bmp);


    }

}

当我在我的 asuncktask 中使用它时....我还有一个 logcat 结果..i.e

03-31 18:16:03.358: D/skia(2622): --- decoder->decode returned false

这是什么问题以及如何解决它......提前谢谢

【问题讨论】:

    标签: android android-asynctask android-imageview inputstream android-bitmap


    【解决方案1】:

    试试这个,

    String strPicture;
    for (int i = 0; i < address.length(); i++) {
     JSONObject c = address.getJSONObject(i);
     strPicture= c.getString(TAG_IMAGE);
     byte bytePic[] = null;
            try {
                bytePic = Base64.decode(strPicture, Base64.DEFAULT);
            } catch (Exception e) {
                e.printStackTrace();
            }
    
            if (bytePic != null) {
                ByteArrayInputStream imageStream = new ByteArrayInputStream(
                        bytePic);
                Bitmap theImage = BitmapFactory.decodeStream(imageStream);
                imageStream.reset();
                imageView.setImageBitmap(theImage); //Setting image to the image view
            }
    }
    

    【讨论】:

    • 04-01 12:52:09.839: D/skia(2771): --- SkImageDecoder::Factory 返回 null 这是我的 json 回复 @HappyMan 04-01 12:52:09.723: d /图像:(2771):{ “成功”:1, “image_table”:[{ “图像”:“\ / 9J \ / 4AAQSkZJRgABAQEAYABgAAD \ / 4RDcRXhpZgA ATU0AKgAAAAgABAE7AAIAAAAGAAAISodpAAQAAAABAAAIUJydAAEAAAAMAAAQyOocAAcAAAgMAAAAPgAA AAAc6gAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAA 跨度>
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多