com.threerings.resource
Class FastImageIO

java.lang.Object
  extended by com.threerings.resource.FastImageIO

public class FastImageIO
extends Object

Provides routines for writing and reading uncompressed 8-bit color mapped images in a manner that is extremely fast and generates a minimal amount of garbage during the loading process.


Field Summary
protected static int[] _cmap
          Used when loading our color map.
protected static Point _origin
          Used when creating our writable raster.
static String FILE_SUFFIX
          A suffix for use when storing raw images in bundles or on the file system.
 
Constructor Summary
FastImageIO()
           
 
Method Summary
static boolean canWrite(BufferedImage image)
          Returns true if the supplied image is of a format that is supported by the fast image I/O services, false if not.
static BufferedImage read(ByteBuffer byteBuffer)
          Reads an image from the supplied byte buffer (which must return the image format previously written via a call to write(java.awt.image.BufferedImage, java.io.OutputStream)).
static BufferedImage read(File file)
          Reads an image from the supplied file (which must contain an image previously written via a call to write(java.awt.image.BufferedImage, java.io.OutputStream)).
static BufferedImage read(InputStream in)
          Reads an image from the supplied input stream (which must return the image format previously written via a call to write(java.awt.image.BufferedImage, java.io.OutputStream)).
static void write(BufferedImage image, OutputStream out)
          Writes the supplied image to the supplied output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_SUFFIX

public static final String FILE_SUFFIX
A suffix for use when storing raw images in bundles or on the file system.

See Also:
Constant Field Values

_cmap

protected static int[] _cmap
Used when loading our color map.


_origin

protected static Point _origin
Used when creating our writable raster.

Constructor Detail

FastImageIO

public FastImageIO()
Method Detail

canWrite

public static boolean canWrite(BufferedImage image)
Returns true if the supplied image is of a format that is supported by the fast image I/O services, false if not.


write

public static void write(BufferedImage image,
                         OutputStream out)
                  throws IOException
Writes the supplied image to the supplied output stream.

Throws:
IOException - thrown if an error occurs writing to the output stream.

read

public static BufferedImage read(File file)
                          throws IOException
Reads an image from the supplied file (which must contain an image previously written via a call to write(java.awt.image.BufferedImage, java.io.OutputStream)).

Throws:
IOException - thrown if an error occurs reading from the file.

read

public static BufferedImage read(InputStream in)
                          throws IOException
Reads an image from the supplied input stream (which must return the image format previously written via a call to write(java.awt.image.BufferedImage, java.io.OutputStream)).

Throws:
IOException - thrown if an error occurs reading from the file.

read

public static BufferedImage read(ByteBuffer byteBuffer)
                          throws IOException
Reads an image from the supplied byte buffer (which must return the image format previously written via a call to write(java.awt.image.BufferedImage, java.io.OutputStream)).

Throws:
IOException - thrown if an error occurs reading from the file.