Java Swing Icon createBitmap(Icon icon)

Here you can find the source of createBitmap(Icon icon)

Description

create Bitmap

License

LGPL

Declaration

public static BufferedImage createBitmap(Icon icon) 

Method Source Code


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

import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import javax.swing.Icon;

public class Main {
    public static BufferedImage createBitmap(Icon icon) {
        BufferedImage bi = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
                BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = bi.createGraphics();
        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
        icon.paintIcon(null, g, 0, 0);/*  w ww .  j ava 2s  .  c  o m*/
        g.dispose();
        return bi;
    }
}

Related

  1. buildIcon(final String relativePath, final Class loader)
  2. changeBrightness(Icon icon, float factor)
  3. clearMergedIconsCache()
  4. combineIcons(Icon underIcon, Icon overIcon)
  5. concatenateIcons(final Icon icon1, final Icon icon2)
  6. createChannelIcon(Icon ic)
  7. createColourIcon(int colour)
  8. createGrayIcon(Icon icon)
  9. createGrayIcon(Icon icon)