so I'm trying to rotate an image in Java. It runs for a couple of seconds and when I check the folder while it's running I can see that the image is being manipulated. However, after a few more seconds the image seems to disappear from the folder and I'm flagged with a FileNotFoundException. I've checked with other image rotating questions around here and my code seems similar to theirs so I can't really tell what I'm doing wrong.
If anyone can point it out or send me a link that could help that'd be great. Thanks!
public static void rotate(String path){
try{
File input = new File(path);
BufferedImage image = ImageIO.read(input);
BufferedImage image2;
int x, ave;
do{
for(x = ave = 0; x < image.getWidth() && ave == 0; x++){
Color c = new Color(image.getRGB(x, image.getHeight()-1));
ave = (c.getBlue() + c.getGreen() + c.getRed())/3;
}
if(x < image.getWidth()){
AffineTransform t = new AffineTransform();
t.rotate(Math.toRadians(1), image.getWidth(), image.getHeight());
AffineTransformOp o = new AffineTransformOp(t, AffineTransformOp.TYPE_BILINEAR);
image2 = o.filter(image, null);
ImageIO.write(image2, "png", new File("C:/Users/Table/Desktop/ALPHABET/A3.png"));
}
}while(x < image.getWidth());
}catch(IOException e){}
}
P.S. If anyone's curios what I'm trying to rotate, it's basically an image of a letter. The letter has a straight line beneath it that indicates the proper orientation of the letter. That's what the for() loop is for.