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 zoom(Bitmap source, float width, float height) {

        Matrix matrix = new Matrix();

        float scaleW = width / source.getWidth();
        float scaleH = height / source.getHeight();

        matrix.postScale(scaleW, scaleH);

        Bitmap bm = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);

        return bm;
    }
}