Java - Anamorphism (image manipulation)

1

Good night, I'm creating an application for a specific purpose, that manipulate image, I'm using methods like:

image.BufferedImage
Graphics2D
RenderingHints

In this context I'm getting a specific image for example

Manipulatingitandtransformingit

Generatingananamorphism,however,I'mdoingthefollowing,rotatingtheimageatthedesiredangle,thenstretchingthedesiredsidelaterallyandreturningtheoriginaltotheangle,forexample,rotating(40.0degrees)thenstretching20%andde-rotated(-40.0degrees),thenyouhavethiseffectofanamorphismandIsavetheimageinthedesiredfolder,Iwantedtoknowifthereisanyothermethodthatonlyputtingtheangledoestheanamorphismalonewithoutallthesework?

  

WhatI'musing  (BufferedImageresize)  (BufferedImagerotateMyImage)

publicstaticBufferedImageresize(BufferedImageimg,StringoutputFileLocation,Stringextension){intnew_largura=img.getWidth();intnew_altura=img.getHeight();intmat=new_largura+((new_largura*50)/100);new_largura=new_largura+mat;BufferedImagenew_img;new_img=newBufferedImage(new_largura,new_altura,BufferedImage.TYPE_INT_RGB);Graphics2Dgraphics2d=new_img.createGraphics();graphics2d.drawImage(img,0,0,new_largura,new_altura,null);writeImage(new_img,outputFileLocation,"png");

    return img;
}


public static BufferedImage rotateMyImage(BufferedImage img, double angle, String outputFileLocation) {
    int w = img.getWidth();
    int h = img.getHeight();
    int iw = w+200;
    int ih = h+200;
    BufferedImage dimg =new BufferedImage(iw, ih, img.getType());
    Graphics2D g = dimg.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias!
            RenderingHints.VALUE_ANTIALIAS_ON);

    g.rotate(Math.toRadians(angle), iw/2, ih/2);

    // ensure image will fit
    int dw = w;
    int dh = h;
    if (dw > iw) {
        dh = (int)(dh * ( (float) iw / (float) dw)) ;
        dw = iw;
    }
    if (dh > ih) {
        dw = (int)(dw * ( (float) ih / (float) dh)) ;
        dh = ih;
    }
    // centre on page
    int dx = (iw - dw) / 2;
    int dy = (ih - dh) / 2;

    g.drawImage(img, dx, dy, dx+dw, dy+dh, 0, 0, w, h, null);

    writeImage(dimg, outputFileLocation, "png");

    //g.drawImage(img, null, 0, 0);
    return dimg;
}

OK works, but I need to get into various folders from the 0-0 folder, 0-1 .... 0-4 ... to the 10-10 folder and each folder has 131 image files, each folder represents a different angle to distort and make the anamorphism and I need to take the image, make the anamorphism and save it overlapping the original in each image, are approximately 14440 images, wanted to facilitate the process because it is consuming too much of the computer giving processing error before to end up, besides being too much lace work (for) to be executed, I wanted to know if there is any method for this activity?

Thank you for your help.

    
asked by anonymous 05.08.2018 / 23:44

0 answers