简体   繁体   中英

Draw an Image in arbitrary corners

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM