List of utility methods to do Image to BufferedImage
BufferedImage | bufferedImageFromImage(final Image image) Creates a BufferedImage from an Image . if (image instanceof BufferedImage) { return (BufferedImage) image; final BufferedImage out = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); final Graphics2D g2d = out.createGraphics(); g2d.drawImage(image, 0, 0, null); g2d.dispose(); ... |
BufferedImage | convertToBufferedImage(Image image) Converts image to buffered image. if (image instanceof BufferedImage) { return (BufferedImage) image; image = new ImageIcon(image).getImage(); boolean hasAlpha = false; BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { ... |
BufferedImage | getBufferedImage(Image image) get Buffered Image if (image instanceof BufferedImage) { return (BufferedImage) image; BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D bGr = bimage.createGraphics(); bGr.addRenderingHints( new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY)); ... |
BufferedImage | getBufferedImage(Image image) get Buffered Image if (image instanceof BufferedImage) { return (BufferedImage) image; BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D g = bimage.createGraphics(); g.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY)); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER)); ... |
BufferedImage | getBufferedImage(Image image) Creates and returns a buffered version of the specified image. BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = bufferedImage.getGraphics(); g.drawImage(image, 0, 0, null); return bufferedImage; |
BufferedImage | getBufferedImage(Image image) get Buffered Image BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics2D g = bufferedImage.createGraphics(); g.drawImage(image, null, null); return bufferedImage; |
BufferedImage | getBufferedImage(Image img) get Buffered Image if (img == null) { return null; int w = img.getWidth(null); int h = img.getHeight(null); BufferedImage bufimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = bufimg.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); ... |
BufferedImage | getBufferedImage(java.awt.Image image) get Buffered Image BufferedImage bufferedImage; if (image instanceof BufferedImage) { bufferedImage = (BufferedImage) image; } else { waitForImage(image); int w = image.getWidth(null); int h = image.getHeight(null); bufferedImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); ... |
BufferedImage | getScaledBufferedImage(Image icon, double scale) get Scaled Buffered Image int iw = icon.getWidth(null); int w = (int) (iw * scale); int h = (int) (icon.getHeight(null) * scale); BufferedImage outImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); AffineTransform trans = new AffineTransform(); trans.scale(scale, scale); Graphics2D g = outImage.createGraphics(); g.drawImage(icon, trans, null); ... |
BufferedImage | imageToBufferedImage(Image image) Converts an Image to a BufferedImage . if (image instanceof BufferedImage) return (BufferedImage) image; image = new ImageIcon(image).getImage(); boolean hasAlpha = hasAlpha(image); BufferedImage bi = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { int transparency = Transparency.OPAQUE; ... |