2
我想旋轉圖像使用滑翔庫。以前,能夠做畢加索(由於一個問題,我移動滑翔)。現在我缺少滑動旋轉功能。我嘗試使用轉換,但沒有奏效。如何使用滑行庫來旋轉圖像? (像在畢加索)
//代碼使用
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);
在此先感謝。
謝謝。我會測試它。 –