List of utility methods to do BufferedImage Load
BufferedImage | loadImage(String classRelativeFile) load Image InputStream is = ClassLoader.getSystemResourceAsStream(classRelativeFile); if (is == null) { throw new IOException(); return ImageIO.read(is); |
BufferedImage | loadImage(String filename) Loads the given file location as a buffered image Returns null if the image is not found BufferedImage img = null; try { return ImageIO.read(new File(filename)); } catch (IOException e) { e.printStackTrace(); return null; |
Image | loadImage(String fileName) Carga una imagen y retorna una instancia de la misma. InputStream stream = ClassLoader.getSystemResourceAsStream(fileName); if (stream == null) { return ImageIO.read(new File(fileName)); } else { return ImageIO.read(stream); |
Image | loadImage(String fileName, Component c) return an Image loaded by a MediaTracker. MediaTracker tracker = new MediaTracker(c); Toolkit toolkit = c.getToolkit(); Image image = toolkit.getImage(fileName); tracker.addImage(image, 0); tracker.waitForAll(); return image; |
Image | loadImage(String fileName, Component component) load Image Toolkit toolkit = Toolkit.getDefaultToolkit(); Image image = toolkit.getImage(fileName); MediaTracker mediaTracker = new MediaTracker(component); mediaTracker.addImage(image, 0); try { mediaTracker.waitForID(0); } catch (InterruptedException ie) { return null; ... |
BufferedImage | loadImage(String filePath) load image try { return ImageIO.read(new File(filePath)); } catch (Exception e) { throw new RuntimeException(e); |
BufferedImage | loadImage(String i, int x, int imageWidth, int imageHeight) load Image try { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); BufferedImage tempBuff = ImageIO.read(new File(i)); BufferedImage a = gc.createCompatibleImage(imageWidth, imageHeight, Transparency.TRANSLUCENT); Graphics tempG = a.getGraphics(); tempG.drawImage(tempBuff.getSubimage(x, 0, imageWidth, imageHeight), 0, 0, null); ... |
BufferedImage | loadImage(String image) Loads an image return ImageIO.read(new File(image)); |
Image | loadImage(String imageName) Loads an image from the given path. URL imageUrl = Thread.currentThread().getContextClassLoader().getResource(IMAGE_PATH + imageName); if (imageUrl == null) { throw new IllegalArgumentException("'" + imageName + "' could not be found in classpath"); return Toolkit.getDefaultToolkit().getImage(imageUrl); |
Image | loadImage(String imageName, Component c) Loads image MediaTracker tracker = new MediaTracker(c); Image img = Toolkit.getDefaultToolkit().createImage(imageName); tracker.addImage(img, 0); try { tracker.waitForID(0); } catch (InterruptedException ie) { return img; ... |