Java BufferedImage Resize linearResizeImage(BufferedImage origin, int width, int height)

Here you can find the source of linearResizeImage(BufferedImage origin, int width, int height)

Description

linear Resize Image

License

Apache License

Declaration

public static BufferedImage linearResizeImage(BufferedImage origin, int width, int height) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;

public class Main {
    public static BufferedImage linearResizeImage(BufferedImage origin, int width, int height) {
        BufferedImage resizedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = resizedImage.createGraphics();
        float xScale = (float) width / origin.getWidth();
        float yScale = (float) height / origin.getHeight();
        AffineTransform at = AffineTransform.getScaleInstance(xScale, yScale);
        g.drawRenderedImage(origin, at);
        g.dispose();//from   w w  w.j av  a2 s.  c  om
        return resizedImage;
    }
}

Related

  1. downsizeImage(Image imgSource, int w, int h)
  2. fitImage(JLabel label, BufferedImage image)
  3. getResizedImage(BufferedImage image)
  4. getResizeFactor(BufferedImage source, int maxWidth, int maxHeight)
  5. imageResize(BufferedImage image, int width, int height)
  6. resizeToContainer(BufferedImage imagen, int wCont, int hCont)