List of utility methods to do Image Load
Image | loadImage(File original) load Image ImageIcon ii = new ImageIcon(original.getCanonicalPath()); Image i = ii.getImage(); return i; |
BufferedImage | loadImage(final String src) Loads image from specified source file return loadImage(new File(src)); |
BufferedImage | loadImage(InputStream s) load Image Image img = Toolkit.getDefaultToolkit().createImage(loadBytes(s)); try { imageAssist.addImage(img, 1); imageAssist.waitForID(1); imageAssist.removeImage(img); } catch (InterruptedException e) { throw new IOException("Interrupted while loading image"); BufferedImage bufImg = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB); bufImg.getGraphics().drawImage(img, 0, 0, null); return bufImg; |
BufferedImage | loadImage(Object parent, String pathToImage) load Image BufferedImage bufferedImage = null; ImageIcon imageIcon = null; try { InputStream inputStream = parent.getClass().getResourceAsStream(pathToImage); bufferedImage = ImageIO.read(inputStream); } catch (IOException e) { e.printStackTrace(); return bufferedImage; |
Image | loadImage(String filename) load Image ImageIcon icon = new ImageIcon(filename); return icon.getImage(); |
Image | loadImage(String filePath, int imageSize) load Image ImageIcon imgIcon = new ImageIcon(filePath); if (imgIcon == null) return null; return getScaledImage(imgIcon.getImage(), imageSize); |
Image | loadImage(URL url) load Image if (url == null) { return null; Image image = null; try { image = Toolkit.getDefaultToolkit().getImage(url); if (image != null) { synchronized (tracker) { ... |
ImageIcon | readImage(InputStream inp) read Image byte[] bytes = readInBytes(inp); return new ImageIcon(bytes); |
void | readImageToLabel(String netUrl) read Image To Label Image image = null; try { URL url = new URL(netUrl); image = ImageIO.read(url); } catch (IOException localIOException) { JFrame frame = new JFrame(); JLabel label = new JLabel(new ImageIcon(image)); ... |