有没有什么简单的方法可以使用java围绕z轴旋转图像而不跳入java 3d? [英] Is there any easy way to rotate an image about z axis using java without jumping into java 3d?

查看:19
本文介绍了有没有什么简单的方法可以使用java围绕z轴旋转图像而不跳入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.

推荐答案

如果您指的是在 Swing paint 操作期间旋转图像,那么正确的方法是使用 仿射变换.

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,它可以从 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆