Java图像转换

发布于 2024-09-08 14:33:33 字数 233 浏览 3 评论 0原文

我需要为我的图像创建 3D 深度效果。数字 1 是我所拥有的,数字 2 是我想要转换数字 1 的形状。那么在 Java 标准图形库或其他一些开源库中是否有任何方法可以实现这一点?

替代文本

I need to create 3d depth effect for my image. Number 1 is what I have and number 2 is shape where I want to transform number 1. So is there any method for that in Java standard graphics libraries or some other open source libraries?

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ㄟ。诗瑗 2024-09-15 14:33:33

使用 AffineTransform 类无法完成此操作。请参阅维基百科关于仿射变换的文章:

一般来说,仿射变换由线性变换(旋转、缩放或剪切)和平移(或“平移”)组成。

您需要的是某种形式的透视变换。来自 http:// java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/PerspectiveTransform.html

透视变换能够将任意四边形映射到另一个任意四边形,同时保持直线的直线度。 与仿射变换不同,源中线的并行性不一定会保留在输出中。

来自 http://answers.google.com/answers/threadview/id/515829.html

Java 高级成像 API 允许您轻松执行透视变换。

与 Java2D 和 Java3D 中一样,这些例程是经过优化的,但不是
以通常的 java 解释方式运行 - 所以它们非常快
好吧。

JAI 可从以下位置下载

http://java.sun.com/产品/java-media/jai/downloads/download-1_1_2.html

您可以在以下位置找到有关如何运行透视变换的信息:

http://java.sun.com/products /java-media/jai/forDevelopers/jai1_0_1guide-unc/

This can not be done using the AffineTransform class. See Wikipedia article on affine transformation:

In general, an affine transformation is composed of linear transformations (rotation, scaling or shear) and a translation (or "shift").

What you need is some form of perspective transform. From http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/javax/media/jai/PerspectiveTransform.html

A perspective transformation is capable of mapping an arbitrary quadrilateral into another arbitrary quadrilateral, while preserving the straightness of lines. Unlike an affine transformation, the parallelism of lines in the source is not necessarily preserved in the output.

From http://answers.google.com/answers/threadview/id/515829.html

The Java Advanced Imaging API allows you to easily perform perspective transform.

As in Java2D and Java3D, these routines are optimised, they are not
run in the usual java interpreted manner - so they are very fast as
well.

The JAI is downloadable from

http://java.sun.com/products/java-media/jai/downloads/download-1_1_2.html

You can find info on how to run perspective transform in:

http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/

花开半夏魅人心 2024-09-15 14:33:33

如果您想在 3D 中进行大量快速绘图,那么我建议您研究 3D 渲染解决方案,例如 OpenGL / JOGL。

如果这只是一个快速的一次性转换,那么您可以通过

  • 循环 2 中的所有线条来
  • 轻松模拟这一点。缩放 1 中的相应线条并将其绘制在 2 中的线条上,将其拉伸到正确的比例(您可以需要一些基本的数学知识才能解决这个问题)

If you want to do a lot of fast drawing in 3D then I'd suggest looking into a 3D rendering solution such as OpenGL / JOGL.

If it is just a quick one-off transformation then you can simulate this pretty easily by

  • Looping over all the lines in 2.
  • Scaling the corresponding line in 1. and drawing it over the line in 2, stretching it to the right proportion (you'll need some basic maths to work this out)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文