0

i ont une page php qui renvoie l'image de la page php au format JSONskia Decodeur> decode retourne faux lorsque l'image de téléchargement et d'affichage dans imageview

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

qui me retourner quelque chose comme

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

quand je l'utilise dans ma classe imageview dosent montrent mon image .... et l'activité asynctask continue en cours d'exécution ......

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


    } 

} 

quand je l'utilise dans mon asuncktask .... j'ai un résultat logcat ..ie

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

quel est le problème et comment le résoudre ...... thx à l'avance

+0

si quelqu'un sait la réponse me aider alors ............ – Tufan

+0

Aidez-moi à des amis que j'ai besoin d'aide ur ...... – Tufan

Répondre

0

Essayez ceci,

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 
     } 
} 
+0

04-01 12:52 : 09.839: D/skia (2771): --- SkImageDecoder :: Usine retournée nulle et ceci est ma réponse json @HappyMan 04- 01 12: 52: 09,723: D/Image: (2771): { "succès": 1, "image_table": [{ "image": "\/9j \/4AAQSkZJRgABAQEAYABgAAD \/4RDcRXhpZgA ATU0AKgAAAAgABAE7AAIAAAAGAAAISodpAAQAAAABAAAIUJydAAEAAAAMAAAQyOocAAcAAAgMAAAAPgAA AAAc6gAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ – Tufan

+0

Thx @Happyman maintenant ça marche – Tufan