Class PixelRectangle

java.lang.Object
  extended by PixelRectangle

public class PixelRectangle
extends java.lang.Object

PixelRectangle - a rectangular area of pixels.

To represent rectangular groups of pixels as a single entitly, two things are needed:


Field Summary
 int[] pixels
          Array of individual pixels represented as ints, 4 bytes: opacity, red, green, and blue.
 int width
          The number of columns in a row of pixels in the array.
 
Constructor Summary
PixelRectangle(int[] pixels, int numCol)
          Instantiate a PixelRectangle given its constituents.
 
Method Summary
 java.awt.Image toImage()
          Create an Image to match the array of picture's pixels.
 java.lang.String toString()
          Override Object.toString() for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pixels

public int[] pixels
Array of individual pixels represented as ints, 4 bytes: opacity, red, green, and blue.


width

public int width
The number of columns in a row of pixels in the array.

Constructor Detail

PixelRectangle

public PixelRectangle(int[] pixels,
                      int numCol)
Instantiate a PixelRectangle given its constituents.

Parameters:
pixels - array of individual pixels in int format
numCol - the number of columns making up a single row of pixels
Method Detail

toImage

public java.awt.Image toImage()
Create an Image to match the array of picture's pixels. AWT Graphics only supports painting of Image objects, no kind of BitBlt for arrays of pixel values (?who know's why?)


toString

public java.lang.String toString()
Override Object.toString() for debugging. Return String with PixelRectangle dimensions in square brackets and the first three pixel values enclosed in squiggle brackets, broken down into a,r,g,b components.

Overrides:
toString in class java.lang.Object