AffineTransform at = g.getTransform();
Rectangle c = g.getClipBounds();
if (at != null){
int atType = at.getType();
if (atType == AffineTransform.TYPE_TRANSLATION) {
c.translate((int)Math.round(at.getTranslateX()), (int)Math.round(at.getTranslateY()));
}
}
WritableRaster wr = ((BufferedImageGraphics2D)g).getWritableRaster();
Rectangle rBounds = wr.getBounds();