0
votes

I want to load large bitmaps efficiently, so i decided to use picasso library.

I have a SurfaceView that must need bitmap to draw something(on surface)

here is my frame-code.

Canvas canvas = surfaceHolder.lockCanvas();

if (canvas != null) canvas.drawColor(Color.GRAY);

// here i want to add some bitmaps

surfaceHolder.unlockCanvasAndPost(canvas);

is it possible? get bitmap using picasso library. i already check usage http://square.github.io/picasso/

but there are not way to get bitmap source using picasso library.

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

Any help would be greatly appreciated, thank you!

3
bitmap source as in? - Sarthak Mittal
Possible solution link - shreyash mashru

3 Answers

3
votes

Should be called from not the main thread!

val url: String = "https://...."
val bitmap: Bitmap = Picasso.with(context).load(url).get()
1
votes

Maybe you can try using the following after Picasso loads your image:

Bitmap bm = ((BitmapDrawable)yourImageView.getDrawable()).getBitmap();
1
votes

You can implement your own class implementing the Target interface and then call:

 Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(target);