Java tutorial
//package com.java2s; import android.graphics.Matrix; public class Main { public static void prepareJpgMatrix(Matrix matrix, boolean mirror, int displayOrientation, int viewWidth, int viewHeight) { // Need mirror for front camera. matrix.setScale(mirror ? -1 : 1, 1); // This is the value for android.hardware.Camera.setDisplayOrientation. matrix.postRotate(displayOrientation); matrix.postTranslate(viewWidth / 2f, viewHeight / 2f); } }