How do I composite(render) 3 images into one image with jdk1.1?

Rob Edmondson

Each Image object has a Graphics object. You can modify an Image by using its Graphics object. Create a blank Image, then use its getGraphics() member to obtain its Graphics object. Use this object in the same way you would use the one provided by paint().

Sample Code:

public void paint(Graphics g)	//g is your object's display surface.
  //Create & load images once in start() or init() for speed.
  Image imTarget app.createImage(TARGET_WIDTH,TARGET_HEIGHT); 
  Image imSrc1 = app.getImage(app.getCodeBase(), "Image1.jpg");
  Image imSrc2 = app.getImage(app.getCodeBase(), "Image2.jpg");
  Image imSrc3 = app.getImage(app.getCodeBase(), "Image3.jpg");
  int imSrc1_X=0, imSrc2_X=0, imSrc3_X=0, 
      imSrc1_Y=0, imSrc2_Y=0, imSrc3_Y=0;

  Graphics tg = null;
  try {
    tg=imTarget.getGraphics();//Create a render surface.

  catch(Exception e) {
    System.out.println("Error creating render surface" + e);

    tg.drawImage(imSrc1, imSrc1_X, imSrc1_Y, this);
      tg.drawImage(imSrc2, imSrc2_X, imSrc2_Y, this);
      tg.drawImage(imSrc3, imSrc3_X, imSrc3_Y, this);