/**
* 旋转bitmap
*
* @param b
* @param degrees
* @return
*/
public static Bitmap rotateBmp(Bitmap b, int degrees) {
if (degrees != 0 && b != null) {
Matrix m = new Matrix();
m.setRotate(degrees, (float) b.getWidth() / 2,
(float) b.getHeight() / 2);
try {
Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(),
b.getHeight(), m, true);
if (b != b2) {
b.recycle();
b = b2;
}
} catch (OutOfMemoryError ex) {
}
}
return b;
}android中bitmap的旋转
最新推荐文章于 2022-07-29 09:00:00 发布
本文详细介绍了如何在Android中高效地旋转Bitmap,并通过使用Matrix类实现了旋转操作,同时确保内存管理得当,避免了内存泄漏。
333

被折叠的 条评论
为什么被折叠?



