int height = Math.round(((int) rect.getHeight())*(float)resizePercentage);
int width = Math.round(((int) rect.getWidth())*(float)resizePercentage);
BufferedImage imageInstance = new BufferedImage((int)recWidth, (int)rectHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = (Graphics2D) imageInstance.getGraphics();
graphics = new CwtAwtGraphicsContext(g2);
// setup user space
AffineTransform imgTransform = graphics.getTransform();
imgTransform.scale(1, -1);
imgTransform.translate(-rect.getMinX(), -rect.getMaxY());
graphics.setTransform(imgTransform);