com.meltingice.caman
Class Image

java.lang.Object
  extended by com.meltingice.caman.Image

public class Image
extends java.lang.Object

Represents a single image. Abstracts over retrieving pixel data and loading images from files.

Version:
1.0
Author:
Ryan LeFevre

Field Summary
 int[] pixels
           
 
Constructor Summary
Image(java.lang.String file)
          Creates a new Image based on the given filename.
 
Method Summary
 java.awt.image.BufferedImage getDestImage()
          Returns a writeable BufferedImage that is used to write the rendered image into.
 int getHeight()
          Gets the height of the image
 int[] getPixel(int x, int y)
           
 int getPixelRGB(int x, int y)
          Gets the RGB value of an arbitrary pixel in the image specified by pixel location.
 int getWidth()
          Gets the width of the image
 void setPixel(int x, int y, int[] rgb)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pixels

public int[] pixels
Constructor Detail

Image

public Image(java.lang.String file)
      throws java.io.IOException
Creates a new Image based on the given filename.

Parameters:
file - The filepath to the image to load
Throws:
java.io.IOException - If the image cannot be found or loaded.
Method Detail

getWidth

public int getWidth()
Gets the width of the image

Returns:
the width

getHeight

public int getHeight()
Gets the height of the image

Returns:
the height

getPixelRGB

public int getPixelRGB(int x,
                       int y)
Gets the RGB value of an arbitrary pixel in the image specified by pixel location.

Parameters:
x - The x location of the pixel
y - The y location of the pixel
Returns:
The RGB values of the pixel

getDestImage

public java.awt.image.BufferedImage getDestImage()
Returns a writeable BufferedImage that is used to write the rendered image into.

Returns:
A writeable BufferedImage object

getPixel

public int[] getPixel(int x,
                      int y)

setPixel

public void setPixel(int x,
                     int y,
                     int[] rgb)