dim
dim

Reputation: 37

Picasso Load Bitmap or byte[] to imageview

I'm trying to find how can i load an image from byte or bitmap to imageview using picasso library.

Here is what i'm trying to do

 ImageView imageview1 = row.FindViewById<ImageView>(Resource.Id.CategoryImageView);

 Bitmap decodedByte = BitmapFactory.DecodeByteArray(Image, 0, Image.Length);

 Picasso.With(mContext).Load((decodedByte)).Into(imageview1);

But i'm getting error can not convert android graphics bitmap to anroid net uri Also here is what i'm trying for byte[]

 byte[] Image;
  Picasso.With(mContext).Load((Image)).Into(imageview1);

Now i'm getting error can not convert android graphics byte[] to anroid net uri

Is there any other way to convert it?

Upvotes: 1

Views: 3631

Answers (1)

shadowsheep
shadowsheep

Reputation: 15012

Following our messages I don't think that using Picasso to put your Bitmap in you ImageView it's the best solution for you.

If the main problem of your Application is a performance issue due to the use of a ListView to display a list of many images I suggest you to use a RecyclerView instead. Look at the official documentation.

If you still want to use Picasso to put your images on their ImageViews so I think that could be better not to store them directly on the SQLite database, but to store them on the phone storage and save on the SQLite database their filesystem full path (e.g. /storage/yourfolder/image1.png).

So you could use always a RecyclerView (the layout you always should choose to show a list of item due to its memory management) and in its ViewHodlder you could use Picasso to show images onto the ViewHolder ImageViews taken the images from the filesystem as Prafulla Malviya said.

As you know Picasso could display images from any Resouces, assets, files and content provider:

Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);
Picasso.with(context).load(new File(...)).into(imageView3);

Upvotes: 1

Related Questions