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:

enter image description here

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top