Пример #1
0
    /**
     * Return the meta information associated with an image defined by _path. If the meta data has
     * yet to be generated, create it and store the meta data in imageMetas. This hashmap is
     * persistant across the runtime of the renderer. If the meta data changes from one call to the
     * next, the meta data stored is NOT updated. FileStream would need to be updated to support
     * file modification timestamps.
     */
    public MalletTexture.Meta getMeta(final String _path) {
      synchronized (imageMetas) {
        MalletTexture.Meta meta = imageMetas.get(_path);
        if (meta != null) {
          return meta;
        }

        final FileStream file = GlobalFileSystem.getFile(_path);
        if (file.exists() == false) {
          Logger.println("No Texture found to create Meta: " + _path, Logger.Verbosity.NORMAL);
          return new MalletTexture.Meta(_path, 0, 0);
        }

        return addMeta(_path, createMeta(_path, file));
      }
    }
Пример #2
0
    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();
      }
    }
Пример #3
0
 private MalletTexture.Meta createMeta(final String _path, final FileStream _file) {
   final DesktopByteIn desktopIn = (DesktopByteIn) _file.getByteInStream();
   return createMeta(_path, desktopIn.getInputStream());
 }