求解图形旋转算法www.blogjava.net.xpsir
请大家多多帮忙
请大家多多帮忙
解决方案 »
- 求解释一下程序代码
- ECLIPSE打包SWT/JFACE的问题
- 安装tomcat 大家能来帮我么 谢谢
- 问一个有关static的问题
- 我现在有个问题是在数据库里时间格式为2006-5-29 下午 03:46:32我现在要通过JSP查询数据库的某个时间段的情况,有没有什么好的方法让数据
- 我写了服务器端的程序,请教怎么把它做成服务,让机器一起动,就自动运行起来!
- 线程有几种表示办法,都是什么?同步有几种实现办法,都是什么?
- P2P应用的前景如何?JXTA或者其他的一些平台现在有多少人在用?
- 很简单的问题,63分给你~
- 设置jpanel背景色的问题
- 关于java调用数据库占用资源的问题
- 中文乱码处理,求助
下载解压jar到lib目录下即可。以下是旋转45度的例程:
import java.awt.Frame;
import java.awt.image.renderable.ParameterBlock;
import java.io.IOException;
import javax.media.jai.*;
import com.sun.media.jai.codec.FileSeekableStream;
import javax.media.jai.widget.ScrollingImagePanel;
/**
* This program decodes an image file of any JAI supported
* formats, such as GIF, JPEG, TIFF, BMP, PNM, PNG, into a
* RenderedImage, scales the image by 2X with bilinear
* interpolation, and then displays the result of the scale
* operation.
*/
public class JAISampleProgramRotate{ /** The main method. */
public static void main(String[] args) {
/* Validate input. */
if (args.length != 1) {
System.out.println("Usage: java JAISampleProgram " +
"input_image_filename");
System.exit(-1);
} /*
* Create an input stream from the specified file name
* to be used with the file decoding operator.
*/
FileSeekableStream stream = null;
try {
stream = new FileSeekableStream(args[0]);
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
} /* Create an operator to decode the image file. */
RenderedOp image = JAI.create("stream", stream);
/*
* Create a standard bilinear interpolation object to be
* used with the "scale" operator.
*/
Interpolation interp = Interpolation.getInstance(
Interpolation.INTERP_BILINEAR);
int value = 45;
float angle = (float)(value * (Math.PI/180.0F)); // Create a ParameterBlock and specify the source and
// parameters
ParameterBlock pb = new ParameterBlock();
pb.addSource(image); // The source image//******************replace im with image****************
pb.add(0.0F); // The x origin
pb.add(0.0F); // The y origin
pb.add(angle); // The rotation angle
pb.add(new InterpolationNearest()); // The interpolation
// Create the scale operation
RenderedOp im = JAI.create("Rotate", pb, null);//**************************************************create an instance im of type RenderedOp********//-----------------------------------add the other operator sample code here-------------------------
/* Get the width and height of image2. */
int width = im.getWidth();
int height = im.getHeight(); /* Attach image2 to a scrolling panel to be displayed. */
ScrollingImagePanel panel = new ScrollingImagePanel(im, width, height); /* Create a frame to contain the panel. */
Frame window = new Frame("JAI Sample Program");
window.add(panel);
window.pack();
window.show();
}
}