Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.graphics.Bitmap;

import android.graphics.Matrix;

public class Main {
    public static Bitmap ScaleAndRotateBitmap(Bitmap bitmap, int rotation, int flipHorizontal) {
        Matrix m = new Matrix();
        if (flipHorizontal != 0) {
            m.postScale(-1, 1);
        }
        if (rotation != 0) {
            m.postRotate(rotation);
        }
        Bitmap finalBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);
        if (finalBitmap != bitmap) {
            bitmap.recycle();
        }
        return finalBitmap;
    }
}