Can you please comment this code? I understand some parts but not all.
This code is to rotate an image 90 degrees counter clockwise:
public static void rotate(String originalImage, String convertedImage) throws Exception {
BufferedImage bufferImg = ImageIO.read(new File(originalImage));
BufferedImage bufferImgOut = new BufferedImage(bufferImg.getWidth(),bufferImg.getHeight(), bufferImg.getType());
for( int x = 0; x < bufferImg.getWidth(); x++ ) {
for( int y = 0; y < bufferImg.getHeight(); y++ ) {
int px = bufferImg.getRGB(x, y);
int destY = bufferImg.getWidth() - x - 1; //what does this line do?
bufferImgOut.setRGB(y,destY, px);
}
}
File outputfile = new File(convertedImage);
ImageIO.write(bufferImgOut, "png", outputfile);
}