android: webservice image replace with images in Local folder

后端 未结 2 464
盖世英雄少女心
盖世英雄少女心 2021-01-16 18:46

I am into final stage of chat application in android.

I am facing few issues while working with images and web service.

So when i select the image and sent

2条回答
  •  别那么骄傲
    2021-01-16 19:07

    use this method to convert url into image Bitmap bi=convertImage(url);, mention your image sizes in this line

    bit=Bitmap.createScaledBitmap(bm,120, 120, true);

    public Bitmap convertImage(String url)
             {
    
                URL aURL = null;
                try 
               {
                final String imageUrl =url.replaceAll(" ","%20");
                Log.e("Image Url",imageUrl);
                aURL = new URL(imageUrl);
                URLConnection conn = aURL.openConnection();
                InputStream is = conn.getInputStream(); 
    
                BufferedInputStream bis = new BufferedInputStream(is); 
                Bitmap bm = BitmapFactory.decodeStream(new PatchInputStream(bis)); 
                if(bm==null)
                {}
                else
                  bit=Bitmap.createScaledBitmap(bm,120, 120, true);
    
                return bm;
    
               } 
    
    
                catch (IOException e) 
                {
                   Log.e("error in bitmap",e.getMessage());
                  return null;
               }
    
    
              }
    

    Set returned bm(bitmap) to your ImageView imageview.setImageBitmap(bi) feel free to ask doubts

提交回复
热议问题