Java BufferedImage Scale getScaledImageAsImageIcon(BufferedImage bufferedImage, int width, int height)

Here you can find the source of getScaledImageAsImageIcon(BufferedImage bufferedImage, int width, int height)

Description

get Scaled Image As Image Icon

License

Open Source License

Declaration

public static ImageIcon getScaledImageAsImageIcon(BufferedImage bufferedImage, int width, int height) 

Method Source Code

//package com.java2s;
/**//  w  ww. j a va2  s .c o  m
 * Copyright (C) 2015 Marek Kou?il <marek.kouril.st@vsb.cz>
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
 */

import javax.swing.*;
import java.awt.image.BufferedImage;

public class Main {
    public static ImageIcon getScaledImageAsImageIcon(BufferedImage bufferedImage, int width, int height) {
        return new ImageIcon(bufferedImage.getScaledInstance(width, height, BufferedImage.SCALE_SMOOTH));
    }
}

Related

  1. adjustScale(final BufferedImage bi, final JComponent component, final int insetX, final int insetY)
  2. ScaleToSize(BufferedImage bimg, int maxCols, int maxRows)