在任意角落绘制图像 [英] Draw an Image in arbitrary corners

查看:124
本文介绍了在任意角落绘制图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个正常的形象。我在矩形图像的每个角上定义了Click- and Drag-Listeners。我想自由地转换每个角落并在屏幕上绘制它。



AffineTransform类提供了转换的可能性,但我找不到实现这一目标的方法。 / p>

我在android中使用Matrix.setPolytoPoly方法实现了相同的功能。然而在java swing中没有等价物。



谢谢!



编辑:
我想要用以下图像来说明这个过程:





当我将一个角拖到左上角时会发生这种情况。现在我遇到的问题是,我不相信人们可以用简单的方法用纯粹的3x3矩阵来模拟这种行为。我查看了android本机代码来观察行为,但实际上它在本机代码中非常深。

解决方案


知道如何做到这一点?


您的更新显示转换不是仿射,因为平行线不保持平行。 Java Advanced Imaging (JAI)提供所需的投射功能通过抽象类 Warp


So i have a normal image. I defined Click- and Drag-Listeners on each corner of the rectangular image. I want to freely transform each of the corners and paint it on the screen.

The AffineTransform class provides transformation possibilities but i couldn't find a way to realize this.

I have implemented the same function in android with the Matrix.setPolytoPoly method. However there is no equivalent in java swing.

Thanks!

Edit: I would like to illustrate this process with the following image:

This should happen when i drag one corner to the upper left. Now the problem that i have is, that i don't believe that one can model such a behaviour with a pure 3x3 matrix in an easy way. I looked at the android native code to watch the behaviour, but it's actually pretty deep in the native code.

解决方案

Any idea of how to do that?

Your update shows that the transformation is not affine, as parallel lines do not remain parallel. Java Advanced Imaging (JAI) provides the required projective capabilities through the abstract class Warp.

这篇关于在任意角落绘制图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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