如何使用Glide获取网络图片的高宽?
How to get network image height and width using Glide?
我正在尝试获取网络图像的高度和宽度。我正在使用 Glide 显示图像。
我在 Java 中使用的代码是:
Glide.with(getContext().getApplicationContext())
.asBitmap()
.load(path)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap,
Transition<? super Bitmap> transition) {
int w = bitmap.getWidth();
int h = bitmap.getHeight()
mImageView.setImageBitmap(bitmap);
}
});
我如何在 Kotlin 中实现这一点?
Glide.with(context.applicationContext)
.asBitmap()
.load(path)
.into(object : SimpleTarget<Bitmap?>() {
override fun onResourceReady(bitmap: Bitmap, transition: Transition<in Bitmap?>?) {
val w = bitmap.width
val h = bitmap.height
mImageView.setImageBitmap(bitmap)
}
})
我正在尝试获取网络图像的高度和宽度。我正在使用 Glide 显示图像。
我在 Java 中使用的代码是:
Glide.with(getContext().getApplicationContext())
.asBitmap()
.load(path)
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap bitmap,
Transition<? super Bitmap> transition) {
int w = bitmap.getWidth();
int h = bitmap.getHeight()
mImageView.setImageBitmap(bitmap);
}
});
我如何在 Kotlin 中实现这一点?
Glide.with(context.applicationContext)
.asBitmap()
.load(path)
.into(object : SimpleTarget<Bitmap?>() {
override fun onResourceReady(bitmap: Bitmap, transition: Transition<in Bitmap?>?) {
val w = bitmap.width
val h = bitmap.height
mImageView.setImageBitmap(bitmap)
}
})