0

I have a following binary data (byte array) "The image's binary data received from server" that i receive from my server in String format. How do I convert it back to image in Android.

6
  • possible duplicate of how to convert binary data to image? Commented Sep 25, 2015 at 3:58
  • @KTAnj nope didnot work Commented Sep 25, 2015 at 4:07
  • don't you have url of the photo that would be way effective Commented Sep 25, 2015 at 5:58
  • @KaranMer I do actually.. I was told that this way it would be faster, so I was trying to learn this method Commented Sep 25, 2015 at 8:36
  • did u know about libraries like picasso and glide? Commented Sep 25, 2015 at 8:45

1 Answer 1

0

You can easily convert your byte data to image by using following code :

byte[] data = "Your byte data";             
imageview.setImageBitmap(BitmapFactory.decodeByteArray(data, 0, data.length));

Hope it will solve your problem.

Sign up to request clarification or add additional context in comments.

7 Comments

the binary data is in String format and converting it to byte[] is giving problem
use this byte[] data = string.getBytes();
Image This is the data that I have to convert to image. Could you help me recognize the format. Thank you
leftwritesleft.wordpress.com/2015/09/25/image This should work. Have tried Base64 decoding methods .. but has not worked for me yet. Any help will be appreciated.
i suggestion for you : instead of getting image like this get url of image.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.