This tip will allow you to rotate an image. The image that the code uses is included at the bottom of this tip.

=============================================
import java.applet.Applet;
import java.awt.Image;
import java.awt.image.PixelGrabber;
import java.awt.image.MemoryImageSource;
import java.awt.Graphics;
import java.awt.MediaTracker;
import java.net.*;

public class rotateGumby extends Applet {
Image img = null;
Image rot = null;

int buffer[] = new int[32 * 32];
int rotate[] = new int[32 * 32];

public void init() {
try {
MediaTracker tracker = new MediaTracker (this);
img = getImage(new URL(getDocumentBase(), "gumby.gif"));
tracker.addImage (img, 0);
tracker.waitForAll();
PixelGrabber grabber =
new PixelGrabber(img, 0, 0, 32, 32, buffer, 0, 32);
try {
grabber.grabPixels();
}
catch(InterruptedException e) {
e.printStackTrace();
}
for(int y = 0; y < 32; y++) {
for(int x = 0; x < 32; x++) {
rotate[((32-x-1)*32)+y] = buffer[(y*32)+x];
}
}
rot = createImage(new MemoryImageSource(32, 32, rotate, 0, 32));
}
catch (Exception e) {
e.printStackTrace();
}
}

public void update( Graphics g) {
paint(g);
}

public void paint(Graphics g) {
g.drawImage(img, 0, 0,this);
g.drawImage(rot,0, 40, this);
}
}


============== HTML File ====================
< HTML>
< TITLE>< /TITLE>

< BODY>


< APPLET CODE="rotateGumby.class">
< /APPLET>

< /BODY>< /HTML>

GUMBY.GIF (186 Bytes)