I am trying to rotate an image using the planing library. I used to be able to do with Picasso (due to a problem, I moved to slide). Now I do not have the rotate function in glide. I tried to use transforms but did not work.
// Used code
public class MyTransformation extends BitmapTransformation { private float rotate = 0f; public MyTransformation(Context context, float rotate) { super(context); this.rotate = rotate; } @Override protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) { return rotateBitmap(toTransform, rotate); } @Override public String getId() { return "com.example.helpers.MyTransformation"; } public static Bitmap rotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); } }
// glide
Glide.with(context) .load(link) .asBitmap() .transform(new MyTransformation(context, 90)) .into(imageView);
Thanks in advance.
source share