Beispiel #1
1
 /**
  * Determines from the magic number whether the given InputStream points to an SGI RGB image. The
  * given InputStream must return true from markSupported() and support a minimum of two bytes of
  * read-ahead.
  */
 public static boolean isSGIImage(InputStream in) throws IOException {
   if (!(in instanceof BufferedInputStream)) {
     in = new BufferedInputStream(in);
   }
   if (!in.markSupported()) {
     throw new IOException(
         "Can not test non-destructively whether given InputStream is an SGI RGB image");
   }
   final DataInputStream dIn = new DataInputStream(in);
   dIn.mark(4);
   final short magic = dIn.readShort();
   dIn.reset();
   return (magic == MAGIC);
 }
Beispiel #2
0
 public static FragmentShader load(Class<?> base, String name) {
   InputStream in = base.getResourceAsStream(name);
   try {
     try {
       return (parse(new InputStreamReader(in, Utils.ascii)));
     } finally {
       in.close();
     }
   } catch (IOException e) {
     throw (new RuntimeException(e));
   }
 }