I would like to use Picasso (https://github.com/square/picasso) for caching and bitmap decoding, the problem i'm having is that my request is for a url like for example : server.com/component/1 which gives me a proto file that i parse that contains some other information and a bytestring of the image that i decode to a bitmap.
Is there a way to use picasso for this even thought the request url is not just for an image or just use it for caching and decoding my bitmaps, I've tried using the class Target but it works only with a url of an image alone.
Thanks.
I think it's not possible, what can you do is just caching, load method has only 4 overrides for Uri, String, Bitmap, int. So when you will use Bitmap as a parameter, you will be able to cache your bitmap. Picasso was created only as an image loader, so I don't think that it has method that received all data from the server.
Related
I am using Glide library on Android to load a JPG format image into an ImageView, first I convert it to a ByteArray and then I use the following code:
GlideApp.with(context)
.load(selectedImageByteArray)
.into(image_view)
However, when the selected image orientation EXIF data is equal to "Rotate 270 CW" the image is not rotated by Glide unless I use the following code:
GlideApp.with(context)
.load(selectedImagePath)
.into(image_view)
This way I pass the selected image Uri instead of a ByteArray, why does this happen?
I attach and example (even here in Stack is not rotated):
Because that interface takes a path and nothing else. Kind of annoying since depending on the api level it is not always available. In some of the newer versions of android it is not easy to get the actual path of the file.image
data for that
The short answer is that the data that interface uses is stored in the file, not in the image data itself. There are many stack overflow links about this:
SO
Yes, I am using Picasso to load a bitmap. The reason is I am decoding URIs in one part of my adapter, and loading bitmaps in another, and I read here that
You should always call Picasso, even if your URL is null. This way it knows that the image view was recycled.
So I tried this....
Bitmap bitMap;
...
Picasso.with(getContext())
.load(bitMap)
.into(imageView);
But I got this error
cannot resolve method 'load(android.graphics.Bitmap)'
You cant put Bitmap for load method of Picasso. You can use only uri , file , url path and int resource id.
If You are downloading image from url then you can do like as below code:
String url = "your_url";
Picasso.with(context).load(url)
.placeholder(R.drawable.any_drawable)
.error(R.drawable.anydrawable).into(your_imageView);
For other resource its same, only load method parameter would gets changed depending on the resource you are using.
I'm using the Picasso library to dynamically load images from an API call.
Certain urls seem to return a malformed URL, for example: "http://imagesite.com/image.1241123.gif which crashes the app.
Picasso.with(activity).load(image)
.centerCrop()
.error(R.drawable.icon01)
.resize(50, 50)
.into(icon);
Looking at the documentation, I assumed the .error() parameter would handle this, but Picasso seems to see it as a valid URL, even though it won't return an image. I've also tried using the Picasso.Builder but I continue to get the same errors. Any suggestions?
picasso don't load gif image for that you have to use Glide library.
Check this link it might help you : http://inthecheesefactory.com/blog/get-to-know-glide-recommended-by-google/en
and you get library from : https://github.com/bumptech/glide
error() will handle issues where the URL is well formed but for some reasons it cannot display the image.
If you have malformed url it means the problem is your data. Remember garbage in , garbage out.
Use Uri.parse() before loading it to picasso, then handle the thrown exception: better fix your data.
I'm using picasso library to download images from URL.What I need is just download the stream not a bitmap, but there is no such method in it.Is it true?
There is :
Picasso.with(this).load(URL_LONG).get(); // return bitmap
Sometimes there are some large images from URL.I need to handle them before displaying for avoiding out of memory.So I cannot load them into bitmap immediately.This is the reason i need the stream.
There is already a feature to provide what you need in Picasso Library. You can actually scale the image when you stream it. Check out this SOF Question.
For the below - I don not have the URL of the image! I cannot use the URL.
If I am downloading images from the internet into a Bitmap array like this:
Bitmap image = BitmapFactory.decodeStream(file.getReadStream());
//add to the Bitmap Array
images.add(image);
Can this be sent to Picasso (or any other Image loader like UIL?)
I know I can display the images in my Adapter but I am getting out of memory issues. And I thought Picasso could take care of this and the caching etc.
This will not work as it will not accept a Bitmap source. Is there any other library to do this?
Picasso.with(context).load(images.get(position)).resize(60, 60).error(R.drawable.error_icon).into(holder.iconImage);