I need to cut off 20px from the image bottom and cache it so the device doesn't have to crop it over and over again every time the user sees the image again, otherwise it would be bad for battery etc. right?
This is what I have so far:
Glide
.with(context)
.load(imgUrl)
.into(holder.image)
fun cropOffLogo(originalBitmap: Bitmap) : Bitmap {
return Bitmap.createBitmap(
originalBitmap,
0,
0,
originalBitmap.width,
originalBitmap.height - 20
)
}
how could I use cropOffLogo with glide?
EDIT:
I tried using https://github.com/bumptech/glide/wiki/Transformations#custom-transformations
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;
}
}
And get those errors:
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)'