BufferedImage image = new BufferedImage((int)Math.ceil(selectionBounds.getWidth() * clipboardScale + 2 * extraMargin),
(int)Math.ceil(selectionBounds.getHeight() * clipboardScale + 2 * extraMargin), BufferedImage.TYPE_INT_RGB);
Graphics2D g2D = (Graphics2D)image.getGraphics();
// Paint background in white
g2D.setColor(Color.WHITE);
g2D.fillRect(0, 0, image.getWidth(), image.getHeight());
// Change component coordinates system to plan system
g2D.scale(clipboardScale, clipboardScale);
g2D.translate(-selectionBounds.getMinX() + extraMargin,
-selectionBounds.getMinY() + extraMargin);
setRenderingHints(g2D);