Java ImageIcon CreateSizedImageIconScaledSmooth(URL filePath, int width, int height)

Here you can find the source of CreateSizedImageIconScaledSmooth(URL filePath, int width, int height)

Description

Scales the provided image to the new height/width

License

Apache License

Parameter

Parameter Description
filePath - The image to resize
width - The new width to scale to
height - The new height to scale to

Return

ImageIcon - the newly resized image

Declaration

public static ImageIcon CreateSizedImageIconScaledSmooth(URL filePath, int width, int height) 

Method Source Code


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

import java.awt.Image;
import java.net.URL;
import javax.swing.ImageIcon;

public class Main {
    /**//from w  ww  . ja  va 2 s.c  o  m
     * Scales the provided image to the new height/width
     * @param filePath - The image to resize
     * @param width - The new width to scale to
     * @param height - The new height to scale to
     * @return ImageIcon - the newly resized image
     */
    public static ImageIcon CreateSizedImageIconScaledSmooth(URL filePath, int width, int height) {

        ImageIcon newImageIcon = new ImageIcon(filePath);
        Image image = newImageIcon.getImage();
        image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
        newImageIcon = new ImageIcon(image);

        return newImageIcon;
    }
}

Related

  1. createFileImageIcon(final String path)
  2. createMonoColoredImageIcon(final Paint paint, final int width, final int height)
  3. createNonCachedImageIcon(File file)
  4. createOverlayIcon(Icon baseIcon, ImageIcon overlayIcon)
  5. createScaledImageIcon(byte[] albumArtBytes)
  6. createTempImage(ImageIcon icon, File oldFile)
  7. displayImage(final ImageIcon ii)
  8. drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)
  9. drawImageBorder(Graphics g, ImageIcon img, Rectangle rect, Insets ins, boolean drawCenter)