question: private void drawChunk ( Image image , Graphics g , boolean stretch , int dx1 , int dy1 , int dx2 , int dy2 , int sx1 , int sy1 , int sx2 , int sy2 , boolean xDirection ) { if ( dx2 - dx1 <= 0 || dy2 - dy1 <= 0 || sx2 - sx1 <= 0 || sy2 - sy1 <= 0 ) { return ; } if ( stretch ) { g . drawImage ( image , dx1 , dy1 , dx2 , dy2 , sx1 , sy1 , sx2 , sy2 , null ) ; } else { int xSize = sx2 - sx1 ; int ySize = sy2 - sy1 ; int deltaX ; int deltaY ; if ( xDirection ) { deltaX = xSize ; deltaY = 0 ; } else { deltaX = 0 ; deltaY = ySize ; } while ( dx1 < dx2 && dy1 < dy2 ) { int newDX2 = Math . min ( dx2 , dx1 + xSize ) ; int newDY2 = Math . min ( dy2 , dy1 + ySize ) ; g . drawImage ( image , dx1 , dy1 , newDX2 , newDY2 , sx1 , sy1 , sx1 + newDX2 - dx1 , sy1 + newDY2 - dy1 , null ) ; dx1 += deltaX ; dy1 += deltaY ; } } }
target:  Draws a portion of an image, stretched or tiled.