You cannot do this directly with Canvas. You will need to actually modify the bitmap (using the matrix) before drawing it. Fortunately, this is a very simple code for this:
public enum Direction { VERTICAL, HORIZONTAL }; public static Bitmap flip(Bitmap src, Direction type) { Matrix matrix = new Matrix(); if(type == Direction.VERTICAL) { matrix.preScale(1.0f, -1.0f); } else if(type == Direction.HORIZONTAL) { matrix.preScale(-1.0f, 1.0f); } else { return src; } return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true); }
source share