private void drawTranslatedRenderedImage(RenderedImage img,Rectangle region,int i2uTransX,int i2uTransY){
  int tileGridXOffset=img.getTileGridXOffset();
  int tileGridYOffset=img.getTileGridYOffset();
  int tileWidth=img.getTileWidth();
  int tileHeight=img.getTileHeight();
  int minTileX=getTileIndex(region.x,tileGridXOffset,tileWidth);
  int minTileY=getTileIndex(region.y,tileGridYOffset,tileHeight);
  int maxTileX=getTileIndex(region.x + region.width - 1,tileGridXOffset,tileWidth);
  int maxTileY=getTileIndex(region.y + region.height - 1,tileGridYOffset,tileHeight);
  ColorModel colorModel=img.getColorModel();
  Rectangle tileRect=new Rectangle();
  for (int ty=minTileY; ty <= maxTileY; ty++) {
    for (int tx=minTileX; tx <= maxTileX; tx++) {
      Raster raster=img.getTile(tx,ty);
      tileRect.x=tx * tileWidth + tileGridXOffset;
      tileRect.y=ty * tileHeight + tileGridYOffset;
      tileRect.width=tileWidth;
      tileRect.height=tileHeight;
      clipTo(tileRect,region);
      WritableRaster wRaster=null;
      if (raster instanceof WritableRaster) {
        wRaster=(WritableRaster)raster;
      }
 else {
        wRaster=Raster.createWritableRaster(raster.getSampleModel(),raster.getDataBuffer(),null);
      }
      wRaster=wRaster.createWritableChild(tileRect.x,tileRect.y,tileRect.width,tileRect.height,0,0,null);
      BufferedImage bufImg=new BufferedImage(colorModel,wRaster,colorModel.isAlphaPremultiplied(),null);
      copyImage(bufImg,tileRect.x + i2uTransX,tileRect.y + i2uTransY,0,0,tileRect.width,tileRect.height,null,null);
    }
  }
}

private void drawTranslatedRenderedImage ( RenderedImage img , Rectangle region , int i2uTransX , int i2uTransY ) { int tileGridXOffset = img . getTileGridXOffset ( ) ; int tileGridYOffset = img . getTileGridYOffset ( ) ; int tileWidth = img . getTileWidth ( ) ; int tileHeight = img . getTileHeight ( ) ; int minTileX = getTileIndex ( region . x , tileGridXOffset , tileWidth ) ; int minTileY = getTileIndex ( region . y , tileGridYOffset , tileHeight ) ; int maxTileX = getTileIndex ( region . x + region . width - 1 , tileGridXOffset , tileWidth ) ; int maxTileY = getTileIndex ( region . y + region . height - 1 , tileGridYOffset , tileHeight ) ; ColorModel colorModel = img . getColorModel ( ) ; Rectangle tileRect = new Rectangle ( ) ; for ( int ty = minTileY ; ty <= maxTileY ; ty ++ ) { for ( int tx = minTileX ; tx <= maxTileX ; tx ++ ) { Raster raster = img . getTile ( tx , ty ) ; tileRect . x = tx * tileWidth + tileGridXOffset ; tileRect . y = ty * tileHeight + tileGridYOffset ; tileRect . width = tileWidth ; tileRect . height = tileHeight ; clipTo ( tileRect , region ) ; WritableRaster wRaster = null ; if ( raster instanceof WritableRaster ) { wRaster = ( WritableRaster ) raster ; } else { wRaster = Raster . createWritableRaster ( raster . getSampleModel ( ) , raster . getDataBuffer ( ) , null ) ; } wRaster = wRaster . createWritableChild ( tileRect . x , tileRect . y , tileRect . width , tileRect . height , 0 , 0 , null ) ; BufferedImage bufImg = new BufferedImage ( colorModel , wRaster , colorModel . isAlphaPremultiplied ( ) , null ) ; copyImage ( bufImg , tileRect . x + i2uTransX , tileRect . y + i2uTransY , 0 , 0 , tileRect . width , tileRect . height , null , null ) ; } } }
draw a portion of a renderedimage tile - by - tile with a given integer image to user space translation . the user to device transform must also be an integer translation .
