I use this to rotate a Bitmap from an existing one:
private Bitmap getRotatedBitmap(Bitmap bitmap, int angle) { int w = bitmap.getWidth(); int h = bitmap.getHeight(); Matrix mtx = new Matrix(); mtx.postRotate(angle); return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true); }
Can this be done without creating a new bitmap?
I tried to redraw the same mutable image using Canvas :
Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight, config); Canvas canvas = new Canvas(targetBitmap); Matrix matrix = new Matrix(); matrix.setRotate(mRotation,source.getWidth()/2,source.getHeight()/2); canvas.drawBitmap(targetBitmap, matrix, new Paint());
but this approach has just damaged the bitmap. So are there any opportunities to achieve this?
birdy source share