List of utility methods to do ImageIcon to BufferedImage
BufferedImage | getBufferedImage(final ImageIcon icon) Gets a scaled icon and if it doesn't exist it creates one and scales it Image imgMemory = icon.getImage(); imgMemory = new ImageIcon(imgMemory).getImage(); int w = icon.getIconWidth(); int h = icon.getIconHeight(); BufferedImage bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics2D = bufferedImage.createGraphics(); graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); graphics2D.drawImage(imgMemory, 0, 0, w, h, 0, 0, w, h, null); ... |
BufferedImage | getBufferedImage(ImageIcon icon) get Buffered Image BufferedImage bi = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D ig2 = bi.createGraphics(); ig2.drawImage(icon.getImage(), 0, 0, icon.getIconWidth(), icon.getIconHeight(), null); return bi; |
BufferedImage | getBufferedImageFitToWidth(ImageIcon icon, double width) get Buffered Image Fit To Width double originalWidth = icon.getIconWidth(); double scale = width / originalWidth; return getScaledBufferedImage(icon, scale); |
BufferedImage | imageIconToBufferedImage(ImageIcon icon) image Icon To Buffered Image BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics graphics = bufferedImage.createGraphics(); icon.paintIcon(null, graphics, 0, 0); graphics.dispose(); return bufferedImage; |
BufferedImage | imageToBufferedImage(ImageIcon src) image To Buffered Image return imageToBufferedImage(src.getImage());
|