Code example for Matrix

Methods: createBitmap, postRotate

0
        /* 
         * if the orientation is not 0 (or -1, which means we don't know), we 
         * have to do a rotation. 
         */ 
        if (orientation > 0) {
            Matrix matrix = new Matrix();
            matrix.postRotate(orientation);
 
            srcBitmap = Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(),
                    srcBitmap.getHeight(), matrix, true);
        } 
 
        String type = context.getContentResolver().getType(photoUri);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        if (type.equals("image/png")) {
            srcBitmap.compress(Bitmap.CompressFormat.PNG, 100, baos);
        } else if (type.equals("image/jpg") || type.equals("image/jpeg")) {
            srcBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
        } 
        byte[] bMapArray = baos.toByteArray();
        baos.close();