/** * Make a BufferedImage from the contents of an image file. * * @param imageFileContents byte array containing the guts of a JPG, GIF, or PNG */ public BufferedImage makeBufferedImage(byte[] imageFileContents) { BufferedImage bi = null; try { InputStream in = new ByteArrayInputStream(imageFileContents); bi = javax.imageio.ImageIO.read(in); } catch (IOException ioe) { GLApp.err("GLImage.makeBufferedImage(): " + ioe); } return bi; }
private void seticon() { Image icon; try { InputStream data = MainFrame.class.getResourceAsStream("icon.png"); icon = javax.imageio.ImageIO.read(data); data.close(); } catch (IOException e) { throw (new Error(e)); } setIconImage(icon); }
public static Image readImage(String filePath) throws IOException { return javax.imageio.ImageIO.read(new File(filePath)); }