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!

1 Answer 1

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.

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

1 Comment

So, i have to change everything. Some another tutorial to do what I want?

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.