A Java Model of a Memory Raster


class Raster implements ImageObserver {
    ////////////////////////// Constructors /////////////////////
    public Raster();                // allows class to be extended
    public Raster(int w, int h);    // specify size
    public Raster(Image img);       // set to size and contents of image

    ////////////////////////// Interface Method /////////////////
    public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h);

    ////////////////////////// Accessors //////////////////////////
    public int getSize( );          // pixels in raster
    public int getWidth( );         // width of raster
    public int getHeight( );        // height of raster
    public int[] getPixelBuffer( ); // get array of pixels

    ////////////////////////// Methods ////////////////////////////
    public void fill(int argb);     // fill with packed argb
    public void fill(Color c);		// fill with Java color
    public Image toImage(Component root);
    public int getPixel(int x, int y);
    public Color getColor(int x, int y);
    public boolean setPixel(int pix, int x, int y);
    public boolean setColor(Color c, int x, int y);
}
Download Raster.java here.
Lecture 2   Slide 5   6.837 Fall '01