将url to bitmap只需要在with后加上asbitmap , resource此时就是bitmap, 只需要将bitmap解码就可以获得字节数值啦!!
GlideApp.with(context).asBitmap().load(url).into(bitMapTarget)
//或者
Glide.with......
//java开发的同学直接new SimpleTarget<Bitmap>() 就好
private val bitMapTarget = object : SimpleTarget<Bitmap>() {
override fun onLoadFailed(errorDrawable: Drawable?) {
super.onLoadFailed(errorDrawable)
}
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap>?) {
val baos = ByteArrayOutputStream()
resource.compress(Bitmap.CompressFormat.JPEG, 100, baos)
val data = baos.toByteArray()
}
}