Java BufferedImage Filter filterScale(BufferedImage img, float ratio)

Here you can find the source of filterScale(BufferedImage img, float ratio)

Description

filter Scale

License

Apache License

Declaration

public static BufferedImage filterScale(BufferedImage img, float ratio) 

Method Source Code

//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;
    }
}

Related

  1. filterContrast(BufferedImage img)
  2. filterDetectLines(BufferedImage img)
  3. filterFillHoles(BufferedImage img)
  4. filterImage(BufferedImageOp bufferedImageOp, BufferedImage srcImg, BufferedImage dstImg)
  5. filterMedian(BufferedImage img)
  6. filterSmooth(BufferedImage img)
  7. filterThreshold(BufferedImage img, int threshold)
  8. horizontalFilter(BufferedImage bufImg, int startX, int stopX, int start, int stop, int y, double[] pContrib)
  9. thresholdFilter(int threshholdLevel, BufferedImage image)