com.gregdennis.drej
Class Images

java.lang.Object
  extended by com.gregdennis.drej.Images

public final class Images
extends java.lang.Object

Utility class for manipulating images.

Author:
Greg Dennis (gdennis@mit.edu)

Method Summary
static GVector imageData(java.awt.Image image)
          Returns a vector of data from the specified image.
static GVector imageData(java.awt.Image image, int x, int y, int width, int height)
          Returns a vector of data from the (x, y, width, height) rectangular section of the specified image.
static java.awt.Image imageFromFile(java.lang.String path)
          Returns the image located at the specified path.
static java.awt.Image imageFromURL(java.net.URL url)
          Returns the image located at the specified URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

imageFromFile

public static java.awt.Image imageFromFile(java.lang.String path)
                                    throws java.io.FileNotFoundException,
                                           java.io.IOException,
                                           NotImageException
Returns the image located at the specified path.

Throws:
java.io.FileNotFoundException - if file does not exist at path
java.io.IOException - if error reading from file
NotImageException - if file is not an image

imageFromURL

public static java.awt.Image imageFromURL(java.net.URL url)
                                   throws java.io.IOException,
                                          NotImageException
Returns the image located at the specified URL.

Throws:
java.io.IOException - if error reading from URL
NotImageException - if URL does not reference an image

imageData

public static GVector imageData(java.awt.Image image)
                         throws NotImageException
Returns a vector of data from the specified image. The returned vector is of length (width * height * 3). The intensity of red in pixel (i, j) is located at index p = (3 * (i + j * width)) in the vector. The intensity of green is at index p + 1 and blue is at p + 2.

Throws:
NotImageException - if image is empty

imageData

public static GVector imageData(java.awt.Image image,
                                int x,
                                int y,
                                int width,
                                int height)
                         throws NotImageException
Returns a vector of data from the (x, y, width, height) rectangular section of the specified image. The returned vector is of length (width * height * 3). The intensity of red in pixel (i, j) is located at index p = (3 * ((i - x) + (j - y) * width)) in the vector. The intensity of green is at index p + 1 and blue is at p + 2.

Throws:
NotImageException - if image is empty