Here you can find the source of filterScale(BufferedImage img, float ratio)
public static BufferedImage filterScale(BufferedImage img, float ratio)
//package com.java2s; //License from project: Apache License import java.awt.image.BufferedImage; public class Main { public static BufferedImage filterScale(BufferedImage img, float ratio) { final int w = (int) (ratio * img.getWidth()); final int h = (int) (ratio * img.getHeight()); final BufferedImage newImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { final int rgb = img.getRGB((int) (x / ratio), (int) (y / ratio)); newImg.setRGB(x, y, rgb); }//from www . j a va 2 s. c o m } return newImg; } }