android中bitmap的旋转

来源:互联网 发布:pdd网络用语是什么意思 编辑:程序博客网 时间:2024/04/26 16:04
/** * 旋转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;}


原创粉丝点击