当前位置: 技术问答>java相关
请问可以在APPLET程序中将图象旋转90度显示吗?
来源: 互联网 发布时间:2015-04-02
本文导语: 请问可以在APPLET程序中将图象旋转90度显示吗?如果可以的话,怎么实现?我用drawImage方法(带十个参数来做,没做出来)。谢谢帮忙!! | from http://www.rgagnon.com/javadetails/java-0248.html Rotate an...
请问可以在APPLET程序中将图象旋转90度显示吗?如果可以的话,怎么实现?我用drawImage方法(带十个参数来做,没做出来)。谢谢帮忙!!
|
from http://www.rgagnon.com/javadetails/java-0248.html
Rotate an image
The following snippet rotates an image (90 degrees). The applet assumes the dimension 32x32 for the image. You may want to grap this image for testing purpose.
import java.applet.Applet;
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
Rotate an image
The following snippet rotates an image (90 degrees). The applet assumes the dimension 32x32 for the image. You may want to grap this image for testing purpose.
import java.applet.Applet;
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