List of utility methods to do BufferedImage Load
Image | loadImage(String path) load Image URL imgUrl = ClassLoader.getSystemResource(path);
Image img = Toolkit.getDefaultToolkit().getImage(imgUrl);
return img;
|
Image | loadImage(String path) load Image Image image = null; if (cache.containsKey(path)) { return cache.get(path); try { image = ImageIO.read(new File(path)); if (!cache.containsKey(path)) { cache.put(path, image); ... |
Image | loadImage(String resourceName) Loads an image from a resource. if (PREFER_TOOLKIT) { return Toolkit.getDefaultToolkit().createImage(ClassLoader.getSystemResource(resourceName)); } else { try (InputStream input = ClassLoader.getSystemResourceAsStream(resourceName)) { return (input == null) ? null : ImageIO.read(input); |
Image | loadImage(String url) load Image InputStream stream = ClassLoader.getSystemClassLoader().getResourceAsStream(url);
Image image = ImageIO.read(stream);
return image;
|
BufferedImage | loadImage(URL resource) load Image BufferedImage image = null; try { image = ImageIO.read(resource); } catch (IOException e) { return image; |
Image | loadImage(URL url) Load an image from a given URL. MediaTracker tracker = new MediaTracker(new java.awt.Container()); Image img = java.awt.Toolkit.getDefaultToolkit().createImage(url); tracker.addImage(img, 0); tracker.waitForAll(); return img; |
int[] | loadImageData(BufferedImage image) load Image Data int w = image.getWidth(); int h = image.getHeight(); int[] pixels = image.getRGB(0, 0, w, h, null, 0, w); return pixels; |
double[] | loadImageData(String name) load Image Data BufferedImage bi = null; double[] arr = null; try { File f = new File(name); bi = ImageIO.read(f); int w = bi.getWidth(null); int h = bi.getHeight(null); arr = new double[w * h]; ... |
Image | loadImageFromBytes(byte[] bytes) load Image From Bytes try { ByteArrayInputStream is = new ByteArrayInputStream(bytes); BufferedImage image = ImageIO.read(is); is.close(); return image; } catch (IOException e) { throw new RuntimeException(e); |
Image | loadImageFromFile(File f) load Image From File try { return ImageIO.read(f); } catch (IOException e) { System.out.println("Couldn't load image " + f.getPath()); e.printStackTrace(); return null; |