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 resize(Bitmap bmp, int width, int height) {
        float sx = (width * 1.0f) / bmp.getWidth();
        float sy = (height * 1.0f) / bmp.getHeight();
        Matrix matrix = new Matrix();
        matrix.postScale(sx, sy);
        return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
    }
}