import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;

// This applet takes an image and displays it stretched and shrunk.

public class ShrinkStretch extends Applet
{
	Image image;

	public void init()
	{
// Get the image
		image = getImage(getDocumentBase(), "samantha.gif");

// Create a media tracker to wait for the image
		MediaTracker tracker = new MediaTracker(this);
		
// Tell the media tracker to watch the image
		tracker.addImage(image, 0);

// Wait for the image to be loaded
		try {
			tracker.waitForAll();
		} catch (Exception ignore) {
		}
	}

	public void paint(Graphics g)
	{
// Get the width of the image
		int width = image.getWidth(this);

// Get the height of the image
		int height = image.getHeight(this);

// Draw the image in its normal size
		g.drawImage(image, 10, 10, width, height, this);

// Draw the image at half-size.
		g.drawImage(image, width+20, 10, width / 2,
			height / 2, this);

// Draw the image at twice its size. Notice that the x coordinate
// for this image is width * 3 / 2 + 30. The 30 represents a 10-pixel
// padding between each image, for 3 images. The 3/2 represents the
// total image size of the previous two images. One full image, plus
// one half the original size.

		g.drawImage(image, width * 3 / 2 + 30, 10,
			width * 2, height * 2, this);
	}
}
