【问题标题】:get bitmap image using picasso library使用毕加索库获取位图图像
【发布时间】:2016-02-02 01:24:39
【问题描述】:

我想有效地加载大型位图,所以我决定使用 picasso 库。

我有一个 SurfaceView,它必须需要位图才能(在表面上)绘制一些东西

这是我的框架代码。

Canvas canvas = surfaceHolder.lockCanvas();

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

// here i want to add some bitmaps

surfaceHolder.unlockCanvasAndPost(canvas);

有可能吗?使用毕加索库获取位图。 我已经检查了使用情况http://square.github.io/picasso/

但是没有办法使用毕加索库获取位图源。

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

任何帮助将不胜感激,谢谢!

【问题讨论】:

  • 位图来源如?
  • 可能的解决方案link

标签: android bitmap picasso


【解决方案1】:

不应该从主线程调用!

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

【讨论】:

    【解决方案2】:

    您可以实现自己的实现Target接口的类,然后调用:

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

    【讨论】:

      【解决方案3】:

      也许您可以在 Picasso 加载您的图片后尝试使用以下方法:

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

      【讨论】:

        猜你喜欢
        • 2021-02-21
        • 2014-10-20
        • 1970-01-01
        • 2018-01-21
        • 2018-01-01
        • 2020-06-27
        • 2018-12-29
        • 1970-01-01
        • 2021-10-01
        相关资源
        最近更新 更多