glide
glide copied to clipboard
How to get a Bitmap from a SVG Url resource with Glide Version 4.11.0 ?
there is a sample here: https://github.com/bumptech/glide/tree/master/samples/svg If you add an SVG Decoder, will it work out of the box.
there is a sample here: https://github.com/bumptech/glide/tree/master/samples/svg If you add an SVG Decoder, will it work out of the box.
but there no sample to get bitmap
获取Bitmap,可以详细描述一下什么情况下获取BItmap吗?
@xiaogu-space did you solve this in the end?
I faced the same issue and managed to make it work:
- Take svg sample as base
- Replace all
PictureDrawablewithBitmap - Rename
SvgDrawableTranscodertoSvgBitmapTranscoder - In its constructor inject
glide.getBitmapPool()in the module. - In
SvgBitmapTranscoderrender SVG to Bitmap, e.g.Canvas canvas = new Canvas(bitmap); svg.renderToCanvas(canvas); return BitmapResource.obtain(bitmap, bitmapPool) - Replace
GlideApp.with(this).as(PictureDrawable.class)...withGlideApp.with(this).asBitmap().decode(SVG.class)...
See also https://github.com/qoqa/glide-svg