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 {

    public static Bitmap zoomBitmap(Bitmap bitmap, int desWidth, int desHeight) {
        return zoomBitmap(bitmap, (float) desWidth / bitmap.getWidth(), (float) desHeight / bitmap.getHeight());
    }

    public static Bitmap zoomBitmap(Bitmap bitmap, float sx, float sy) {
        Matrix matrix = new Matrix();
        matrix.postScale(sx, sy);
        return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    }
}