g.transform(transform);
AffineTransform inv = transform.createInverse();
Shape fillRect = new Rectangle2D.Double(0,0,img.getWidth(),img.getHeight());
fillRect = inv.createTransformedShape(fillRect);
g.setPaint(paint);
g.fill(fillRect);
if (invert) {
AffineTransform tx = new AffineTransform();
tx.scale(1,-1);
tx.translate(-xoffset,-yoffset);
g.drawImage(img,tx,null);