0

I have beeen following this tutorial: Click Me

The problem is that I have my images in byte[] in my database, I don't have the links for each image. The tutorial works great. But i don't know my url image because I use byte[] to store the data, so: How can I convert the urls to byte[] using asynchronous?

I don't put my code because is the same like the tutorial! But if your like, let me know

Thanks for helping me!

Federick Jons
  • 93
  • 1
  • 13

1 Answers1

1

The tutorial loads image from the String urls. Since you do not have image URLs and you are saving images in your database as byte[] so you need to render images from byte[]. So, instead of loading images from URL, you can load byte[] to create a Bitmap. This is the code that can convert byte[] to bitmap.

ByteArrayOutputStream baoStream = new ByteArrayOutputStream();
bmpOld.compress(Bitmap.CompressFormat.PNG, 100, baoStream);
bytesImage = baoStream.toByteArray();
bmpNew = BitmapFactory.decodeByteArray(bytesImage, 0, bytesImage.length);

This code is taken from Android byte array to Bitmap How to

And yes, definitely, you will have to modify implementation of MemoryCache and and ImageLoader accordingly as well.

Community
  • 1
  • 1
java8.being
  • 464
  • 3
  • 11