0

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!

bubu uwu
  • 463
  • 2
  • 12
  • 26

3 Answers3

3

Should be called from not the main thread!

val url: String = "https://...."
val bitmap: Bitmap = Picasso.with(context).load(url).get()
Prilaga
  • 818
  • 10
  • 18
1

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

Bitmap bm = ((BitmapDrawable)yourImageView.getDrawable()).getBitmap();
Tomislav Turcic
  • 879
  • 1
  • 11
  • 24
1

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

 Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(target);
Codo
  • 75,595
  • 17
  • 168
  • 206