public static void crop(Rectangle rect) {
        if (lastScreenshot == null)
            return;
        
        BufferedImage image = lastScreenshot.getImage();
        int x = (int) rect.getX();
        int y = (int) rect.getY();
        int width = (int) rect.getWidth();
        int height = (int) rect.getHeight();
        // Crop the image to the secified dimensions and re-create the screenshot object.
        BufferedImage newImage = image.getSubimage(x, y, width, height);
        lastScreenshot = new ScreenshotImage(newImage, newImage.getWidth(), newImage.getHeight());
    }