What do x,y in java.awt.Graphics.drawImage() refer to?
The x,y in drawImage refer to the location on the screen (relative to the origin or translation of the Graphics object) at which to draw the upper left corner of the image. The reason this is confusing in the “drawing a subset of an image” example you have is that if you want pixel i,j of the image to appear at 0,0 which is also the upper left corner of the clipping rectangle, then you have to draw the image at screen location -i,-j so that the screen location 0,0 is i pixels from the left edge of the image and j pixels from the top edge of the image – thus screen location 0,0 shows image pixel i,j…