Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.graphics.Bitmap;

import android.graphics.Matrix;

public class Main {
    /**
     * Expand the bitmap to the specified scale.
     *
     * @param bitmap to expand.
     * @param scale  the expand scale, must be > 1.0.
     * @return the expanded bitmap.
     */
    public static Bitmap expand(Bitmap bitmap, float scale) {
        if (scale <= 1.0f) {
            return bitmap.copy(bitmap.getConfig(), false);
        }

        Matrix matrix = new Matrix();
        matrix.postScale(scale, scale);

        return Bitmap.createBitmap(bitmap, 0, 0, (int) (scale * bitmap.getWidth()),
                (int) (scale * bitmap.getHeight()), matrix, true);
    }
}