Java ImageIcon to BufferedImage imageIconToBufferedImage(ImageIcon icon)

Here you can find the source of imageIconToBufferedImage(ImageIcon icon)

Description

image Icon To Buffered Image

License

Apache License

Declaration

public static BufferedImage imageIconToBufferedImage(ImageIcon icon) 

Method Source Code

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

import java.awt.Graphics;

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

public class Main {
    public static BufferedImage imageIconToBufferedImage(ImageIcon icon) {
        BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(),
                BufferedImage.TYPE_INT_ARGB);
        Graphics graphics = bufferedImage.createGraphics();
        icon.paintIcon(null, graphics, 0, 0);
        graphics.dispose();//from   w  ww.j a  va  2  s.  co m
        return bufferedImage;
    }
}

Related

  1. getBufferedImage(final ImageIcon icon)
  2. getBufferedImage(ImageIcon icon)
  3. getBufferedImageFitToWidth(ImageIcon icon, double width)
  4. imageToBufferedImage(ImageIcon src)