import java.applet.*;
import java.awt.*;
import Raster;

public class Rastest extends Applet {
    Raster raster;
    Image output;
    int count = 0;

    public void init() {
      String filename = getParameter("image");
      showStatus("Using " + filename);
      output = getImage(getDocumentBase(), filename);
      raster = new Raster(output);
      showStatus("Image size: " + raster.getWidth() + " x " + raster.getHeight());
    }

    public void paint(Graphics g) {
      g.drawImage(output, 0, 0, this);
      count += 1;
      showStatus("paint() called " + count + " time" + ((count > 1) ? "s":""));
    }

    public void update(Graphics g) {
      paint(g);
    }

    public boolean mouseUp(Event e, int x, int y) {
      int s = raster.getSize();
      int [] pixel = raster.getPixelBuffer();
      for (int i = 0; i < s; i++) {
        raster.pixel[i] ^= 0x00ffffff;
      }
      output = raster.toImage(this);
      repaint();
      return true;
    }
}
