Java - Squish Image / BufferedImage to Four Points

时间:2017-12-14 19:41:10

标签: java image graphics

我最近一直在做一些图形,但我遇到了一个问题。我似乎找不到在四点之间压缩图像的好方法。这听起来像一个简单的操作,如果我刚刚失踪,可以随意指出它。这就是我理想的想法: Before/After

值得注意的是,整个图像必须被压缩成新的多边形,而不仅仅是裁剪。 编辑:我的代码看起来像这样:

import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class Main extends JPanel {
    public static Image image;
    public static JFrame frame;
    public static Main main;

    public static void main(String[] args) throws IOException {
        File imageFile = new File("test.png");
        image = ImageIO.read(imageFile);

        frame = new JFrame();
        frame.setSize(500, 500);

        main = new Main();
        frame.add(main);
        frame.setVisible(true);
    }

    public void paintComponent(Graphics g) {
        int p1x = 10;
        int p1y = 10;

        int p2x = 400;
        int p2y = 450;

        int p3x = 360;
        int p3y = 23;

        int p4x = 23;
        int p4y = 500;

        /*////////////////

        Draw the image between all of the defined points.

        /*////////////////
    }
}

0 个答案:

没有答案