Glide加载图片框架(仅获取BitMap)

来源:互联网 发布:python核心编程第三版 编辑:程序博客网 时间:2024/06/09 16:54

1.Simple Target

拿到图片的BitMap对象,不直接加载至ImageView 中(Simple Target) 
Glide into(),不仅可以传入ImageView 控件,还可传入 Targets

private SimpleTarget target = new SimpleTarget<Bitmap>() {      @Override    public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {        //这里我们拿到回掉回来的bitmap,可以加载到我们想使用到的地方    }};private void loadImageSimpleTarget() {      Glide        .with( context ) // could be an issue!        .load( eatFoodyImages[0] )        .asBitmap()   //强制转换Bitmap        .into( target );}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14


2.生成指定的图片大小。

private SimpleTarget target = new SimpleTarget<Bitmap>(250250) {      @Override    public void onResourceReady(Bitmap bitmap, GlideAnimation glideAnimation) {        //这里我们拿到回掉回来的bitmap,可以加载到我们想使用到的地方    }};private void loadImageSimpleTarget() {      Glide        .with( context ) // could be an issue!        .load( eatFoodyImages[0] )        .asBitmap()   //强制转换Bitmap        .into( target );}
原创粉丝点击