Мне нужно отрезать 20 пикселей от нижней части изображения и кэшировать его, чтобы устройству не приходилось обрезать его снова и снова каждый раз, когда пользователь снова видит изображение, иначе это было бы плохо для батареи и т. Д. c . правильно?
Это то, что у меня есть до сих пор:
Glide
.with(context)
.load(imgUrl)
.into(holder.image)
fun cropOffLogo(originalBitmap: Bitmap) : Bitmap {
return Bitmap.createBitmap(
originalBitmap,
0,
0,
originalBitmap.width,
originalBitmap.height - 20
)
}
как я могу использовать cropOffLogo
с glide
?
EDIT:
Я пробовал использовать https://github.com/bumptech/glide/wiki/Transformations#custom -трансформации
private static class CutOffLogo extends BitmapTransformation {
public CutOffLogo(Context context) {
super(context);
}
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform,
int outWidth, int outHeight) {
Bitmap myTransformedBitmap = Bitmap.createBitmap(
toTransform,
10,
10,
toTransform.getWidth(),
toTransform.getHeight() - 20);
return myTransformedBitmap;
}
}
и получил эти ошибки:
Modifier 'private' not allowed here
Modifier 'static' not allowed here
'BitmapTransformation()' in 'com.bumptech.glide.load.resource.bitmap.BitmapTransformation' cannot be applied to '(android.content.Context)'