Soru & Cevap

imageloader ile büyük resim çekmek ...

02.09.2014 - 02:11

Merhabalar,

imageloader ile uzak sunucudan resim çekiyorum. küçük böyutlu resimleri çekdiğimde sorunsuz çalışıyor. 120 KB buyuk resimler çekdiğim zaman ise çalışmıyor nullpointerexception döndürüyor. Bu sorunu nasıl çöze bilirim?

yazdığım kod aşağıdaki

[code]

ImageLoader imgLoader = new ImageLoader(context);
        Bitmap bm=imgLoader.getBitmap(url);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.JPEG, 100, stream);
        byte[] byteArray = stream.toByteArray();
        return byteArray;

[/code]

şimdiden teşekkrler

1 Görüntülenme

1 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-7730-1383655584.png
egemen.durmus
04.09.2014 - 02:48

on create in içine 

    new LoadImage().execute(url adresin);

sonrasında ;

 private class LoadImage extends AsyncTask<String, String, Bitmap> {
    @Override
        protected void onPreExecute() {
            super.onPreExecute();
            pDialog = new ProgressDialog(main.this);
            pDialog.setMessage("Loading Image ....");
            pDialog.show();
    }
       protected Bitmap doInBackground(String... args) {
         try {
               bitmap = BitmapFactory.decodeStream((InputStream)new URL(args[0]).getContent());
        } catch (Exception e) {
              e.printStackTrace();
        }
      return bitmap;
       }
       protected void onPostExecute(Bitmap image) {
         if(image != null){
          KENDİ İMAGEVİEW'NİN İSMİ.setImageBitmap(image);
           pDialog.dismiss();
         }else{
           pDialog.dismiss();
           Toast.makeText(main.this, "Image Does Not exist or Network Error", Toast.LENGTH_SHORT).show();
         }
       }
   }

Mushfig
05.09.2014 - 11:13
teşekkür ederim. çok doğru kod. çok iyi çalıştı
egemen durmuş
05.09.2014 - 11:17
rica ederim iyi çalışmalar..