Search code examples
javabufferedimageaffinetransform

Java, fake 3D effect


How to achieve effect like on the pic below using AffineTransform or something on AffineTransform? Or any other effect/transform in Java that I can use on BufferedImage ?

enter image description here


Solution

  • The effect you want to achieve is called Skewing
    Take a look at the Skew section @ http://www.javaxt.com/javaxt-core/javaxt.io.Image/

    First of all download the javaxt api. The Image class has a public constructor which accepts BufferedImage as an argument , see below

       javaxt.io.Image image = new javaxt.io.Image(java.awt.image.BufferedImage bufferedImage);
        int width = image.getWidth();
        int height = image.getHeight();
        image.setCorners(20, 70,              //UL
                         width-70, 0,         //UR
                         width+20, height-50, //LR
                         50, height);         //LL
    

    setCorners is sed to skew an image by updating the corner coordinates. Coordinates are supplied in clockwise order starting from the upper left corner.