code: public static ByteBuffer getImageData(InputStream source, Format format, Rectangle size) {
          try {
              final BufferedImage image = ImageIO.read(source);
              size.setSize(image.getWidth(), image.getHeight());
              return getImageData(image, format);
          } catch (IOException ex) {
              throw new IllegalStateException("Unreadable texture image data", ex);
          }
      }
docs: Gets the {@link java.io.InputStream}'s data as a {@link java.nio.ByteBuffer}. The image data reading is done according to the {@link com.flowpowered.caustic.api.gl.Texture.Format}. The image size is
  stored in the passed {@link Rectangle} instance. The returned buffer is flipped an ready for reading.
  
  @param source The image input stream to extract the data from
  @param format The format of the image data
  @param size The rectangle to store the size in
  @return The flipped buffer containing the decoded image data