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;

public class Main {
    public static Bitmap resizeBitmapToFitWidth(Bitmap bm, int width) {
        int oriWidth = bm.getWidth();
        int oriHeight = bm.getHeight();
        if (oriWidth < width) {
            return bm;
        } else {
            int height = (int) ((float) width / oriWidth * oriHeight);
            Bitmap tmp = Bitmap.createScaledBitmap(bm, width, height, false);
            bm.recycle();
            return tmp;
        }
    }
}