Java Icon scaleIcon(Image iconImage, int size)

Here you can find the source of scaleIcon(Image iconImage, int size)

Description

scale Icon

License

Open Source License

Declaration

public static BufferedImage scaleIcon(Image iconImage, int size) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

import javax.swing.ImageIcon;

public class Main {
    public static ImageIcon scaleIcon(ImageIcon icon, int size) {
        return new ImageIcon(scaleIcon(icon.getImage(), size));
    }//  w  w  w.j  a  va 2  s  .  c  o m

    public static BufferedImage scaleIcon(Image iconImage, int size) {
        BufferedImage newImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2 = newImage.createGraphics();
        try {
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            g2.drawImage(iconImage, 0, 0, size, size, null);
        } finally {
            g2.dispose();
        }
        return newImage;
    }
}

Related

  1. createRotatedImage(Component c, Icon icon, double rotatedAngle)
  2. extractIconImage(Component component, Icon icon)
  3. genImageResource(Class cls, String icon)
  4. getChatIconImage()
  5. makeIcon(final Class baseClass, final Class rootClass, final String imageFile)
  6. toImage(Icon icon)
  7. toImages(List icons)