0

I have a problem which is to convert image from String. That String is returned from PHP , not from drawable folder. My coding is not working well. Here is my code.

picturePath = jArray.getString("photo");
             cursor.close();
             Bitmap bm = ShrinkBitmap(picturePath, 300, 300);
             Bitmap resizedbitmap = Bitmap.createScaledBitmap(bm, 100, 100, true);
             img_Photo.setImageBitmap(resizedbitmap);

Please, Guide me some ways.

Halo
  • 729
  • 1
  • 8
  • 18
  • why do you want to convert image from string. If you have php server, you just send image path like http ://xxx.png to android and display it – henry4343 Jan 17 '14 at 08:34
  • check this http://stackoverflow.com/questions/8799290/convert-string-text-to-bitmap – Jaiprakash Soni Jan 17 '14 at 08:35
  • 1
    what does the string represent? Is that an url to the image or is it the image itself (coded in Base64)? – Blackbelt Jan 17 '14 at 08:39
  • @henry4343 Now, I have to change this image. PHP return the String like that ("User_Photo/828220944.png"). Use that String, I have to on ImageButton as an image. So, I think you got it. – Halo Jan 17 '14 at 08:40
  • @blackbelt It is image itself. – Halo Jan 17 '14 at 08:44
  • I think this string is image name stored in `User_Photo` folder on your server. Append the rest of address of your server and you got the image. Download it and show – DroidDev Jan 17 '14 at 08:45
  • @Vishwas Sharma Can you teach me some good ways... :) – Halo Jan 17 '14 at 08:46
  • You'll have to get the rest of the web url to your server and then append `User_Photo/828220944.png` to get the image. First check on you computer browser if it shows you the image with whole url. If it does, I can give you the code to download image. – DroidDev Jan 17 '14 at 08:49
  • @Halo check this for decoding image (in base 64 string) to bitmap http://stackoverflow.com/questions/16945194/android-decode-string-base-64-to-bitmap – Jaiprakash Soni Jan 17 '14 at 08:50

0 Answers0