List of utility methods to do Image to BufferedImage
BufferedImage | toBufferedImage(Image image) to Buffered Image if (image instanceof BufferedImage) { return (BufferedImage) image; image = new ImageIcon(image).getImage(); boolean hasAlpha = hasAlpha(image); BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { ... |
BufferedImage | toBufferedImage(Image image) to Buffered Image if (image instanceof BufferedImage) { return (BufferedImage) image; image = new ImageIcon(image).getImage(); BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { int transparency = Transparency.OPAQUE; ... |
BufferedImage | toBufferedImage(Image image) to Buffered Image if (image instanceof BufferedImage) { return (BufferedImage) image; image = new ImageIcon(image).getImage(); boolean hasAlpha = hasAlpha(image); BufferedImage bimage = null; GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); try { ... |
BufferedImage | toBufferedImage(Image image, int type) Create a BufferedImage from the given image int w = image.getWidth(null); int h = image.getHeight(null); BufferedImage bImage = new BufferedImage(w, h, type); bImage.getGraphics().drawImage(image, 0, 0, null); return bImage; |
BufferedImage | toBufferedImage(Image image, int x, int y) Converts the given Image into a BufferedImage . BufferedImage result = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics g = result.getGraphics(); try { g.drawImage(image, x, y, null); return result; } finally { g.dispose(); ... |
BufferedImage | toBufferedImage(Image img) Convierte un objeto Image a un BufferedImage if (img instanceof BufferedImage) { return (BufferedImage) img; BufferedImage bimage = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics2D bGr = bimage.createGraphics(); bGr.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); bGr.drawImage(img, 0, 0, null); ... |
BufferedImage | toBufferedImage(Image img) to Buffered Image ImageIcon ii = new ImageIcon(img); img = ii.getImage(); BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics2D g = bi.createGraphics(); g.drawImage(img, 0, 0, null); g.dispose(); return bi; |
BufferedImage | toBufferedImage2(Image image) to Buffered Image if (image instanceof BufferedImage) { return ((BufferedImage) image); } else { image = new ImageIcon(image).getImage(); BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB); Graphics g = bufferedImage.createGraphics(); g.drawImage(image, 0, 0, null); ... |
BufferedImage | toGrayBufferedImage(Image image) Converts an AWT Image into a gray scale BufferedImage. if (image instanceof BufferedImage && ((BufferedImage) image).getType() == BufferedImage.TYPE_BYTE_GRAY) return (BufferedImage) image; image = new ImageIcon(image).getImage(); BufferedImage bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY); Graphics g = bimage.createGraphics(); g.drawImage(image, 0, 0, null); g.dispose(); ... |