Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.

Paste

Pasted as Java by Khan ( 13 years ago )
BitmapFactory.Options bmOptions;
               bmOptions = new BitmapFactory.Options();
               bmOptions.inSampleSize = 1;
               bitmap = LoadImage(strMainImageLink, bmOptions);
               ivMainImage.setImageBitmap(bitmap);

private Bitmap LoadImage(String URL, BitmapFactory.Options options)
   {      
    Bitmap bitmap = null;
    InputStream in = null;      
       try {
           in = OpenHttpConnection(URL);
           bitmap = BitmapFactory.decodeStream(in, null, options);
           in.close();
       } catch (IOException e1) {
       }
       return bitmap;              
   } 

private InputStream OpenHttpConnection(String strURL) throws IOException{
   InputStream inputStream = null;
   URL url = new URL(strURL);
   URLConnection conn = url.openConnection();

   try{
    HttpURLConnection httpConn = (HttpURLConnection)conn;
    httpConn.setRequestMethod("GET");
    httpConn.connect();

    if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
     inputStream = httpConn.getInputStream();
    }
   }
   catch (Exception ex)
   {
   }
   return inputStream;
  }

 

Revise this Paste

Parent: 51212
Your Name: Code Language: