Skip to content Skip to sidebar Skip to footer

Convert String To Image In Android?

So, here is the thing. I am receiving an imagepath through WebService. I am storing the imagepath in a String. Now I want to convert the String to Bitmap and display the image in a

Solution 1:

Oh God, you can't convert a String of image path into a Bitmap! The image path isn't the image itself! You need to download the image from internet through the image path and store it into a local file. The you need to call this:

Bitmapbm= BitmapFactory.decodeFile(localImagePath);

to load the Image.

Solution 2:

Use this link:

http://www.androidhive.info/2012/07/android-loading-image-from-url-http/

Its very simple and then use this code:

intloader= R.drawable.loader;

    // Imageview to showImageViewimage= (ImageView) findViewById(R.id.image);

    // Image urlStringimage_url="http://api.androidhive.info/images/sample.jpg";

    // ImageLoader class instanceImageLoaderimgLoader=newImageLoader(getApplicationContext());

    // whenever you want to load an image from url// call DisplayImage function// url - image url to load// loader - loader image, will be displayed before getting image// image - ImageView
    imgLoader.DisplayImage(image_url, loader, image);

Hope it will helps you..

Post a Comment for "Convert String To Image In Android?"