Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Image;

public class Main {
    public static Image resizeToWidth(Image image, int w) {
        int h = image.getHeight(null) * w / image.getWidth(null);
        Image newimg = image.getScaledInstance(w, h, java.awt.Image.SCALE_SMOOTH); // scale it the smooth way  
        return newimg;
    }
}