public BufferedImage paneToBufferedImg() {
        BufferedImage bi;
        if (canvas.getWidth() <= 0 || canvas.getHeight() <= 0) {
            bi = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
        } else {
            bi = new BufferedImage(canvas.getWidth(), canvas.getHeight(), BufferedImage.TYPE_INT_RGB);
        }

        canvas.paint(bi.getGraphics());

        return bi;
    }