List of utility methods to do BufferedImage Load
BufferedImage | loadImageFromFile(File file) Loads a java.awt.image.BufferedImage from a java.io.File . if (file == null) return null; BufferedImage ret = null; try { ret = ImageIO.read(file); } catch (IOException e) { System.err.println("Could not load image from file! I/O Error!"); return ret; |
Image | loadImageFromFile(String fileName) load Image From File try { return ImageIO.read(new File(fileName)); } catch (IOException e) { throw new RuntimeException(e); |
Image | loadImageFromFile(String filename) load Image From File return ImageIO.read(new File(filename)); |
BufferedImage | loadImageFromFile(String filepath) Loads an image with the given file name. return loadImageFromFile(new File(filepath)); |
Image | loadImageFromFile_ORIG(String imgName) load Image From FilORIG byte[] imageBytes = getBytesFromFile(imgName); Image tmpi = null; int numTries = 20; if (imageBytes != null) { tmpi = Toolkit.getDefaultToolkit().createImage(imageBytes, 0, imageBytes.length); while (tmpi.getWidth(null) < 0 && numTries-- > 0) { try { Thread.sleep(100); ... |
BufferedImage | loadImagefromJar(Object refObj, String fileName) This method loads a picture from a relative path string. BufferedImage bi = null; try { bi = ImageIO.read(refObj.getClass().getResourceAsStream(fileName)); } catch (IOException e) { e.printStackTrace(); return bi; |
Image | loadImageFromURL(String imageURL, Component component) Loads an image from a URL if (imageURL == null) { return null; Image result = null; MediaTracker mediaTracker = new MediaTracker(component); try { result = Toolkit.getDefaultToolkit().createImage(new URL(imageURL)); } catch (Exception ex) { ... |
BufferedImage | loadImageFromVisualgorithmJar(String imageFileName) Loads the image indicated with imageFileName from the jar file of the application. BufferedImage image = null; try { image = ImageIO.read(urlClassLoader.findResource(imageFileName)); } catch (Exception ex) { return image; |
BufferedImage | loadImageRessource(Object source, String file) Load image ressource. BufferedImage image = null; try { image = ImageIO.read(source.getClass().getResource(file)); } catch (IOException ioe) { System.out.println(ioe.getMessage()); try { image = ImageIO.read(source.getClass().getResource("src" + file)); } catch (IOException e) { ... |
void | loadImages(Image[] images, Component comp) Load images (used for preloading images). MediaTracker tracker = new MediaTracker(comp); for (int i = 0; i < images.length; i++) tracker.addImage(images[i], 0); try { tracker.waitForID(0); } catch (InterruptedException ignore) { |