有没有一种简单的方法可以使用Java绕z轴旋转图像而无需跳入Java 3d? [英] Is there any easy way to rotate an image about z axis using java without jumping into java 3d?
问题描述
我想使用Java围绕z轴旋转图像。
I want to rotate an image about the z axis using java.
我试图寻找实现该方法的方法,但是它涉及复杂的矩阵操作,并且可以在3d模型和东西。如果没有其他方法,我将求助于此,但想知道是否还有其他选择。
I tried to search for ways to do that but it involves complex matrix manipulations and it works on 3d models and stuff. I will resort to that if there is no other way but would like to know if there are any other alternatives for this.
我只需要绕z轴旋转图像
I simply need to rotate an image about z axis and nothing else.
编辑
这正是我所需要的:
我有这样的图像:
我想将其转换为此类内容:
And I want to convert it to something of this sort:
我使用处理来做到这一点。我需要一些使用java的方法。
I did this using processing. I need some way of doing this using java.
推荐答案
如果您指的是在摆动<$ c $期间旋转图像c> paint 操作,那么正确的方法是使用 AffineTransform
。
If you are referring to rotating an image during a Swing paint
operation, then the correct way to do this is with an AffineTransform
.
Graphics2D graphic;
graphic.drawRenderedImage(image, AffineTransform.getRotateInstance(Math.PI));
不幸的是, AffineTransform
不支持透视变换(根据定义,如果平行线保持平行,则变换仅是仿射)。对于透视变换,您需要使用Java Advanced Imaging API,该API可从Oracle网站下载。它有一个 PerspectiveTransform
可以满足您的需求。不幸的是,JAI使用起来不那么直接,因为它更加灵活。
Unfortunately AffineTransform
does not support perspective transforms (by definition a transform is only Affine if parallel lines remain parallel). For perspective transforms you need to use the Java Advanced Imaging API which can be downloaded from Oracle's site. It has a PerspectiveTransform
that does just what you want. Unfortunately JAI is not quite as straightforward to use as it is much more flexible.
这篇关于有没有一种简单的方法可以使用Java绕z轴旋转图像而无需跳入Java 3d?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!