final BufferedImage bufferImage = new BufferedImage((int)width, (int)height, BufferedImage.TYPE_INT_RGB);
final Graphics2D graphic = bufferImage.createGraphics();
final double scale = Math.min(maxSize/width, maxSize/height);
final BufferedImage bufferImage2 = new BufferedImage((int)maxSize, (int)maxSize, BufferedImage.TYPE_INT_ARGB);
final Graphics2D graphic2 = bufferImage2.createGraphics();
final IViewShape view = View2DTK.getFactory().createView(selection);
final AffineTransform aff = new AffineTransform();
graphic.setColor(Color.WHITE);
graphic.fillRect(0, 0, (int)width, (int)height);
graphic.scale(scale, scale);
graphic.translate(-tl.getX()+dec, -tl.getY()+dec);
aff.translate(0, 0);
view.paint(graphic, null);
view.flush();
graphic2.setColor(Color.WHITE);
graphic2.fillRect(0, 0, (int)maxSize, (int)maxSize);
graphic2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
graphic2.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);