I have been attempting to do this for about a week. Every single time I have tried something it failed. So I turned to copying others code... they said the code worked for them... yet it failed for me.
The piece of code that I ended up liking came from the following.
How To Crop Image in Java (StackOverflow)
So then from that I basically copied / made this.
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
public class ImageEditor {
public BufferedImage crop(BufferedImage src, Rectangle rect) {
BufferedImage dest = new BufferedImage(rect.getWidth(), rect.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics g = dest.getGraphics();
g.drawImage(src, 0, 0, rect.getWidth(), rect.getHeight(), rect.getX(), rect.getY(), rect.getX() + rect.getWidth(), rect.getY() + rect.getHeight(), null);
g.dispose();
return dest;
}
}
I got the following errors with this code.
Thanks for the help in advance!