一张长方形图片,想旋转90度显示,用的glide框架,应该如何实现
public class RotateTransformation extends BitmapTransformation {
private float rotateRotationAngle = 0f;
public RotateTransformation(Context context, float rotateRotationAngle) {
super(context);
this.rotateRotationAngle = rotateRotationAngle;
}
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
Matrix matrix = new Matrix();
matrix.postRotate(rotateRotationAngle);
return Bitmap.createBitmap(toTransform, 0, 0, toTransform.getWidth(), toTransform.getHeight(), matrix, true);
}
}
@NonNull
public static RequestOptions getRotateOptions(Context context) {
return RequestOptions.bitmapTransform(new RotateTransformation(context, 90));
}
Glide.with(this).load(path).apply(getRotateOptions(getContext())).into(imageView);