private static MalletTexture.Meta createMeta(final String _path, final InputStream _stream) { try (final ImageInputStream in = ImageIO.createImageInputStream(_stream)) { final Iterator<ImageReader> readers = ImageIO.getImageReaders(in); if (readers.hasNext()) { final ImageReader reader = readers.next(); try { reader.setInput(in); // Add additional Meta information to MalletTexture as // and when it becomes needed. It shouldn't hold too much (RGB, RGBA, Mono, endinese, // 32, 24-bit, etc) // data as a game-developer shouldn't need detailed information. return new MalletTexture.Meta(_path, reader.getHeight(0), reader.getWidth(0)); } finally { reader.dispose(); } } } catch (IOException ex) { ex.printStackTrace(); } return null; }
public void run() { final FileStream file = GlobalFileSystem.getFile(texturePath); if (file.exists() == false) { Logger.println("Failed to create Texture: " + texturePath, Logger.Verbosity.NORMAL); return; } try { final DesktopByteIn in = (DesktopByteIn) file.getByteInStream(); final InputStream stream = in.getInputStream(); final BufferedImage image = ImageIO.read(stream); in.close(); synchronized (toBind) { // We don't want to bind the BufferedImage now // as that will take control of the OpenGL context. toBind.add(new Tuple<String, BufferedImage>(texturePath, image)); } } catch (IOException ex) { ex.printStackTrace(); } }