【发布时间】:2016-01-15 12:46:19
【问题描述】:
我正在尝试使用 glide 库来旋转图像。以前,可以和毕加索一起做(由于一个问题,我搬到了滑翔)。现在我在滑行中缺少旋转功能。我尝试使用转换,但没有成功。
// 使用的代码
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.with(context)
.load(link)
.asBitmap()
.transform(new MyTransformation(context, 90))
.into(imageView);
提前致谢。
【问题讨论】:
标签: android android-glide