13

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)'

Community
  • 1
  • 1
the_prole
  • 8,275
  • 16
  • 78
  • 163
  • 2
    why do you need `Picasso` it you have already the bitmap? – Blackbelt Dec 03 '15 at 08:38
  • @Blackbelt You got that right. – Paresh P. Dec 03 '15 at 08:39
  • 1
    You cant put `Bitmap` for `load` method you can use `uri` , `file` , `url path` and `int resource id` – Pankaj Dec 03 '15 at 08:41
  • How you creating `bitmap`??? if you creating `bitmap` by `uri` or `url` or by `file` put that resource in your `load` method as parameter – Pankaj Dec 03 '15 at 08:42
  • @the_prole this is not possible to u load bitmap. picasso its contain only string path , uri , file . – Hardik Parmar Dec 03 '15 at 08:44
  • @Blackbelt Read my edit and tell me if it makes sense to you or not. Thanks. – the_prole Dec 03 '15 at 08:50
  • @Trivial You may also read my edit. – the_prole Dec 03 '15 at 08:52
  • it doesn't. If you have the `Uri` keep using it. Picasso caches the bitmaps for your internally, and, probably it uses the uri to look of the bitmap in the cache before downloading/loading it – Blackbelt Dec 03 '15 at 08:53
  • if you need to load bitmaps asynchronously use Picasso. *and given that not all my files have valid URIs, I need to download the images, and I get the images as bitmaps*. If they don't have a valid uri/url how did you download them – Blackbelt Dec 03 '15 at 09:08
  • @Blackbelt I did not download them. They are bitmaps which are by origin, encoded within the music files. Since not all these music files have bitmaps encoded within them, then I need to use a web service to query and download the image of the album art files. I'm am using Volley for this purpose, and the response in Volley is in the form of a Bitmap... so, on one hand I need Picasso, and on the other hand I have this bitmap... – the_prole Dec 03 '15 at 09:11
  • @Clairvoyant I will check mark your answer. Thanks. – the_prole Dec 03 '15 at 09:18
  • @Blackbelt - Hello, I read above discussion. I want to use Picasso just because of caching and async loading of images. Currently, In my project I got Byte array of from server. Then I convert byte array into Bitmap and then set it to my image View control. So , now my question is that How can I use Picasso in my scenario ? As per above discussion, it seems that Picasso only work with URL not with other Byte[] OR Bitmap or other formats. Please help me to guide that how can I use Picasso if I have Byte[] or Bitmap ? – Ajay Sharma Jun 16 '16 at 05:58
  • @AjaySharma did you try to give Picasso directly the url as input? – Blackbelt Jun 16 '16 at 07:22
  • @Blackbelt I never try picasso , I just viewing the article and examples. It shows that we have to pass image url in Load method. – Ajay Sharma Jun 16 '16 at 07:31

1 Answers1

2

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.

Pankaj
  • 7,908
  • 6
  • 42
  • 65