Glide: There is no such method asBitmap(), when custom decoder() , could not use into(new SimpleTarget<Bitmap>() ,

Created on 9 Jun 2017  Â·  4Comments  Â·  Source: bumptech/glide

Hi, I have non-standard picture files, so I have to use custom decoder() .
this works fine when I load into imageview.
but now I need the bitmap file. so I want to load it into SimpleTarget But it shows no asBitmap method

what should I do?

glide:3.7.0

this is my code:

 Glide.with(getActivity())
                .load(url)
                .decoder(new MyGlideDecoder(poetry))
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .asBitmap() // There is no such method
                .into(new SimpleTarget<Bitmap>(100, 100) {
                    @Override
                    public void onResourceReady(Bitmap bitmap, GlideAnimation anim) {
                        // Do something with bitmap here.
                    }
                });
question

Most helpful comment

@IgorGanapolsky

Glide.with().asBitmap() on 4.0+

All 4 comments

Put asBitmap right after load and then see what methods you get with dot-completion.

Btw, Simple target may be error prone. Consider the pattern shown in FutureTarget JavaDocs

I am having the same problem with Glide 4.4:

unresolved reference asBitmap

@IgorGanapolsky

Glide.with().asBitmap() on 4.0+

// Put asBitmap() right after Glide.with(context) ,,. 4.0+
Glide.with(context)
.asBitmap()
.load(images[position])
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.AUTOMATIC))
.into(new SimpleTarget(width, height) {
@Override
public void onResourceReady(Bitmap bitmap, Transition transition) {
SubsamplingScaleImageView.setImage(ImageSource.bitmap(bitmap)); //For SubsamplingScaleImageView
}
});

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Morteza-Rastgoo picture Morteza-Rastgoo  Â·  3Comments

sergeyfitis picture sergeyfitis  Â·  3Comments

kenneth2008 picture kenneth2008  Â·  3Comments

Tryking picture Tryking  Â·  3Comments

r4m1n picture r4m1n  Â·  3Comments