/**
*
* @param b bitmap
* @param degrees 角度 0 ~ 360
* @return
*/
public static Bitmap rotate(Bitmap b, int degrees) {
if (degrees != 0 && b != null) {
Matrix m = new Matrix();
m.setRotate(degrees, (float) b.getWidth() / 2,
(float) b.getHeight() / 2);
// m.setRotate(degrees,0, 0);
try {
Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(),
b.getHeight(), m, true);
if (b != b2) {
b.recycle(); // Android开发网再次提示Bitmap操作完应该显示的释放
b = b2;
}
} catch (OutOfMemoryError ex) {
// Android123建议大家如何出现了内存不足异常,最好return 原始的bitmap对象。.
return b;
}
}
return b;
}
*
* @param b bitmap
* @param degrees 角度 0 ~ 360
* @return
*/
public static Bitmap rotate(Bitmap b, int degrees) {
if (degrees != 0 && b != null) {
Matrix m = new Matrix();
m.setRotate(degrees, (float) b.getWidth() / 2,
(float) b.getHeight() / 2);
// m.setRotate(degrees,0, 0);
try {
Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(),
b.getHeight(), m, true);
if (b != b2) {
b.recycle(); // Android开发网再次提示Bitmap操作完应该显示的释放
b = b2;
}
} catch (OutOfMemoryError ex) {
// Android123建议大家如何出现了内存不足异常,最好return 原始的bitmap对象。.
return b;
}
}
return b;
}