Here you can find the source of getResizedImage(String path, int height, int width)
public static Image getResizedImage(String path, int height, int width)
//package com.java2s; //License from project: Apache License import java.awt.Image; import java.awt.Toolkit; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import javax.swing.ImageIcon; public class Main { public static Image getResizedImage(String path, int height, int width) { Image img = new ImageIcon(path).getImage(); return img.getScaledInstance(height, width, 0); }/*w ww . ja v a 2 s. co m*/ public static Image getImage(InputStream stream) { ByteArrayOutputStream output = new ByteArrayOutputStream(); int a1; Image myImage = null; try { a1 = stream.read(); while (a1 >= 0) { output.write((char) a1); a1 = stream.read(); } myImage = Toolkit.getDefaultToolkit().createImage(output.toByteArray()); } catch (IOException ex) { // TODO Auto-generated catch block ex.printStackTrace(); } finally { try { output.close(); } catch (IOException ex) { // TODO Auto-generated catch block ex.printStackTrace(); } } return myImage; } }